{
  "asyncapi": "3.0.0",
  "info": {
    "title": "CoinGecko WebSocket",
    "version": "1.0.0",
    "description": "Real-time cryptocurrency data streaming via WebSocket"
  },
  "servers": {
    "production": {
      "host": "stream.coingecko.com",
      "protocol": "wss",
      "pathname": "/v1",
      "description": "Production WebSocket server",
      "security": [
        {
          "$ref": "#/components/securitySchemes/cgApiKey"
        }
      ]
    }
  },
  "channels": {
    "cgsimpleprice": {
      "address": "/v1",
      "description": "Real-time coin price updates by CoinGecko coin IDs",
      "messages": {
        "subscribe": {
          "$ref": "#/components/messages/CGSimplePriceSubscribe"
        },
        "stream": {
          "$ref": "#/components/messages/CGSimplePriceStream"
        },
        "update": {
          "$ref": "#/components/messages/CGSimplePriceUpdate"
        }
      }
    },
    "onchainsimpletokenprice": {
      "address": "/v1",
      "description": "Real-time onchain token price updates by network and token address",
      "messages": {
        "subscribe": {
          "$ref": "#/components/messages/OnchainSimpleTokenPriceSubscribe"
        },
        "stream": {
          "$ref": "#/components/messages/OnchainSimpleTokenPriceStream"
        },
        "update": {
          "$ref": "#/components/messages/OnchainSimpleTokenPriceUpdate"
        }
      }
    },
    "onchaintrade": {
      "address": "/v1",
      "description": "Real-time onchain DEX trade updates by pool address",
      "messages": {
        "subscribe": {
          "$ref": "#/components/messages/OnchainTradeSubscribe"
        },
        "stream": {
          "$ref": "#/components/messages/OnchainTradeStream"
        },
        "update": {
          "$ref": "#/components/messages/OnchainTradeUpdate"
        }
      }
    },
    "onchainohlcv": {
      "address": "/v1",
      "description": "Real-time onchain OHLCV candlestick updates by pool address",
      "messages": {
        "subscribe": {
          "$ref": "#/components/messages/OnchainOHLCVSubscribe"
        },
        "stream": {
          "$ref": "#/components/messages/OnchainOHLCVStream"
        },
        "update": {
          "$ref": "#/components/messages/OnchainOHLCVUpdate"
        }
      }
    }
  },
  "operations": {
    "subscribeToCGSimplePrice": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/cgsimpleprice"
      },
      "title": "CGSimplePrice: Subscribe",
      "description": "To subscribe to the CGSimplePrice channel for receiving coin price updates",
      "messages": [
        {
          "$ref": "#/channels/cgsimpleprice/messages/subscribe"
        }
      ]
    },
    "streamCGSimplePrice": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/cgsimpleprice"
      },
      "title": "CGSimplePrice: Stream Data",
      "description": "To set which coins and vs_currencies to stream price data for",
      "messages": [
        {
          "$ref": "#/channels/cgsimpleprice/messages/stream"
        }
      ]
    },
    "receiveCGSimplePriceUpdates": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/cgsimpleprice"
      },
      "title": "CGSimplePrice: Receive Updates",
      "description": "To receive real-time coin price updates including price, market cap, volume, and 24h change",
      "messages": [
        {
          "$ref": "#/channels/cgsimpleprice/messages/update"
        }
      ]
    },
    "subscribeToOnchainSimpleTokenPrice": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/onchainsimpletokenprice"
      },
      "title": "OnchainSimpleTokenPrice: Subscribe",
      "description": "To subscribe to the OnchainSimpleTokenPrice channel for receiving onchain token price updates",
      "messages": [
        {
          "$ref": "#/channels/onchainsimpletokenprice/messages/subscribe"
        }
      ]
    },
    "streamOnchainSimpleTokenPrice": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/onchainsimpletokenprice"
      },
      "title": "OnchainSimpleTokenPrice: Stream Data",
      "description": "To set which tokens to stream price data for, by network and token address",
      "messages": [
        {
          "$ref": "#/channels/onchainsimpletokenprice/messages/stream"
        }
      ]
    },
    "receiveOnchainSimpleTokenPriceUpdates": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/onchainsimpletokenprice"
      },
      "title": "OnchainSimpleTokenPrice: Receive Updates",
      "description": "To receive real-time onchain token price updates including price, market cap, volume, and 24h change",
      "messages": [
        {
          "$ref": "#/channels/onchainsimpletokenprice/messages/update"
        }
      ]
    },
    "subscribeToOnchainTrade": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/onchaintrade"
      },
      "title": "OnchainTrade: Subscribe",
      "description": "To subscribe to the OnchainTrade channel for receiving DEX trade updates",
      "messages": [
        {
          "$ref": "#/channels/onchaintrade/messages/subscribe"
        }
      ]
    },
    "streamOnchainTrade": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/onchaintrade"
      },
      "title": "OnchainTrade: Stream Data",
      "description": "To set which pools to stream trade data for, by network and pool address",
      "messages": [
        {
          "$ref": "#/channels/onchaintrade/messages/stream"
        }
      ]
    },
    "receiveOnchainTradeUpdates": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/onchaintrade"
      },
      "title": "OnchainTrade: Receive Updates",
      "description": "To receive real-time DEX trade updates including buy/sell type, amounts, and prices",
      "messages": [
        {
          "$ref": "#/channels/onchaintrade/messages/update"
        }
      ]
    },
    "subscribeToOnchainOHLCV": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/onchainohlcv"
      },
      "title": "OnchainOHLCV: Subscribe",
      "description": "To subscribe to the OnchainOHLCV channel for receiving OHLCV candlestick updates",
      "messages": [
        {
          "$ref": "#/channels/onchainohlcv/messages/subscribe"
        }
      ]
    },
    "streamOnchainOHLCV": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/onchainohlcv"
      },
      "title": "OnchainOHLCV: Stream Data",
      "description": "To set which pools, intervals, and token sides to stream OHLCV data for",
      "messages": [
        {
          "$ref": "#/channels/onchainohlcv/messages/stream"
        }
      ]
    },
    "receiveOnchainOHLCVUpdates": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/onchainohlcv"
      },
      "title": "OnchainOHLCV: Receive Updates",
      "description": "To receive real-time OHLCV candlestick updates including open, high, low, close, and volume",
      "messages": [
        {
          "$ref": "#/channels/onchainohlcv/messages/update"
        }
      ]
    }
  },
  "components": {
    "securitySchemes": {
      "cgApiKey": {
        "type": "httpApiKey",
        "in": "query",
        "name": "x_cg_pro_api_key",
        "description": "CoinGecko API key"
      }
    },
    "messages": {
      "CGSimplePriceSubscribe": {
        "name": "CGSimplePriceSubscribe",
        "title": "Subscribe to CGSimplePrice",
        "summary": "Subscribe to the CGSimplePrice channel",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "subscribe"
              ],
              "default": "subscribe",
              "description": "Subscription command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"CGSimplePrice\"}",
              "description": "JSON string specifying the target channel"
            }
          }
        }
      },
      "CGSimplePriceStream": {
        "name": "CGSimplePriceStream",
        "title": "Stream CGSimplePrice Data",
        "summary": "Set coins to receive price updates for",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier",
            "data"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "message"
              ],
              "default": "message",
              "description": "Message command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"CGSimplePrice\"}",
              "description": "JSON string specifying the target channel"
            },
            "data": {
              "type": "string",
              "default": "{\"coin_id\":[\"bitcoin\"],\"vs_currencies\":[\"usd\"],\"action\":\"set_tokens\"}",
              "example": "{\"coin_id\":[\"bitcoin\"],\"vs_currencies\":[\"usd\"],\"action\":\"set_tokens\"}",
              "description": "JSON string with coin_id array (required) and vs_currencies array (optional, defaults to [\"usd\"])"
            }
          }
        }
      },
      "CGSimplePriceUpdate": {
        "name": "CGSimplePriceUpdate",
        "title": "CGSimplePrice Update",
        "summary": "Real-time coin price update from server",
        "payload": {
          "type": "object",
          "properties": {
            "c": {
              "type": "string",
              "example": "C1",
              "description": "Channel type"
            },
            "i": {
              "type": "string",
              "example": "bitcoin",
              "description": "Coin identifier"
            },
            "vs": {
              "type": "string",
              "example": "usd",
              "description": "Target vs_currency"
            },
            "p": {
              "type": "number",
              "example": 61696.68,
              "description": "Price in vs_currency"
            },
            "pp": {
              "type": "number",
              "example": 1.42,
              "description": "24h price change percentage"
            },
            "m": {
              "type": "number",
              "example": 1236047139289.68,
              "description": "Market cap in vs_currency"
            },
            "v": {
              "type": "number",
              "example": 30595921115.54,
              "description": "24h trading volume in vs_currency"
            },
            "t": {
              "type": "integer",
              "example": 1780839768,
              "description": "UNIX timestamp in seconds"
            }
          }
        },
        "examples": [
          {
            "payload": {
              "c": "C1",
              "i": "bitcoin",
              "vs": "usd",
              "p": 61696.68,
              "pp": 1.42,
              "m": 1236047139289.68,
              "v": 30595921115.54,
              "t": 1780839768
            }
          }
        ]
      },
      "OnchainSimpleTokenPriceSubscribe": {
        "name": "OnchainSimpleTokenPriceSubscribe",
        "title": "Subscribe to OnchainSimpleTokenPrice",
        "summary": "Subscribe to the OnchainSimpleTokenPrice channel",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "subscribe"
              ],
              "default": "subscribe",
              "description": "Subscription command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"OnchainSimpleTokenPrice\"}",
              "description": "JSON string specifying the target channel"
            }
          }
        }
      },
      "OnchainSimpleTokenPriceStream": {
        "name": "OnchainSimpleTokenPriceStream",
        "title": "Stream OnchainSimpleTokenPrice Data",
        "summary": "Set tokens to receive price updates for",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier",
            "data"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "message"
              ],
              "default": "message",
              "description": "Message command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"OnchainSimpleTokenPrice\"}",
              "description": "JSON string specifying the target channel"
            },
            "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"
            }
          }
        }
      },
      "OnchainSimpleTokenPriceUpdate": {
        "name": "OnchainSimpleTokenPriceUpdate",
        "title": "OnchainSimpleTokenPrice Update",
        "summary": "Real-time onchain token price update from server",
        "payload": {
          "type": "object",
          "properties": {
            "c": {
              "type": "string",
              "example": "G1",
              "description": "Channel type"
            },
            "n": {
              "type": "string",
              "example": "bsc",
              "description": "Network identifier"
            },
            "ta": {
              "type": "string",
              "example": "0x55d398326f99059ff775485246999027b3197955",
              "description": "Token contract address"
            },
            "p": {
              "type": "number",
              "example": 1.0002630480973,
              "description": "Token price in USD"
            },
            "pp": {
              "type": "number",
              "example": 0.04574653488,
              "description": "24h price change percentage"
            },
            "m": {
              "type": "number",
              "example": 9187408426.01,
              "description": "Market cap in USD"
            },
            "v": {
              "type": "number",
              "example": 1999727791.12,
              "description": "24h trading volume in USD"
            },
            "t": {
              "type": "integer",
              "example": 1780840630,
              "description": "UNIX timestamp in seconds"
            }
          }
        },
        "examples": [
          {
            "payload": {
              "c": "G1",
              "n": "bsc",
              "ta": "0x55d398326f99059ff775485246999027b3197955",
              "p": 1.0002630480973,
              "pp": 0.04574653488,
              "m": 9187408426.01,
              "v": 1999727791.12,
              "t": 1780840630
            }
          }
        ]
      },
      "OnchainTradeSubscribe": {
        "name": "OnchainTradeSubscribe",
        "title": "Subscribe to OnchainTrade",
        "summary": "Subscribe to the OnchainTrade channel",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "subscribe"
              ],
              "default": "subscribe",
              "description": "Subscription command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"OnchainTrade\"}",
              "description": "JSON string specifying the target channel"
            }
          }
        }
      },
      "OnchainTradeStream": {
        "name": "OnchainTradeStream",
        "title": "Stream OnchainTrade Data",
        "summary": "Set pools to receive trade updates for",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier",
            "data"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "message"
              ],
              "default": "message",
              "description": "Message command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"OnchainTrade\"}",
              "description": "JSON string specifying the target channel"
            },
            "data": {
              "type": "string",
              "default": "{\"network_id:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"action\":\"set_pools\"}",
              "example": "{\"network_id:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"action\":\"set_pools\"}",
              "description": "JSON string with network_id:pool_addresses array, format: network_id:pool_address"
            }
          }
        }
      },
      "OnchainTradeUpdate": {
        "name": "OnchainTradeUpdate",
        "title": "OnchainTrade Update",
        "summary": "Real-time DEX trade update from server",
        "payload": {
          "type": "object",
          "properties": {
            "c": {
              "type": "string",
              "example": "G2",
              "description": "Channel type"
            },
            "n": {
              "type": "string",
              "example": "bsc",
              "description": "Network identifier"
            },
            "pa": {
              "type": "string",
              "example": "0x172fcd41e0913e95784454622d1c3724f546f849",
              "description": "Pool contract address"
            },
            "tx": {
              "type": "string",
              "example": "0x3aa702e87ebc87cc4f877ab494afa0ac59f46873c147ee406a546c1e12ab5f57",
              "description": "Transaction hash"
            },
            "ty": {
              "type": "string",
              "example": "s",
              "description": "Trade type (b=buy, s=sell)"
            },
            "to": {
              "type": "number",
              "example": 0.0369078635593666,
              "description": "Base token amount"
            },
            "toq": {
              "type": "number",
              "example": 0.000062600168318069,
              "description": "Quote token amount"
            },
            "vo": {
              "type": "number",
              "example": 0.036858979105679,
              "description": "Trade volume in USD"
            },
            "pc": {
              "type": "number",
              "example": 0.0016961200752619,
              "description": "Price in quote token"
            },
            "pu": {
              "type": "number",
              "example": 0.998675500314209,
              "description": "Price in USD"
            },
            "t": {
              "type": "integer",
              "example": 1780840929000,
              "description": "UNIX timestamp in milliseconds"
            }
          }
        },
        "examples": [
          {
            "payload": {
              "c": "G2",
              "n": "bsc",
              "pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
              "tx": "0x3aa702e87ebc87cc4f877ab494afa0ac59f46873c147ee406a546c1e12ab5f57",
              "ty": "s",
              "to": 0.0369078635593666,
              "toq": 0.000062600168318069,
              "vo": 0.036858979105679,
              "pc": 0.0016961200752619,
              "pu": 0.998675500314209,
              "t": 1780840929000
            }
          }
        ]
      },
      "OnchainOHLCVSubscribe": {
        "name": "OnchainOHLCVSubscribe",
        "title": "Subscribe to OnchainOHLCV",
        "summary": "Subscribe to the OnchainOHLCV channel",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "subscribe"
              ],
              "default": "subscribe",
              "description": "Subscription command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"OnchainOHLCV\"}",
              "description": "JSON string specifying the target channel"
            }
          }
        }
      },
      "OnchainOHLCVStream": {
        "name": "OnchainOHLCVStream",
        "title": "Stream OnchainOHLCV Data",
        "summary": "Set pools to receive OHLCV updates for",
        "payload": {
          "type": "object",
          "required": [
            "command",
            "identifier",
            "data"
          ],
          "properties": {
            "command": {
              "type": "string",
              "enum": [
                "message"
              ],
              "default": "message",
              "description": "Message command"
            },
            "identifier": {
              "type": "string",
              "default": "{\"channel\":\"OnchainOHLCV\"}",
              "description": "JSON string specifying the target channel"
            },
            "data": {
              "type": "string",
              "default": "{\"network_id:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"interval\":\"1m\",\"token\":\"base\",\"action\":\"set_pools\"}",
              "example": "{\"network_id:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"interval\":\"1m\",\"token\":\"base\",\"action\":\"set_pools\"}",
              "description": "JSON string with network_id:pool_addresses array, interval (1s/1m/5m/15m/1h/2h/4h/8h/12h/1d), and token (base or quote)"
            }
          }
        }
      },
      "OnchainOHLCVUpdate": {
        "name": "OnchainOHLCVUpdate",
        "title": "OnchainOHLCV Update",
        "summary": "Real-time OHLCV candlestick update from server",
        "payload": {
          "type": "object",
          "properties": {
            "ch": {
              "type": "string",
              "example": "G3",
              "description": "Channel type"
            },
            "n": {
              "type": "string",
              "example": "bsc",
              "description": "Network identifier"
            },
            "pa": {
              "type": "string",
              "example": "0x172fcd41e0913e95784454622d1c3724f546f849",
              "description": "Pool contract address"
            },
            "to": {
              "type": "string",
              "example": "base",
              "description": "Token side (base or quote)"
            },
            "i": {
              "type": "string",
              "example": "1m",
              "description": "Candle interval (1s/1m/5m/15m/1h/2h/4h/8h/12h/1d)"
            },
            "o": {
              "type": "number",
              "example": 1.00052534269941,
              "description": "Open price in USD"
            },
            "h": {
              "type": "number",
              "example": 1.00063525778742,
              "description": "High price in USD"
            },
            "l": {
              "type": "number",
              "example": 0.999952061655863,
              "description": "Low price in USD"
            },
            "c": {
              "type": "number",
              "example": 0.999952061655863,
              "description": "Close price in USD"
            },
            "v": {
              "type": "number",
              "example": 59672.13452671968,
              "description": "Volume in USD"
            },
            "t": {
              "type": "integer",
              "example": 1780841100,
              "description": "Candle open time, UNIX timestamp in seconds"
            }
          }
        },
        "examples": [
          {
            "payload": {
              "ch": "G3",
              "n": "bsc",
              "pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
              "to": "base",
              "i": "1m",
              "o": 1.00052534269941,
              "h": 1.00063525778742,
              "l": 0.999952061655863,
              "c": 0.999952061655863,
              "v": 59672.13452671968,
              "t": 1780841100
            }
          }
        ]
      }
    }
  }
}