> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xarchive.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAPI

> Download the 0xArchive REST API specification to generate clients and inspect request and response schemas.

export const OpenApiDetails = () => <dl className="oxa-openapi-details" aria-label="Specification details">
    <div><dt>OpenAPI</dt><dd>{"3.0.3"}</dd></div>
    <div><dt>Specification version</dt><dd>{"1.8.0"}</dd></div>
    <div><dt>REST API</dt><dd><code>{"https://api.0xarchive.io"}</code></dd></div>
  </dl>;

export const OpenApiTools = () => {
  const specificationUrl = "https://docs.0xarchive.io/openapi.json";
  const [copyState, setCopyState] = useState("");
  const [copying, setCopying] = useState(false);
  const copyUrl = async () => {
    if (copying) return;
    setCopying(true);
    setCopyState("");
    try {
      await navigator.clipboard.writeText(specificationUrl);
      setCopyState("Specification URL copied.");
    } catch {
      setCopyState("Select the URL above to copy it.");
    } finally {
      setCopying(false);
    }
  };
  return <div className="oxa-openapi-tools not-prose">
      <div className="oxa-openapi-actions">
        <a className="oxa-openapi-download" href={specificationUrl} download="openapi.json">
          Download OpenAPI JSON
        </a>
        <a className="oxa-openapi-reference" href="/api-reference">Browse endpoint reference</a>
      </div>
      <div className="oxa-openapi-url-row">
        <a className="oxa-openapi-url" href={specificationUrl}>{specificationUrl}</a>
        <button className="oxa-openapi-copy" type="button" onClick={copyUrl} aria-busy={copying} aria-label="Copy specification URL" title="Copy specification URL">
          <svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" strokeWidth="1.5" aria-hidden="true" focusable="false">
            <rect x="6" y="6" width="9" height="9" rx="2" />
            <path d="M11.5 3H5a2 2 0 0 0-2 2v6.5" />
          </svg>
        </button>
      </div>
      <div className="oxa-openapi-copy-status" role="status" aria-live="polite">{copyState}</div>
    </div>;
};

Download the REST API specification to generate a typed client, validate requests and responses, or give a coding agent the exact routes.

<OpenApiTools />

<OpenApiDetails />

## Save the specification

```bash theme={"theme":"github-dark"}
curl --fail --location \
  https://docs.0xarchive.io/openapi.json \
  --output openapi.json
```

This saves the JSON specification as `openapi.json` in your current directory. Downloading the specification is public. For authenticated REST requests, send your key in the `X-API-Key` header; each operation declares its security requirements. See [Authentication](/authentication) for key setup and public-route exceptions.

The specification covers REST routes. [WebSocket commands and channels](/websocket) have a separate contract.

## Generate a TypeScript client

Use Node.js 22.18 or newer and the downloaded `openapi.json` in a local Node project. For a new project, run `npm init --yes` first. These commands use [Hey API's Fetch client generator](https://heyapi.dev/openapi-ts/clients/fetch):

```bash theme={"theme":"github-dark"}
npm pkg set \
  'overrides.@hey-api/json-schema-ref-parser.js-yaml=4.3.2'
npm install --save-dev --save-exact \
  @hey-api/openapi-ts@0.99.0 typescript@5.9.3
npx openapi-ts -i ./openapi.json \
  -o ./src/client -c @hey-api/client-fetch
```

The generated methods, types, and Fetch client are written to `src/client`. The parser override selects a patched YAML dependency for the generator. Keep these tooling versions and your project lockfile with the specification when reproducing the client.

<Accordion title="Run a public health check">
  Save this as `health.ts`. The public `/health` route lets you check the generated client without using an API key.

  ```typescript health.ts theme={"theme":"github-dark"}
  import { healthCheck } from './src/client';
  import { client } from './src/client/client.gen';

  client.setConfig({ baseUrl: 'https://api.0xarchive.io' });

  async function main() {
    const { data, response } = await healthCheck({
      signal: AbortSignal.timeout(10_000),
      throwOnError: true,
    });
    if (response.status !== 200) {
      throw new Error(`Unexpected HTTP ${response.status}`);
    }
    console.log(data);
  }

  main().catch((error) => { throw error; });
  ```

  In a standalone project, compile and run it with:

  ```bash theme={"theme":"github-dark"}
  npx tsc --strict --target ES2022 \
    --module commonjs --lib ES2022,DOM,DOM.Iterable \
    --outDir dist health.ts
  node dist/health.js
  ```

  A successful response contains `service: "0xarchive-api"` and `status: "ok"`. In an existing application, use your project's TypeScript configuration instead of this standalone compile command.
</Accordion>

For protected operations, configure `client.setConfig({ auth: () => apiKey })`, where `apiKey` comes from your server's secret configuration. The generated client uses the `X-API-Key` security header, not Bearer authentication. Keep private keys on your server, not in browser code.

## Integration checks

* **Route and venue:** Choose the method, path, and venue family in [Endpoint reference](/api-reference). Hyperliquid core, Spot, HIP-3, HIP-4, Lighter, and Lighter on Robinhood Chain have distinct routes and symbol formats.
* **Parameters and time bounds:** Read the route's symbol format, filters, request limits, and time-window rules. Use [Venue coverage](/venue-coverage#check-one-market-before-a-job) when choosing a historical window.
* **Authentication and responses:** Set `X-API-Key` for protected routes and handle the documented responses and the error codes on [Errors](/errors). Keep the response envelope rather than assuming every route returns a bare array.
* **Pagination:** Follow the route's [pagination rules](/rest-api/pagination), including `meta.next_cursor` where provided. Validate one bounded request, for example in the [API playground](/playground), before expanding the workload.
* **Schemas:** Inspect the operation and component JSON schemas in [Schemas](/schemas) when code generation or validation needs them.

For coding-agent route selection, use the [Coding agents guide](/coding-agents). For maintained SDKs, CLI, MCP, or other execution choices, see [Choose an interface](/tooling).

## Versions and troubleshooting

Keep the downloaded specification alongside your generated client so the same input can reproduce that client. When refreshing it, compare the routes and schemas your application uses, regenerate the client, and run your integration checks. The specification version above comes from the JSON contract; this article's modification date is not an API version.

<Accordion title="Specification sources and route mismatches">
  Endpoint reference uses the specification bundled with these docs. The docs host serves that JSON directly and keeps semantic parity with `https://0xarchive.io/openapi.json`.

  If a route differs between the JSON and its reference page, use the public JSON contract for code generation. [Contact 0xArchive](mailto:support@0xarchive.io) with the method, path, specification version, and request ID when available so the discrepancy can be checked.
</Accordion>

## Next step

Browse every route with its parameters, authentication, and examples in the [Endpoint reference](/api-reference).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.