Skip to content

SDK setup

@highlightxyz/sdk is a fully typed TypeScript client, auto-generated from the backend’s OpenAPI schema. Every parameter, response, and error type matches the API exactly — there’s no manual drift.

Terminal window
bun add @highlightxyz/sdk

ESM-only. Works on Bun 1.1+, Node 20+, and modern browsers.

Minimum config — public endpoints only:

import { createHighlightClient } from "@highlightxyz/sdk";
const client = createHighlightClient({
baseUrl: "https://api.highlightv2.xyz",
});

With a JWT (from SIWE or Privy sign-in):

const client = createHighlightClient({
baseUrl: "https://api.highlightv2.xyz",
auth: () => accessToken,
security: [{ type: "http", scheme: "bearer" }],
});

The auth callback is invoked on every request, so you can refresh a cached token lazily.

With an API key (for server-to-server):

const client = createHighlightClient({
baseUrl: "https://api.highlightv2.xyz",
auth: () => process.env.HIGHLIGHT_API_KEY!,
security: [{ type: "http", scheme: "bearer" }],
});

API keys use the same bearer scheme as JWTs — just pass the plaintext.

All methods take a single flat parameters object. Path, query, and body params are merged:

// Public read
const collection = (await client.collection.get({ highlightId: "abc123" })).data;
// Auth'd list
const list = (await client.collection.list({
blockchains: [8453],
testnet: false,
types: ["OpenEdition"],
})).data;
// Auth'd create
const created = (await client.collection.create({
name: "My Drop",
description: "Genesis collection",
type: "OpenEdition",
logoMediaId: mediaUuid,
image: imageUrl,
contract: { chainId: 8453, name: "DROP", symbol: "DROP", standard: "ERC721" },
})).data;

Every method returns a discriminated result — no exceptions on non-2xx:

type SdkResponse<T> = {
data?: T;
error?: unknown;
response?: Response;
};

Pattern:

const res = await client.collection.get({ highlightId });
if (res.error) {
if (res.response?.status === 404) return null;
throw new Error(`${res.response?.status}: ${JSON.stringify(res.error)}`);
}
return res.data;

Error payloads are typed NamedError shapes — match on res.error.name for fine-grained dispatch.

All domain operations hang off client:

ClientPurposeDocs
client.collectionCollections, sales, deployCollections, Sales, Deploy workflow
client.tokenMinted token queriesTokens
client.gateAccess controlGates
client.mediaUpload & storageMedia, Upload flow
client.mechanicBuilt-in & custom mechanicsMechanics
client.contractContract recordsContracts
client.configChains & system contractsConfig
client.user.signin, client.user.siwe.nonceSign inAuth
client.apiKeyAPI key managementAuth: API keys
client.healthLiveness check

See clients overview for the full method list.

Re-exported enums and types from the root:

import {
CollectionType,
ContractStandard,
SaleType,
SaleAccessMode,
GateMatchMode,
MediaKind,
MediaScope,
MediaAssetStatus,
GenerativeEditionType,
} from "@highlightxyz/sdk";
import type {
HighlightClient,
HighlightClientConfig,
Client,
CollectionListResponses,
CollectionGetResponses,
MediaCreateUploadSessionResponses,
} from "@highlightxyz/sdk";