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

# OnchainSimpleTokenPrice

> Real-time onchain token price updates by network and token address

### Notes

* Streams real-time price and market data for tokens by network and token address.
* Returns data from the top pool of the specified token.
* Lookup format: `network_id:token_address` (e.g. `bsc:0x55d398326f99059ff775485246999027b3197955`).
* Find supported network IDs via [Networks List](/reference/networks-list).
* Fields may return `null` when data is unavailable. Ensure your application handles null values.

<Callout icon="clock-rotate-left" color="#2196F3" iconType="regular">
  <strong>Update Frequency:</strong><br />As fast as \~1 second for actively traded tokens.
</Callout>

### Data Payload

| Key  | Field                             | Type    | Description                    | Example                                      |
| ---- | --------------------------------- | ------- | ------------------------------ | -------------------------------------------- |
| `c`  | `channel_type`                    | string  | Channel type subscribed to.    | `G1`                                         |
| `n`  | `network_id`                      | string  | Blockchain network identifier. | `bsc`                                        |
| `ta` | `token_address`                   | string  | Token contract address.        | `0x55d398326f99059ff775485246999027b3197955` |
| `p`  | `usd_price`                       | number  | Current token price in USD.    | 1.0002630480973                              |
| `pp` | `usd_price_24h_change_percentage` | number  | Price change percentage (24h). | 0.05                                         |
| `m`  | `usd_market_cap`                  | number  | Market capitalization in USD.  | 9187408426.01                                |
| `v`  | `usd_24h_vol`                     | number  | 24-hour trading volume in USD. | 1999727791.12                                |
| `t`  | `last_updated_at`                 | integer | UNIX timestamp in seconds.     | 1780840630                                   |

***

### 1. Establish Connection

```bash theme={null}
wss://stream.coingecko.com/v1?x_cg_pro_api_key=YOUR_KEY
```

<Tip>You can also pass the key as a header: `x-cg-pro-api-key: YOUR_KEY`</Tip>

**Output:**

```json theme={null}
{
  "code": 3000,
  "message": "Connection established",
  "uuid": "YOUR_SESSION_ID"
}
```

```json theme={null}
{
  "type": "welcome",
  "sid": "YOUR_SESSION_ID"
}
```

***

### 2. Subscribe to OnchainSimpleTokenPrice

**Input:**

```json wrap theme={null}
{"command":"subscribe","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}"}
```

**Output:**

```json theme={null}
{
  "type": "confirm_subscription",
  "identifier": "{\"channel\":\"OnchainSimpleTokenPrice\"}"
}
```

***

### 3. Stream Token Price Data

**Input:**

```json wrap theme={null}
{"command":"message","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}","data":"{\"network_id:token_addresses\":[\"bsc:0x55d398326f99059ff775485246999027b3197955\"],\"action\":\"set_tokens\"}"}
```

**Output:**

```json theme={null}
{
  "code": 2000,
  "message": "Subscription successful for bsc:0x55d398326f99059ff775485246999027b3197955"
}
```

**Streaming output:**

```json theme={null}
{
  "c": "G1",
  "n": "bsc",
  "ta": "0x55d398326f99059ff775485246999027b3197955",
  "p": 1.0002630480973,
  "pp": 0.04574653488,
  "m": 9187408426.010283,
  "v": 1999727791.12026,
  "t": 1780840630
}
```

<Note>Output keys may appear in any order.</Note>

***

### 4. Unsubscribe

**Unsubscribe from a specific token:**

```json wrap theme={null}
{"command":"message","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}","data":"{\"network_id:token_addresses\":[\"bsc:0x55d398326f99059ff775485246999027b3197955\"],\"action\":\"unset_tokens\"}"}
```

```json theme={null}
{
  "code": 2000,
  "message": "Unsubscription is successful for bsc:0x55d398326f99059ff775485246999027b3197955"
}
```

**Unsubscribe from the channel entirely:**

```json wrap theme={null}
{"command":"unsubscribe","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}"}
```

```json theme={null}
{
  "code": 2000,
  "message": "Unsubscription is successful for all tokens"
}
```

***


## AsyncAPI

````yaml websocket/asyncapi.json onchainsimpletokenprice
id: onchainsimpletokenprice
title: Onchainsimpletokenprice
description: Real-time onchain token price updates by network and token address
servers:
  - id: production
    protocol: wss
    host: stream.coingecko.com
    bindings: []
    variables: []
address: /v1
parameters: []
bindings: []
operations:
  - &ref_1
    id: subscribeToOnchainSimpleTokenPrice
    title: 'OnchainSimpleTokenPrice: Subscribe'
    description: >-
      To subscribe to the OnchainSimpleTokenPrice channel for receiving onchain
      token price updates
    type: receive
    messages:
      - &ref_4
        id: subscribe
        payload:
          - name: Subscribe to OnchainSimpleTokenPrice
            description: Subscribe to the OnchainSimpleTokenPrice channel
            type: object
            properties:
              - name: command
                type: string
                description: Subscription command
                enumValues:
                  - subscribe
                required: true
              - name: identifier
                type: string
                description: JSON string specifying the target channel
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - command
            - identifier
          properties:
            command:
              type: string
              enum:
                - subscribe
              default: subscribe
              description: Subscription command
              x-parser-schema-id: <anonymous-schema-24>
            identifier:
              type: string
              default: '{"channel":"OnchainSimpleTokenPrice"}'
              description: JSON string specifying the target channel
              x-parser-schema-id: <anonymous-schema-25>
          x-parser-schema-id: <anonymous-schema-23>
        title: Subscribe to OnchainSimpleTokenPrice
        description: Subscribe to the OnchainSimpleTokenPrice channel
        example: |-
          {
            "command": "<string>",
            "identifier": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: onchainsimpletokenprice
  - &ref_2
    id: streamOnchainSimpleTokenPrice
    title: 'OnchainSimpleTokenPrice: Stream Data'
    description: To set which tokens to stream price data for, by network and token address
    type: receive
    messages:
      - &ref_5
        id: stream
        payload:
          - name: Stream OnchainSimpleTokenPrice Data
            description: Set tokens to receive price updates for
            type: object
            properties:
              - name: command
                type: string
                description: Message command
                enumValues:
                  - message
                required: true
              - name: identifier
                type: string
                description: JSON string specifying the target channel
                required: true
              - name: data
                type: string
                description: >-
                  JSON string with network_id:token_addresses array, format:
                  network_id:token_address
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - command
            - identifier
            - data
          properties:
            command:
              type: string
              enum:
                - message
              default: message
              description: Message command
              x-parser-schema-id: <anonymous-schema-27>
            identifier:
              type: string
              default: '{"channel":"OnchainSimpleTokenPrice"}'
              description: JSON string specifying the target channel
              x-parser-schema-id: <anonymous-schema-28>
            data:
              type: string
              default: >-
                {"network_id:token_addresses":["bsc:0x55d398326f99059ff775485246999027b3197955"],"action":"set_tokens"}
              example: >-
                {"network_id:token_addresses":["bsc:0x55d398326f99059ff775485246999027b3197955"],"action":"set_tokens"}
              description: >-
                JSON string with network_id:token_addresses array, format:
                network_id:token_address
              x-parser-schema-id: <anonymous-schema-29>
          x-parser-schema-id: <anonymous-schema-26>
        title: Stream OnchainSimpleTokenPrice Data
        description: Set tokens to receive price updates for
        example: |-
          {
            "command": "<string>",
            "identifier": "<string>",
            "data": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: stream
    bindings: []
    extensions: *ref_0
  - &ref_3
    id: receiveOnchainSimpleTokenPriceUpdates
    title: 'OnchainSimpleTokenPrice: Receive Updates'
    description: >-
      To receive real-time onchain token price updates including price, market
      cap, volume, and 24h change
    type: send
    messages:
      - &ref_6
        id: update
        payload:
          - name: OnchainSimpleTokenPrice Update
            description: Real-time onchain token price update from server
            type: object
            properties:
              - name: c
                type: string
                description: Channel type
                required: false
              - name: 'n'
                type: string
                description: Network identifier
                required: false
              - name: ta
                type: string
                description: Token contract address
                required: false
              - name: p
                type: number
                description: Token price in USD
                required: false
              - name: pp
                type: number
                description: 24h price change percentage
                required: false
              - name: m
                type: number
                description: Market cap in USD
                required: false
              - name: v
                type: number
                description: 24h trading volume in USD
                required: false
              - name: t
                type: integer
                description: UNIX timestamp in seconds
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            c:
              type: string
              example: G1
              description: Channel type
              x-parser-schema-id: <anonymous-schema-31>
            'n':
              type: string
              example: bsc
              description: Network identifier
              x-parser-schema-id: <anonymous-schema-32>
            ta:
              type: string
              example: '0x55d398326f99059ff775485246999027b3197955'
              description: Token contract address
              x-parser-schema-id: <anonymous-schema-33>
            p:
              type: number
              example: 1.0002630480973
              description: Token price in USD
              x-parser-schema-id: <anonymous-schema-34>
            pp:
              type: number
              example: 0.04574653488
              description: 24h price change percentage
              x-parser-schema-id: <anonymous-schema-35>
            m:
              type: number
              example: 9187408426.01
              description: Market cap in USD
              x-parser-schema-id: <anonymous-schema-36>
            v:
              type: number
              example: 1999727791.12
              description: 24h trading volume in USD
              x-parser-schema-id: <anonymous-schema-37>
            t:
              type: integer
              example: 1780840630
              description: UNIX timestamp in seconds
              x-parser-schema-id: <anonymous-schema-38>
          x-parser-schema-id: <anonymous-schema-30>
        title: OnchainSimpleTokenPrice Update
        description: Real-time onchain token price update from server
        example: |-
          {
            "c": "G1",
            "n": "bsc",
            "ta": "0x55d398326f99059ff775485246999027b3197955",
            "p": 1.0002630480973,
            "pp": 0.04574653488,
            "m": 9187408426.01,
            "v": 1999727791.12,
            "t": 1780840630
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: update
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
  - *ref_5
receiveMessages:
  - *ref_6
extensions:
  - id: x-parser-unique-object-id
    value: onchainsimpletokenprice
securitySchemes:
  - id: cgApiKey
    name: x_cg_pro_api_key
    type: httpApiKey
    description: CoinGecko API key
    in: query
    extensions: []

````