Skip to main content
A typed TypeScript client lives in the app repo at web/src/lib/api-client. It’s drift-tested against the checked-in OpenAPI spec: when the spec moves, the client moves with it or the test suite fails. It’s not on npm yet. Use it as source or as a reference implementation.
Want a package release? That needs decisions on package name, semver policy, changelog ownership, and npm access. Open an issue if you depend on it.

What it handles

  • Authorization: Bearer header injection.
  • Path parameter interpolation (/trader/{address}, /market/{condition_id}/intel).
  • Repeated query parameters like expand=strategy&expand=categories. The API also accepts the legacy expand[] form.
  • JSON request bodies for batch and webhook endpoints.
  • V1 error envelopes as typed exceptions (code, message, param, request_id).

Example

import { OxinsiderApiClient } from "./api-client";

const client = new OxinsiderApiClient({
  baseUrl: "https://api.0xinsider.com",
  apiKey: process.env.OXINSIDER_API_KEY,
});

// Wallet address or username — both work.
const trader = await client.getTrader("swisstony", {
  query: { expand: ["strategy", "categories"] },
});

const markets = await client.searchMarkets("NBA", {
  query: { limit: 5, status: "active" },
});

Handling errors

The client throws typed exceptions instead of a generic error object, so you match on error.code directly:
import { OxinsiderApiError } from "./api-client";

try {
  const trader = await client.getTrader("not-a-real-trader");
} catch (err) {
  if (err instanceof OxinsiderApiError) {
    if (err.code === "not_found") {
      // expected: unknown trader
    } else if (err.code === "rate_limited") {
      await new Promise(r => setTimeout(r, err.retryAfterMs ?? 1000));
    } else {
      throw err;
    }
  } else {
    throw err;
  }
}

Keep OpenAPI as the source of truth

The client operation table regenerates from api-reference/openapi.json. Change the spec and the client follows. Don’t hand-edit the client to add operations without updating the spec.