Skip to main content

Introduction

The Long.xyz REST API is built using ts-rest, providing end-to-end type safety between client and server. All API contracts are available in the @longdotxyz/shared package.

Installation

npm install @longdotxyz/shared @ts-rest/core zod

Authentication

All requests require an API key in the X-API-KEY header:
const headers = {
  'X-API-KEY': 'your-api-key-here'
};
Contact the Long.xyz team to obtain an API key.

Client Setup

import { initClient } from '@ts-rest/core';
import { rootContract } from '@longdotxyz/shared';

const client = initClient(rootContract, {
  baseUrl: 'https://api.long.xyz/v1',
  baseHeaders: {
    'X-API-KEY': process.env.LONG_API_KEY!,
  },
});

First Request

import { AssetStatus } from '@longdotxyz/shared';

const { status, body } = await client.assets.listAssets({
  query: {
    status: AssetStatus.LIVE,
    limit: 10,
  },
});

if (status === 200) {
  console.log('Assets:', body.result);
}

Response Structure

ts-rest responses include:
  • status: HTTP status code
  • body: Typed response body
  • headers: Response headers

Available Contracts

  • assets: Asset management
  • auctions: Auction operations
  • auctionTemplates: Template management
  • communities: Community data
  • ipfs: File uploads
  • quotes: Trading quotes