Reservoir SDK (JS/TS/Node)

Reservoir SDK

The Reservoir SDK is the underlying package that ReservoirKit UI uses behind the scenes to execute core functionality (listing, bidding, buying and selling). The Reservoir SDK can be used if you are using another javascript framework, executing orders via a Nodejs server or building a custom experience.

If you're using ReservoirKit UI then you're already using the sdk, and you have access to the useReservoirClient hook to retrieve the sdk in a react context and use it. If you aren't using the UI package then you'll need to follow these steps to get the sdk up and running.

Installing Reservoir SDK:

yarn add @reservoir0x/reservoir-sdk

The Reservoir SDK also requires viem to be installed, make sure that's added to your package.json if it isn't already.

yarn add viem

Configuring the Reservoir SDK

To configure the SDK we first need to create a global instance of it:

import { createClient } from "@reservoir0x/reservoir-sdk"

  chains: [{
    id: 1,
    baseApiUrl: '',
    default: true,
    apiKey: "YOUR_KEY"
  source: "YOUR.SOURCE

We start by importing the createClient function and then calling that function to create a global client, passing in the required parameters.

chainsAn array of chain objects representing reservoir chains that your application supports. Below we'll breakdown the properties of the chain object.
sourceThe source parameter can be any valid domain (e.g. It's used to attribute orders to your particular marketplace and to scrape custom metadata from your marketplace.
marketplaceFeeFee in bps included when creating an order (listing & bidding). Only relevant for native orders.
marketplaceFeeRecipientThe recipient address to receive the marketplaceFee
automatedRoyaltiesIf true, royalties will be automatically included, defaults to true. Only relevant for creating orders (listing and bidding)
normalizeRoyaltiesGlobal setting to add royalties on top of orders that do not include royalties.

Let's dive into the properties that make up a reservoir chain:

idThe id of the chain (e.g. 1 for mainnet)
baseApiUrlCan be one of our hosted api endpoints or any instance of the Reservoir indexer.
defaultOnly one chain can be the default at a time. This is used in the SDK when determining which default chain to select.
apiKeyThe apiKey is not required but should be passed in as it allows for higher rate limits. Read more about the API Keys & Rate Limits and how to instantly generate one.

Once the client has been created there are 5 core actions available to you:




Now that the Reservoir SDK is up and running lets add sweeping to our javascript application.