API Client

API Client

Overview

The API client is a wrapper around the Fetch API that provides a more convenient interface for making requests to all the Lootex API endpoints. You also need a valid Lootex client to create the API client.

Usage

To create the API client, you need to pass a valid Lootex client to the createApiClient function.

import { createApiClient } from 'lootex/api';
 
import { lootex } from './config';
 
const apiClient = createApiClient({
  client: lootex,
});

Example 1: Get assets of a collection

const assets = await apiClient.explore.assets({
  chainId: 1946,
  collectionSlugs: ['soneium:0x9baafaf5dfc772ce1514cbd3ed2866778505dece'],
  sortBy: 'bestListPrice',
  limit: 10,
  page: 1,
});

Example 2: Get assets of a wallet

const assets = await apiClient.explore.assets({
  chainId: 1946,
  walletAddress: '0xbF6692795A07684147838fC54A2764aa884C440c',
  limit: 10,
  page: 1,
});

Example 3: Get active listings of an asset

const orders = await apiClient.order.getOrders({
  chainId: 1946,
  contractAddress: '0x9baafaf5dfc772ce1514cbd3ed2866778505dece',
  tokenId: 1,
  limit: 10,
  page: 1,
  isFillable: true,
  isCancelled: false,
  isExpired: false,
  category: 'LISTING',
});

Endpoints

The API client provides access to the following scopes of endpoints. Please check the full documentation for more details: