Skip to main content

Installation

Install @lifi/perps-sdk plus a provider package for each venue you trade on. Each provider package (@lifi/perps-sdk-provider-hyperliquid, @lifi/perps-sdk-provider-lighter, @lifi/perps-sdk-provider-ondo) declares @lifi/perps-sdk as a peer dependency.

Configuration

Initialize the Perps SDK client. An API key selects your fee identity through the Partner Service. The integrator name is an optional assertion that must match the API key’s identity:
The SDK supports three client configurations:
The SDK sends x-lifi-integrator only when both apiKey and integrator are set. integrator with no apiKey has no effect, because fee identity always comes from the API key. See API Reference / Authentication for the full contract. DEFAULT_API_URL still resolves to the Development host (https://develop.li.quest/v1/perps). Pass apiUrl explicitly to target the Production host (https://li.quest/v1/perps), where an API key is optional — Development requires one:

Configuration Options

These options configure createPerpsClient, the low-level client the service functions (getProviders, getAssets, etc.) take:

PerpsClient constructor options

new PerpsClient(options) — the higher-level class covering setup, trading, and app-level meta actions (see SDK / Actions) — takes a narrower option set. It forwards integrator, apiKey, apiUrl, and providers to an internal createPerpsClient call: PerpsClient has no userWallet or retry constructor option. Set the end-user wallet after construction with client.setUserWallet(wallet), and update switchChain at runtime with client.setSwitchChain(hook).

Provider Configuration

The providers option accepts two shapes. Pass an array of provider plugins (preferred for new code) to bind each DEX’s read surface to the client — looked up at runtime via client.getProvider(key):
Alternatively, pass a keyed ProviderConfigs object for per-provider tuning:
Storage for the agent / API-key signer is configured on the provider plugin (e.g. hyperliquidProvider({ storage })), not on createPerpsClient.

Request Interceptor

The requestInterceptor option lets you modify request options before each API call. This is useful for adding custom headers, logging, or integrating with authentication systems:
Get an API key from the LI.FI Partner Portal to receive your own fee identity. A client with no API key is a supported configuration and uses the default lifi fee structure.

Quick Start

Fetch available providers and assets:
For a complete end-to-end example including wallet setup, account setup, and placing an order, see SDK / Trading — End-to-End Example.

Request Cancellation

All service functions accept an optional options parameter with an AbortSignal for cancelling in-flight requests:
When the signal fires, the underlying fetch is aborted and the promise rejects with an AbortError.

Next steps