AsyncAPI 2.6 description of the Betfair **Exchange Stream API** - Betfair's low-latency, subscription-based push channel for market and order changes. IMPORTANT TRANSPORT NOTE: this is **NOT a WebSocket API**. The Exchange Stream API is a persistent **raw SSL/TCP socket** to `stream-api.betfair.com` on **port 443**, over which messages are exchanged as **CRLF-delimited JSON** - one complete JSON object per line, terminated by `\r\n`, with JSON pretty-printing turned off. Betfair's own documentation states that any attempted WebSocket connection will be refused. `secure-tcp` is used as the AsyncAPI server protocol; the exact socket semantics are documented here and in `info.x-transport-notes`. Flow: open the SSL socket, read the initial `connection` message, send an `authentication` request (appKey + session token), then send `marketSubscription` and/or `orderSubscription` requests. The server then pushes `mcm` (market change) and `ocm` (order change) messages plus periodic `status` and `heartbeat` frames. A `heartbeat` request may be sent to keep the socket alive; a message must be sent within 15 seconds of connecting or the server returns a TIMEOUT status. Every RequestMessage carries a client-supplied integer `id`, echoed back on the corresponding `status` ResponseMessage. The `op` field on every message identifies its type for correct (de)serialization.
View SpecView on GitHubBetting ExchangeSports BettingWageringTradingMarket DataJSON-RPCStreamingAsyncAPIEvents
Channels
authentication
publishsendAuthentication
Authenticate the stream connection.
Client -> server request that authenticates the socket using the Application Key and the session token (ssoid) from identity SSO login. Must be sent before any subscription. The server replies with a `status` message on the response stream.
marketSubscription
publishsendMarketSubscription
Subscribe to market changes.
Client -> server request subscribing to market changes for a set of markets (via a marketFilter) at a chosen priceData/ladder level (via a marketDataFilter). The server then pushes `mcm` messages on the change stream.
orderSubscription
publishsendOrderSubscription
Subscribe to order changes.
Client -> server request subscribing to the customer's order changes. The server then pushes `ocm` messages on the change stream.
heartbeatRequest
publishsendHeartbeat
Send a keep-alive heartbeat request.
Client -> server keep-alive request (op=heartbeat). Used to keep the socket active and detect a broken connection; the server replies with a `status` message.
connectionStream
subscribereceiveConnection
Receive the initial connection frame.
Server -> client initial `connection` message sent on socket open, carrying the connectionId.
statusStream
subscribereceiveStatus
Receive status / acknowledgement frames.
Server -> client `status` messages - the acknowledgement/response to a request `id`, plus connection health (connectionsAvailable) and error details (statusCode, errorCode, errorMessage).
marketChangeStream
subscribereceiveMarketChange
Receive market change messages.
Server -> client `mcm` (Market Change Message) frames pushing price/status deltas for subscribed markets.
orderChangeStream
subscribereceiveOrderChange
Receive order change messages.
Server -> client `ocm` (Order Change Message) frames pushing order/matched deltas for the customer.
Messages
✉
AuthenticationMessage
Authentication request
Authenticates the socket with appKey + session token.
✉
MarketSubscriptionMessage
Market subscription request
✉
OrderSubscriptionMessage
Order subscription request
✉
HeartbeatRequestMessage
Heartbeat request
✉
ConnectionMessage
Connection frame
✉
StatusMessage
Status / acknowledgement frame
✉
MarketChangeMessage
Market Change Message
Push of market price/status deltas.
✉
OrderChangeMessage
Order Change Message
Push of the customer's order/matched deltas.
Servers
secure-tcp
productionstream-api.betfair.com:443
Production Exchange Stream endpoint. Establish an SSL/TLS socket to this host:port and exchange CRLF-delimited JSON messages. This is a raw TCP socket over SSL - not WebSocket and not HTTP.
secure-tcp
integrationstream-api-integration.betfair.com:443
Integration/test Exchange Stream endpoint with the same protocol.
Discovery needs no key. Ratings and market analysis are Pro.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. See our Privacy Policy and
Terms.