> ## 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.

# CGSimplePrice

> Subscribe to receive real-time price updates for tokens, as seen on CoinGecko.com

This WebSocket channel allows you to subscribe to real-time updates of price changes for tokens.

* It will return the prices of one or more coins by using their unique Coin API IDs
* You may specify preferred exchange rate(s) using `vs_currencies` in the subscription data. Choose from [`/simple/supported_vs_currencies`](/reference/simple-supported-currencies). If not specified, data is returned in USD by default.
* You may obtain the coin ID (API ID) via several ways:
  * Refer to respective coin page and find 'API ID'.
  * Refer to [`/coins/list`](/reference/coins-list) endpoint.
  * Refer to Google Sheets [here](https://docs.google.com/spreadsheets/d/1wTTuxXt8n9q7C4NDXqQpI3wpKu1_5bGVmP9Xz0XGSyU/edit?usp=sharing).

**Update Frequency**: as fast as \~10s, for large cap and actively traded coins.

### Data Payload

|      | Field                         | Type    | Description                                                                                         | Example                |
| ---- | ----------------------------- | ------- | --------------------------------------------------------------------------------------------------- | ---------------------- |
| `c`  | `channel_type`                | string  | Indicates the type of channel subscribed to.                                                        | C1                     |
| `i`  | `coin_id`                     | string  | Identifier of the coin. Check full list of IDs [here](https://api.coingecko.com/api/v3/coins/list). | `ethereum`, `usd-coin` |
| `vs` | `vs_currency`                 | string  | The target currency for price data. Defaults to `usd` if `vs_currencies` is not specified.          | `usd`, `eur`           |
| `p`  | `price`                       | float   | Current token price in the specified `vs_currency`.                                                 | 3639.78228844745       |
| `pp` | `price_24h_change_percentage` | float   | Percentage change in token price over the last 24 hours.                                            | 3.566                  |
| `m`  | `market_cap`                  | float   | Market capitalization in the specified `vs_currency`.                                               | 123                    |
| `v`  | `24h_vol`                     | float   | 24-hour trading volume in the specified `vs_currency`.                                              | 31233333.33            |
| `t`  | `last_updated_at`             | integer | Timestamp of the last data update in UNIX time.                                                     | 1709542750             |

**Tips**: The WebSocket payload will use the value `null` when specific data is unavailable. Ensure your application is capable of handling null values for fields that may not always have data.

***

## 1. Establish Connection to WebSocket

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

  OR

  wss://stream.coingecko.com/v1  
  x-cg-pro-api-key: YOUR_KEY
  ```
</CodeGroup>

## 2. Subscribe to a specific channel - CGSimplePrice

**Input Example:**

<CodeGroup>
  ```json JSON theme={null}
  {"command":"subscribe","identifier":"{\"channel\":\"CGSimplePrice\"}"}
  ```
</CodeGroup>

**Output Example**:

<CodeGroup>
  ```json JSON theme={null}
  {"type":"confirm_subscription","identifier":"{\"channel\":\"CGSimplePrice\"}"}
  ```
</CodeGroup>

## 3. Stream CGSimplePrice

**Input Example:**

<CodeGroup>
  ```json JSON theme={null}
  {"command":"message","identifier":"{\"channel\":\"CGSimplePrice\"}","data":"{\"coin_id\":[\"ethereum\",\"bitcoin\"],\"vs_currencies\":[\"usd\",\"eur\"],\"action\":\"set_tokens\"}"}
  ```
</CodeGroup>

**Output Example**:

<CodeGroup>
  ```json JSON theme={null}
  {
      "code": 2000,
      "message": "Subscription is successful for ethereum"
  }
  ```
</CodeGroup>

**Output Example**:

<CodeGroup>
  ```json JSON theme={null}
  {
      "c": "C1",
      "i": "ethereum",
      "vs": "usd",
      "m": 312938652962.8005,
      "p": 2591.080889351465,
      "pp": 1.3763793110454519,
      "t": 1747808150.269067,
      "v": 20460612214.801384
  }
  ```
</CodeGroup>

The output keys will be in random order.

## Tips:

### Unsubscribe to stop streaming CGSimplePrice data

**Input Example:** Unsubscribe for 1 specific token data:

<CodeGroup>
  ```json JSON theme={null}
  {"command":"message","identifier":"{\"channel\":\"CGSimplePrice\"}","data":"{\"coin_id\":[\"ethereum\"],\"action\":\"unset_tokens\"}"}
  ```
</CodeGroup>

**Output Example**:

<CodeGroup>
  ```json JSON theme={null}
  {
      "code": 2000,
      "message": "Unsubscription is successful for ethereum"
  }
  ```
</CodeGroup>

**Input Example:** Unsubscribe from CGSimplePrice channel and all token data:

<CodeGroup>
  ```json JSON theme={null}
  {"command":"unsubscribe","identifier":"{\"channel\":\"CGSimplePrice\"}"}
  ```
</CodeGroup>

**Output Example**:

<CodeGroup>
  ```json JSON theme={null}
  {
      "code": 2000,
      "message": "Unsubscription is successful for all tokens"
  }
  ```
</CodeGroup>


## AsyncAPI

````yaml websocket/asyncapi.json cgsimpleprice
id: cgsimpleprice
title: Cgsimpleprice
description: ''
servers:
  - id: production
    protocol: wss
    host: stream.coingecko.com
    bindings: []
    variables: []
address: /v1
parameters: []
bindings: []
operations:
  - &ref_1
    id: subscribeToCGSimplePrice
    title: 'CGSimplePrice: Subscribe'
    description: Subscribe to CGSimplePrice channel
    type: receive
    messages:
      - &ref_4
        id: subscribe
        payload:
          - name: Subscribe to CGSimplePrice
            description: Subscribe to the CGSimplePrice channel
            type: object
            properties:
              - name: command
                type: string
                description: Command to subscribe to a channel
                enumValues:
                  - subscribe
                required: true
              - name: identifier
                type: string
                description: JSON string containing channel information
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            command:
              type: string
              enum:
                - subscribe
              default: subscribe
              example: subscribe
              description: Command to subscribe to a channel
              x-parser-schema-id: <anonymous-schema-2>
            identifier:
              type: string
              default: '{"channel":"CGSimplePrice"}'
              example: '{"channel":"CGSimplePrice"}'
              description: JSON string containing channel information
              x-parser-schema-id: <anonymous-schema-3>
          required:
            - command
            - identifier
          x-parser-schema-id: <anonymous-schema-1>
        title: Subscribe to CGSimplePrice
        description: Subscribe to the CGSimplePrice 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: cgsimpleprice
  - &ref_2
    id: streamCGSimplePrice
    title: 'CGSimplePrice: Stream Data'
    description: Request price streaming for coins
    type: receive
    messages:
      - &ref_5
        id: streamRequest
        payload:
          - name: Stream CGSimplePrice Data
            description: Set coins to receive price updates
            type: object
            properties:
              - name: command
                type: string
                description: Command to send a message
                enumValues:
                  - message
                required: true
              - name: identifier
                type: string
                description: JSON string containing channel information
                required: true
              - name: data
                type: string
                description: >-
                  You may edit the coin_id and vs_currencies arrays.
                  vs_currencies is optional and defaults to ["usd"]. Examples:
                  ["bitcoin"] or ["bitcoin","ethereum"]. vs_currencies: ["usd"]
                  or ["usd","eur"]
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            command:
              type: string
              enum:
                - message
              default: message
              example: message
              description: Command to send a message
              x-parser-schema-id: <anonymous-schema-5>
            identifier:
              type: string
              default: '{"channel":"CGSimplePrice"}'
              example: '{"channel":"CGSimplePrice"}'
              description: JSON string containing channel information
              x-parser-schema-id: <anonymous-schema-6>
            data:
              type: string
              default: >-
                {"coin_id":["bitcoin"],"vs_currencies":["usd"],"action":"set_tokens"}
              example: >-
                {"coin_id":["bitcoin"],"vs_currencies":["usd"],"action":"set_tokens"}
              description: >-
                You may edit the coin_id and vs_currencies arrays. vs_currencies
                is optional and defaults to ["usd"]. Examples: ["bitcoin"] or
                ["bitcoin","ethereum"]. vs_currencies: ["usd"] or ["usd","eur"]
              x-parser-schema-id: <anonymous-schema-7>
          required:
            - command
            - identifier
            - data
          x-parser-schema-id: <anonymous-schema-4>
        title: Stream CGSimplePrice Data
        description: Set coins to receive price updates
        example: |-
          {
            "command": "<string>",
            "identifier": "<string>",
            "data": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: streamRequest
    bindings: []
    extensions: *ref_0
  - &ref_3
    id: receiveCGSimplePriceUpdates
    title: 'CGSimplePrice: Receive Updates'
    description: Receive real-time price updates
    type: send
    messages:
      - &ref_6
        id: priceUpdate
        payload:
          - name: CGSimplePrice Update
            description: Real-time price update
            type: object
            properties:
              - name: c
                type: string
                description: Channel identifier
                required: false
              - name: i
                type: string
                description: Coin identifier
                required: false
              - name: vs
                type: string
                description: Target currency for price data, defaults to usd
                required: false
              - name: m
                type: number
                description: Market cap in the specified vs_currency
                required: false
              - name: p
                type: number
                description: Current price in the specified vs_currency
                required: false
              - name: pp
                type: number
                description: Price change percentage (24h)
                required: false
              - name: t
                type: number
                description: Timestamp (UNIX with milliseconds)
                required: false
              - name: v
                type: number
                description: 24-hour trading volume in the specified vs_currency
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            c:
              type: string
              example: C1
              description: Channel identifier
              x-parser-schema-id: <anonymous-schema-9>
            i:
              type: string
              example: ethereum
              description: Coin identifier
              x-parser-schema-id: <anonymous-schema-10>
            vs:
              type: string
              example: usd
              description: Target currency for price data, defaults to usd
              x-parser-schema-id: <anonymous-schema-11>
            m:
              type: number
              example: 312938652962.8005
              description: Market cap in the specified vs_currency
              x-parser-schema-id: <anonymous-schema-12>
            p:
              type: number
              example: 2591.08
              description: Current price in the specified vs_currency
              x-parser-schema-id: <anonymous-schema-13>
            pp:
              type: number
              example: 1.38
              description: Price change percentage (24h)
              x-parser-schema-id: <anonymous-schema-14>
            t:
              type: number
              example: 1747808150.269
              description: Timestamp (UNIX with milliseconds)
              x-parser-schema-id: <anonymous-schema-15>
            v:
              type: number
              example: 20460612214.8
              description: 24-hour trading volume in the specified vs_currency
              x-parser-schema-id: <anonymous-schema-16>
          x-parser-schema-id: <anonymous-schema-8>
        title: CGSimplePrice Update
        description: Real-time price update
        example: |-
          {
            "c": "<string>",
            "i": "<string>",
            "vs": "<string>",
            "m": 123,
            "p": 123,
            "pp": 123,
            "t": 123,
            "v": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: priceUpdate
    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: cgsimpleprice
securitySchemes:
  - id: cgApiKey
    name: x_cg_pro_api_key
    type: httpApiKey
    description: Insert CoinGecko Pro API key to establish WebSocket connection
    in: query
    extensions: []

````