Capital.com OHLCMarketData.subscribe
Subscribes to candlestick bar updates for a list of epics, at chosen resolutions and for a chosen bar type. An answer confirms each combination, then an ohlc.event message arrives for each update.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
This is a message of the Capital.com WebSocket API, not an HTTP endpoint. It has no method and no path: it is sent as JSON over an open WebSocket connection.
The message
- Name
- OHLCMarketData.subscribe
- Direction
- Request, sent by the client
- Carried by
- WebSocket. Capital.com's page says to ping the service at least once every 10 minutes to keep the connection alive.
- WebSocket address
- wss://api-streaming-capital.backend-capital.com/connect
- Answered by
Fields
| Name | Type | Description |
|---|---|---|
| destinationrequired or not: not stated | Not stated | Names the message, in the way a path names a REST call. Here it is OHLCMarketData.subscribe. |
| correlationIdrequired or not: not stated | Not stated | An id of your own. The answer carries the same value, which is how an answer is matched to its request. |
| cstrequired or not: not stated | Not stated | The token that identifies the client. It is the CST value returned when a session is started over REST. |
| securityTokenrequired or not: not stated | Not stated | The token that identifies the account in use. It is the X-SECURITY-TOKEN value returned when a session is started over REST. |
| payload.epicsrequired | string[] | The epics to subscribe to. The page limits the list to 40. |
| payload.resolutions | string[] | The bar widths wanted: MINUTE, MINUTE_5, MINUTE_15, MINUTE_30, HOUR, HOUR_4, DAY or WEEK. The page gives MINUTE as the default. |
| payload.type | string | The kind of candlestick: classic or heikin-ashi. The page gives classic as the default. |
What arrives
OHLCMarketData.subscribe: The confirmation of the subscription. Bar updates then arrive as ohlc.event messages.
The vendor's page does not say which of these fields are required or always present.
| Name | Type | Description |
|---|---|---|
| status | Not stated | OK in the vendor's example of a successful answer. |
| destination | Not stated | The destination of the request it answers: OHLCMarketData.subscribe. |
| correlationId | Not stated | The correlationId the request carried. |
| payload.subscriptions | Not stated | An object with one entry for each combination subscribed to, keyed as epic, resolution and type joined by colons, such as OIL_CRUDE:MINUTE_5:classic. In the vendor's example the value is PROCESSED. |
Sample
Written by this site from the fields recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. No credential is typed into it: where a field holds one, the placeholder says where it comes from. Nothing is entered on this site.
{
"destination": "OHLCMarketData.subscribe",
"correlationId": "3",
"cst": "<the CST token of your session, from your own environment>",
"securityToken": "<the X-SECURITY-TOKEN of your session, from your own environment>",
"payload": {
"epics": [
"OIL_CRUDE",
"AAPL"
],
"resolutions": [
"MINUTE_5"
],
"type": "classic"
}
}Limits that apply at Capital.com
| Limit | Value | Scope | Source |
|---|---|---|---|
| Headline limit | 10/s per user | user | open-api.capital.comchecked |