Client & API Key
Creating a client
A client is simply an object containing essential information and an API key to interact with the Lootex API, which is required for most of the SDK’s modules.
You can create a client using the createClient
function, and store it in a variable for reuse across your application.
config.ts
import { createLootexClient } from 'lootex';
export const lootex = createLootexClient({
apiKey: 'your_api_key',
environment: 'development',
customHeaders: {
'referer': 'https://your_domain' // only required in server side
}
});
Using a client
Once you have a client, you can pass it to all of the modules that require it. For example, to start using the Lootex Aggregator, you can do the following:
src/app/page.tsx
import { lootex } from './config';
import { createAggregator } from 'lootex/aggregator';
const aggregator = createAggregator({ client: lootex });
await aggregator.queryOrders(); // or any other function that requires a client
Obtaining an API key
For the moment, you can only obtain an API key by contacting us at contact@lootex.io.