1

Add the SDK

Check out Codex Typescript SDK on GitHub or just get right into installation:

npm install @codex-data/sdk
2

Add the API key to your environment variables

Usually these live in your .env file. Add this line and replace xxxxxxxx with your API key:

  CODEX_API_KEY=xxxxxxxx
3

Create an SDK file

Make a new lib/codex-sdk.ts file (or whatever folder/name fits your project) and add:

import { Codex } from "@codex-data/sdk";

export const sdk = new Codex({
  apiKey: process.env.CODEX_API_KEY!,
});
4

Make a request

Now you can import the SDK from other files and make requests. For example:

sdk.queries.token({
  input: {
    address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
    networkId: 56,
  },
})
.then(console.log);
5

See more examples

Check out Codex Typescript SDK GitHub for examples of:

  • Next.js integation
  • Codegen
  • Subscriptions
  • Short-lived API keys
  • Writing custom GraphQL queries (in which case you may want to read Using the GraphQL API)
  • And more