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

# Using the SDK

> Install the Codex TypeScript SDK to query real-time token data and subscribe to live updates over WebSockets.

**1. Add the SDK**

Check out [Codex Typescript SDK on GitHub](https://github.com/codex-data/sdk) or just get right into installation:

```bash npm theme={null}
npm install @codex-data/sdk
```

```bash yarn theme={null}
yarn add @codex-data/sdk
```

```bash pnpm theme={null}
pnpm add @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:

```typescript theme={null}
import { Codex } from "@codex-data/sdk";

export const sdk = new Codex(process.env.CODEX_API_KEY!);
```

**4. Make a request**

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

```typescript theme={null}
sdk.queries.token({
  input: {
    address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
    networkId: 56,
  },
})
.then(console.log);
```

**5. See more examples**

Check out [Codex Typescript SDK GitHub](https://github.com/codex-data/sdk) 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](https://docs.codex.io/learn-graphql.md))
* And more


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