ReservoirKit Client

ReservoirKit Client

ReservoirKit Client is the underlying package that ReservoirKit UI uses behind the scenes to execute core functionality (listing, bidding, buying and selling). ReservoirKit Client 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 client, and you have access to the useReservoirClient hook to retrieve the client 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 client up and running.

Installing ReservoirKit Client:

yarn add @reservoir0x/reservoir-kit-client

ReservoirKit client also requires ethers to be installed, make sure that's added to your package.json if it isn't already.

yarn add ethers

Configuring ReservoirKit Client

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

import { createClient } from "@reservoir0x/reservoir-kit-client"

  apiBase: "",
  apiKey: "YOUR_API_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.

apiBaseThe apiBase can be one of our hosted api endpoints or any instance of the Reservoir indexer. This is a required option.
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.
sourceThe source parameter is optional if you're building a browser application as ReservoirKit will pull the source from the domain hosting the app but if you're developing a server that uses ReservoirKit Client then you need to provide a source. The source can be any domain and is used to attribute orders to your particular marketplace.
automatedRoyaltiesIf true, royalties will be automatically included, defaults to true. Only relevant for creating orders (listing and bidding)
referralFeeFee in bps applied on top of an order when filling it (buying)
referralFeeRecipientThe recipient address to receive the referralFee
marketplaceFeeFee in bps included when creating an order (listing & bidding). Only relevant for native orders.
marketplaceFeeRecipientThe recipient address to receive the marketplaceFee

Once the client has been initialized you can use it like so:

import { getClient } from "@reservoir0x/reservoir-kit-client";


Here we gain access to the client by importing a method called getClient, which when executed will return a client for us to use, it's important to note here that the client may be null if not initialized. From this point we have access to actions that we can trigger from our application. In this case we triggered the buyToken action and passed in the required parameters.



Now that ReservoirKit Client is up and running lets add sweeping to our javascript application.

Did this page help you?