Set up the SDK

After you have installed the SDK, you first need to set it up.
To get started, you have to instantiate and configure the LI.FI SDK:
import { LiFi } from '@lifi/sdk'
const lifi = new LiFi({
integrator: 'Your dApp/company name'
// or
const { LiFi } = require("@lifi/sdk")
const lifi = new LiFi({
integrator: 'Your dApp/company name'
The optional config parameter can be used to pass custom configuration to the SDK:
type ConfigUpdate = {
apiUrl?: string
apiKey?: string
rpcs?: Record<number, string[]>
multicallAddresses?: Record<number, string | undefined>
defaultExecutionSettings?: ExecutionSettings
defaultRouteOptions?: RouteOptions
The apiUrl defines which backend should be called. This only has to be edited when accessing a dedicated API endpoint.
If you are interested in a dedicated API endpoint for your service, reach out via our Discord or file an issue in our repository here.
The apiKey allows you to authenticate on the API. This will give you access to custom rate limits. Check our API documentation for information on how to apply for an API key.
rpcs or multicallAddresses can be passed if custom endpoints/addresses should be used, for example to prevent rate limiting.
The RouteOptions are explained in more detail here. An explanation of ExecutionSettings is available here.

Node.js Compatibility

SDK uses native Fetch API and in Node.js 16 and lower versions fetch is not natively included, so it needs to be added manually. To provide access to Fetch API you need to patch global object using node-fetch or cross-fetch.
Here is an example using cross-fetch:
import fetch, { Headers, Request, Response } from 'cross-fetch'
if (!globalThis.fetch) {
const globalThisAny: any = globalThis
globalThisAny.fetch = fetch
globalThisAny.Headers = Headers
globalThisAny.Request = Request
globalThisAny.Response = Response
Last modified 3mo ago