> ## Documentation Index
> Fetch the complete documentation index at: https://docs.li.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure SDK

> Get started and set up LI.FI SDK in just a few lines of code.

## Create Client

To get started, you need to create an SDK client for the LI.FI SDK. This client contains the shared settings and data required for the proper functioning of other SDK features that developers will use. The client can be configured with providers and used throughout your application.

```typescript theme={"system"}
import { createClient } from '@lifi/sdk';

const client = createClient({
  integrator: 'Your dApp/company name',
});
```

## Parameters

| Parameter               | Required | Default               | Description                                                                                                                                                                                                                                                                                                                                                                                     |
| ----------------------- | -------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `integrator`            | Yes      |                       | LI.FI SDK requires an integrator option to identify partners and allows them to monitor their activity on the partner dashboard, such as the transaction volume, enabling better management and support. Usually, the integrator option is your dApp or company name. This string must consist only of letters, numbers, hyphens, underscores, and dots and be a maximum of 23 characters long. |
| `apiKey`                | No       |                       | Unique API key for accessing LI.FI API services. Necessary for higher rate limits. Read more [Rate Limits & API Key](/api-reference/rate-limits)                                                                                                                                                                                                                                                |
| `apiUrl`                | No       | `https://li.quest/v1` | The base URL for the LI.FI API. This is the endpoint through which all API requests are routed. It can be changed to the staging environment to test new features, for example.                                                                                                                                                                                                                 |
| `userId`                | No       |                       | A unique identifier for the user of your application. This can be used to track user-specific data and interactions within the LI.FI.                                                                                                                                                                                                                                                           |
| `routeOptions`          | No       |                       | Custom options for routing, applied when using `getQuote`, `getRoutes`, and `getContractCallsQuote` endpoints. These options can be configured once during SDK initialization or passed each time those functions are called.                                                                                                                                                                   |
| `rpcUrls`               | No       |                       | A mapping of chain IDs to arrays of RPC URLs. These URLs might be used for transaction execution and data retrieval.                                                                                                                                                                                                                                                                            |
| `providers`             | No       |                       | An array of SDK providers (e.g., `EthereumProvider()`, `SolanaProvider()`). Providers can also be set later using `client.setProviders()`.                                                                                                                                                                                                                                                      |
| `executionOptions`      | No       |                       | Default execution options applied to all route executions. Individual executions can override these options.                                                                                                                                                                                                                                                                                    |
| `preloadChains`         | No       | `true`                | A flag to enable preloading of chain data. When enabled, chains are fetched from the API on client creation.                                                                                                                                                                                                                                                                                    |
| `chainsRefetchInterval` | No       |                       | Interval in milliseconds to refetch chain data from the API.                                                                                                                                                                                                                                                                                                                                    |
| `disableVersionCheck`   | No       | `false`               | A flag to disable version checking of the SDK. By default, the SDK checks its version on initialization and logs a message in the console if a new version is available, prompting the user to update the SDK.                                                                                                                                                                                  |
| `debug`                 | No       | `false`               | A flag to enable debug logging in the SDK.                                                                                                                                                                                                                                                                                                                                                      |
| `requestInterceptor`    | No       |                       | A function to intercept and modify outgoing API requests before they are sent.                                                                                                                                                                                                                                                                                                                  |
| `storage`               | No       |                       | A custom storage implementation for persisting SDK data (e.g., chain data, route execution state). Uses `LocalStorageAdapter` in browser environments and `InMemoryStorage` in Node.js by default.                                                                                                                                                                                              |

<Tip>
  To learn how to use `routeOptions` for monetization, including configuring
  fees, see the [Monetize the SDK](/sdk/monetize-sdk) guide.
</Tip>

<Note>
  Setting up providers is not required if you are using the SDK solely to access
  the LI.FI API without quote/route SDK execution functionality and plan to
  handle the execution independently. Providers can be added later using the
  `client.setProviders()` method.
</Note>

## Setting custom RPC URLs

```typescript theme={"system"}
import { createClient, ChainId } from '@lifi/sdk';

const client = createClient({
  integrator: "Your dApp/company name",
  rpcUrls: {
    [ChainId.ARB]: ["https://arbitrum-example.node.com/"],
    [ChainId.SOL]: ["https://solana-example.node.com/"],
  },
});
```

<Warning>
  In a production app, it is recommended to pass through your authenticated RPC provider URL (Alchemy, Infura, Ankr, etc).

  If no RPC URLs are provided, LI.FI SDK will default to public RPC providers.

  Public RPC endpoints (especially Solana) can sometimes rate-limit users depending on location or during periods of heavy load, leading to issues such as incorrectly displaying balances or errors with transaction simulation.
</Warning>

## Client Methods

The SDK client provides various methods to access configuration and manage providers. All methods are called on the client instance.

```typescript theme={"system"}
import { createClient } from '@lifi/sdk';

const client = createClient({
  integrator: 'Your dApp/company name',
});
```

## Client API

| Method                                   | Description                                                                                                                                  |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `config`                                 | Returns the current SDK configuration (read-only).                                                                                           |
| `providers`                              | Returns the array of configured providers (read-only).                                                                                       |
| `getProvider(type: ChainType)`           | Returns the provider for the specified chain type, or `undefined` if not found.                                                              |
| `setProviders(providers: SDKProvider[])` | Sets the providers in the SDK client. If a provider already exists for a chain type, it will be updated with the new information.            |
| `setChains(chains: ExtendedChain[])`     | Sets the chains in the SDK client. Useful for preloading or overriding chain data.                                                           |
| `getChains()`                            | Returns a promise that resolves to the list of available chains.                                                                             |
| `getChainById(chainId: ChainId)`         | Returns a promise that resolves to the chain configuration for the specified chain ID. Throws an error if the chain is not found.            |
| `getRpcUrls()`                           | Returns a promise that resolves to the RPC URLs mapping for all configured chains.                                                           |
| `getRpcUrlsByChainId(chainId: ChainId)`  | Returns a promise that resolves to the array of RPC URLs for the specified chain ID. Throws an error if no RPC URLs are found for the chain. |

## Example: Using Client Methods

```typescript theme={"system"}
import { createClient, ChainId } from '@lifi/sdk';

const client = createClient({
  integrator: "Your dApp/company name",
});

// Get all available chains
const chains = await client.getChains();

// Get a specific chain
const ethereumChain = await client.getChainById(ChainId.ETH);

// Get RPC URLs for all chains
const rpcUrls = await client.getRpcUrls();

// Get RPC URLs for a specific chain
const arbitrumRpcUrls = await client.getRpcUrlsByChainId(ChainId.ARB);

// Access configuration
console.log(client.config.integrator);
console.log(client.config.apiUrl);

// Set providers (see Configure SDK Providers section)
client.setProviders([
  // ... your providers
]);
```
