# Clients and codegen

> Generate a typed client from the OpenAPI document, or call the API with fetch. There is no SDK to install.

Source: https://getchord.xyz/docs/clients/

The whole API is one OpenAPI 3.1 document, kept in step with the routes:

```
https://getchord.xyz/docs/openapi.json
```

It has every endpoint in this reference, with parameter constraints, response schemas and the same real examples. Feed it to a generator or to a model.

## TypeScript with openapi-typescript

```bash
npx openapi-typescript https://getchord.xyz/docs/openapi.json -o chord.d.ts
```

```ts
import type { paths } from "./chord";
import createClient from "openapi-fetch";

const chord = createClient<paths>({ baseUrl: "https://api.getchord.xyz/v1", headers: { "X-API-Key": process.env.CHORD_API_KEY ?? "" } });

const { data } = await chord.GET("/arc/tokens", { params: { query: { limit: 20, sort: "volume" } } });
for (const t of data?.tokens ?? []) console.log(t.symbol, t.priceUsd, t.volume24h, t.flags ?? []);
```

## Plain fetch

Nothing in the API needs more than `fetch`. Amounts are strings, so use `BigInt` for arithmetic.

```ts
const A = "https://api.getchord.xyz/v1";
const quote = await fetch(`${A}/quote?chain=5042&inputMint=0x3600000000000000000000000000000000000000&outputMint=0x171a4217b86a807a64eb94757db6849fb4bdbaa0&amount=5000000&slippageBps=100`).then((r) => r.json());
if (quote.routePlan.length === 0) throw new Error(quote.noRouteReason);
const { transaction } = await fetch(`${A}/swap`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ quoteResponse: quote, userPublicKey: wallet, chain: 5042 }) }).then((r) => r.json());
```

## Python

```python
import requests
A = "https://api.getchord.xyz/v1"
r = requests.get(f"{A}/arc/trending", params={"limit": 10}, headers={"X-API-Key": KEY}, timeout=20)
r.raise_for_status()
for t in r.json()["tokens"]:
    print(t["symbol"], t["score"], t["change1hPct"])
```

## Other generators

Any OpenAPI 3.1 generator works: `openapi-generator-cli` for Go, Java, Rust or Swift, `orval` or `oazapfts` for TypeScript, `datamodel-codegen` for Pydantic models. The document uses `oneOf`, `allOf` and nullable type arrays (`["number", "null"]`), so pick a generator that understands 3.1.

## Agents

If the caller is a model, hand it the document or [llms.txt](/docs/agents/llms-txt/), or use the [MCP server](/docs/agents/mcp/) and the [function-calling manifest](/docs/agents/function-calling/), which wrap the API as tools.
