# Get Token Chart — Codex

> Returns OHLCV (open, high, low, close, volume) candlestick bars for a token over a time range. Use this for price charts, trend analysis, or historical data. Use Get Networks to resolve networkId if needed. from and to are Unix timestamps…

- Key: `codex-get-token-chart`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Codex (`codex`) — https://pipedream.com/apps/codex.md
- This page (HTML): https://pipedream.com/apps/codex/actions/get-token-chart
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/codex/actions/get-token-chart/get-token-chart.mjs

## Description

Returns OHLCV (open, high, low, close, volume) candlestick bars for a token over a time range. Use this for price charts, trend analysis, or historical data. Use **Get Networks** to resolve `networkId` if needed. `from` and `to` are Unix timestamps in seconds (e.g., current time = `Math.floor(Date.now() / 1000)`). Valid resolutions: `1` (1 min), `5`, `15`, `30`, `60` (1 hr), `240` (4 hr), `720` (12 hr), `1D`, `7D`. [See the documentation](https://docs.codex.io/api-reference/queries/gettokenbars)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `address` | `string` | Yes | On-chain contract address of the token (e.g., 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 for WETH). |
| `networkId` | `integer` | Yes | Numeric blockchain network ID. Use Get Networks to list all supported networks and their IDs (e.g., 1 = Ethereum, 137 = Polygon). |
| `resolution` | `string` | Yes | Candle interval. Use 60 for hourly, 1D for daily, 7D for weekly. |
| `from` | `integer` | Yes | Start of the time range as a Unix timestamp in seconds. |
| `to` | `integer` | No | End of the time range as a Unix timestamp in seconds. Defaults to now if not provided. |
| `statsType` | `string` | No | The type of statistics returned. Can be FILTERED or UNFILTERED. Default is UNFILTERED. |
| `countback` | `integer` | No | Guarantees number of bars returned is at most this number. Use countback: 1500 with from: 0 for maximum results. |
| `currencyCode` | `string` | No | The currency to use for the response. Can be USD or TOKEN. Default is USD. Use currencyCode: TOKEN for native token pricing. |
| `removeLeadingNullValues` | `boolean` | No | Whether to remove leading null values from the response. Default is false. To fetch a token’s entire history, set resolution to 1D, from value to 0 and removeLeadingNullValues to true. |
| `removeEmptyBars` | `boolean` | No | Whether to remove empty bars from the response. This is useful for eliminating gaps in low-activity tokens. Default is false. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "codex",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "codex-get-token-chart",
  arguments: {
    address: "Token Address",
    networkId: 10,
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "codex-get-token-chart",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    codex: { authProvisionId: "apn_xxxxxxx" },
    address: "Token Address",
    networkId: 10,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "codex-get-token-chart",
    "configured_props": {
      "codex": { "authProvisionId": "apn_xxxxxxx" },
      "address": "Token Address",
      "networkId": 10
    }
  }'
```

---

- App: https://pipedream.com/apps/codex.md · All apps: https://pipedream.com/apps
