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

# Market trades

> Real-time trades for the subscribed products. Updates are collected over
the last 250 ms and sent together, so an update may contain one or many
trades.




## AsyncAPI

````yaml api-reference/advanced-trade-api/advanced-trade-asyncapi.json market_trades
id: market_trades
title: Market trades
description: |
  Real-time trades for the subscribed products. Updates are collected over
  the last 250 ms and sent together, so an update may contain one or many
  trades.
servers:
  - id: production
    protocol: wss
    host: advanced-trade-ws.coinbase.com
    bindings: []
    variables: []
address: market_trades
parameters: []
bindings: []
operations:
  - &ref_2
    id: marketTradesSubscribe
    title: Subscribe to market trades
    description: >-
      Client sends a subscribe or unsubscribe request for the market_trades
      channel.
    type: receive
    messages:
      - &ref_4
        id: subscribe_request
        contentType: application/json
        payload:
          - name: Subscription request
            description: Subscribe or unsubscribe to the market_trades channel.
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - subscribe
                  - unsubscribe
                required: true
              - name: channel
                type: string
                required: true
              - name: product_ids
                type: array
                description: Products to subscribe to, e.g. ["BTC-USD"].
                required: true
                properties:
                  - name: item
                    type: string
                    required: false
              - name: jwt
                type: string
                description: >-
                  CDP JWT. Optional here; recommended for connection
                  reliability.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - channel
            - product_ids
          properties:
            type:
              type: string
              enum:
                - subscribe
                - unsubscribe
              default: subscribe
              x-parser-schema-id: <anonymous-schema-119>
            channel:
              type: string
              default: market_trades
              x-parser-schema-id: <anonymous-schema-120>
            product_ids:
              type: array
              items:
                type: string
                x-parser-schema-id: <anonymous-schema-122>
              description: Products to subscribe to, e.g. ["BTC-USD"].
              x-parser-schema-id: <anonymous-schema-121>
            jwt:
              type: string
              description: CDP JWT. Optional here; recommended for connection reliability.
              x-parser-schema-id: <anonymous-schema-123>
          x-parser-schema-id: <anonymous-schema-118>
        title: Subscription request
        description: Subscribe or unsubscribe to the market_trades channel.
        example: |-
          {
            "type": "subscribe",
            "channel": "market_trades",
            "product_ids": [
              "BTC-USD"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe_request
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: market_trades
  - &ref_3
    id: marketTradesStream
    title: Market trades stream
    description: Server streams market trades to subscribed clients.
    type: send
    messages:
      - &ref_5
        id: market_trades
        contentType: application/json
        payload:
          - allOf: &ref_0
              - type: object
                properties:
                  channel:
                    type: string
                    description: The channel that produced this message.
                    x-parser-schema-id: <anonymous-schema-5>
                  timestamp:
                    type: string
                    format: date-time
                    description: Server time the message was sent (RFC 3339).
                    x-parser-schema-id: <anonymous-schema-6>
                  sequence_num:
                    type: integer
                    description: >-
                      Per-connection message sequence number; use it to detect
                      dropped or out-of-order messages.
                    x-parser-schema-id: <anonymous-schema-7>
                x-parser-schema-id: EnvelopeBase
              - type: object
                properties:
                  channel:
                    const: market_trades
                    x-parser-schema-id: <anonymous-schema-125>
                  events:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - snapshot
                            - update
                          x-parser-schema-id: <anonymous-schema-128>
                        trades:
                          type: array
                          items:
                            type: object
                            properties:
                              trade_id:
                                type: string
                                description: Unique identifier of the trade.
                                x-parser-schema-id: <anonymous-schema-130>
                              product_id:
                                type: string
                                description: Product the trade occurred on.
                                x-parser-schema-id: <anonymous-schema-131>
                              price:
                                type: string
                                description: Price the trade executed at.
                                x-parser-schema-id: <anonymous-schema-132>
                              size:
                                type: string
                                description: Base size of the trade.
                                x-parser-schema-id: <anonymous-schema-133>
                              side:
                                type: string
                                enum:
                                  - BUY
                                  - SELL
                                description: The maker's side of the trade.
                                x-parser-schema-id: <anonymous-schema-134>
                              time:
                                type: string
                                format: date-time
                                description: Time the trade occurred (RFC 3339).
                                x-parser-schema-id: <anonymous-schema-135>
                            x-parser-schema-id: MarketTrade
                          x-parser-schema-id: <anonymous-schema-129>
                      x-parser-schema-id: <anonymous-schema-127>
                    x-parser-schema-id: <anonymous-schema-126>
                x-parser-schema-id: <anonymous-schema-124>
            x-parser-schema-id: MarketTradesEnvelope
            name: Market trades message
        headers: []
        jsonPayloadSchema:
          allOf: *ref_0
          x-parser-schema-id: MarketTradesEnvelope
        title: Market trades message
        example: '{}'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: market_trades
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
receiveMessages:
  - *ref_5
extensions:
  - id: x-parser-unique-object-id
    value: market_trades
securitySchemes: []

````