The Capital.com API allows direct access to the latest version of our trading engine.
POST /session
endpoint.To use the API the following simple steps should be taken:
POST /accounts/topUp
endpointPOST /session
endpoint.GET /markets
endpointfrom
, to
, lastPeriod
to 1 day for the GET /history/activity
POST /positions
and POST /workingorders
in Demo.There are 2 ways to start the session:
Here you should simply use the POST /session
endpoint and mention the received in the platform’s Settings API key in the X-CAP-API-KEY
header, login and API key password info in the identifier
and password
parameters. The value of the encryptedPassword
parameter should be false
.
GET /session/encryptionKey
and mention the generated in the platform’s Settings API key in the X-CAP-API-KEY
header. As a response you will receive the encryptionKey
and timeStamp
parameters;encryptionKey
and timeStamp
parameters you should encrypt your API key password using the AES encryption method.Encryption request example:
public static String encryptPassword(String encryptionKey, Long timestamp, String password) {
try {
byte[] input = stringToBytes(password + "|" + timestamp);
input = Base64.encodeBase64(input);
KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM);
PublicKey publicKey = keyFactory.generatePublic(new X509EncodedKeySpec(Base64.decodeBase64(stringToBytes(encryptionKey))));
Cipher cipher = Cipher.getInstance(PKCS1_PADDING_TRANSFORMATION);
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] output = cipher.doFinal(input);
output = Base64.encodeBase64(output);
return bytesToString(output);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Encrypted password example:
encryptionKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1dOujgcFh/9n4JLJMY4VMWZ7aRrynwKXUC9RuoC8Qu5UOeskxgZ1q5DmAXjkes77KrLfFZYEKtrp2g1TB0MBkSALiyrG+Fl52vhET9/AWRhvHuFyskWI7tEtcGIaOB1FwR0EDO9bnylTaZ+Y9sPbLVA7loAtfaX3HW/TI9JDpdmgzXZ0KrwIxdMRzPxVqQXcA8yJL1m33pvo9mOJ0AsQ8FFuy+ctjI8l/8xUhe2Hk01rpMBXDwI1lSjnvuUUDvAtacxyYVlNsnRvbrMZYp7hyimm27RtvCUXhTX2A94tDB0MFLApURrki+tvTvw5ImDPN8qOdTUzbs8hNtVwTpSxPwIDAQAB";
timestamp = 1647440528194;
password = "1111qqqq";
// Result of password encryption with the encryptionKey
encryptedPassword = "hUxWlqKRhH6thdjJnR7DvdlGE7ABkcKHrzKDGeE7kQ7nKg91sw7BpYsLDqtxihnlHN2IEmFPZ/ZmOKBAwEAw9/vjELmAZDeKsu3Q6s+Koj4wt8giE1Sxv76JjjOB/667dEeL22IFO1rwTMZ1NS5DrfeYbTfOdQgA0v5eIOS3fH8Pp/mFHodibY28X+zIaNwk6Rcb49l6aiXwM1CAtDl359qK633a+sEB9TR0/C3EaRkuGg8wAQyQ0JERaSYOZ58Dx7pw//cmvk/U5dkQlgli2l6Ts2cMhqYXCD1ZlTDA/rLfl52lgnarfari3n0uh6LicmNeWXJBF5oxj3LCruVwMA==";
POST /session
endpoint, set true
value for the encryptedPassword
parameter and mention the received in the platform’s Settings API key in the X-CAP-API-KEY
header, login and prior encrypted API key password info in the identifier
and password
parametersOn starting the session you will receive the CST
and X-SECURITY-TOKEN
parameters in the response headers. CST
is an authorization token, X-SECURITY-TOKEN
shows which financial account is used for the trades. These headers should be passed on subsequent requests to the API. Both tokens are valid for 10 minutes after the last use.
GET /accounts
endpoint. To find out which financial account is used for trading operations in the API please go to the GET /session
endpoint. To change the financial account use: PUT /session
.GET /markets{?searchTerm}
endpoint to find the market pairs you are interested in. A simple market name like ‘Bitcoin’ or ‘BTC’ can be requested with the searchTerm
parameter and you will receive the full list of the market pairs associated with it. The GET /marketnavigation
endpoint can be used to obtain asset group names. These names can be used with the GET /marketnavigation/{nodeId}
endpoint to view the list of assets under the corresponding group.GET /watchlists
endpoint returns the existing watchlists on your account. Each watchlist has an id parameter which can be used to obtain the corresponding list of assets: GET /watchlists/{watchlistId}
POST /positions
endpoint a dealReference
parameter is included in the response. However, a successful response does not always mean that the position has been successfully opened. The status of the position can be confirmed using GET /confirms/{dealReference}
. This will produce the status of the position together with the affectedDeals
array. Note that several positions can be opened at a time: this info will be shown in the affectedDeals
array.GET /accounts/preferences
method. The hedgingMode
parameter value shows whether the hedging mode is engaged. This value can be altered using endpoint: PUT /accounts/preferences
.GET /accounts/preferences
endpoint. To change leverages, use PUT /accounts/preferences
.On Capital.com we suggest both REST and WebSocket API. In case of WebSocket API real-time prices updates for max 40 instruments at a time.
Yes, we do have several limitations in our Capital.com API. Here is the list:
POST /session
endpoint limit is 1 request per second per API key.POST /positions
and POST /workingorders
endpoint limit is 1000 requests per hour in the Demo account.POST /accounts/topUp
endpoint limits: 10 requests per second and 100 requests per account per day.PUT /session
endpoint.Yes, Capital.com API supports all of the instruments which you can find on the platform.
In order to start using our Capital.com API you should first of all generate an API key in the Settings
> API integrations
section on the platform. Upon doing so you will be able to use this key and your account credentials to authorise for the API usage with the POST /session
method.
Sure. In order to use your Demo account with our API you should mention the following service as Base URL: https://demo-api-capital.backend-capital.com/
In order to generate an API Key you should log in to your account, go to the Settings
> API integrations
section and click on the Generate API key
button.
In case your 2FA is turned off you will be asked to switch on this function to ensure safe and secure keys usage.
Next you will be presented with the Generate new key
window where you will be able to name your API Key, add an API key password and set an expiration date (if needed). By default the validity of the API key is 1 year.
After that you should enter your 2FA code and wait for an API Key to be generated. Once an API Key is generated you will see an API Key itself. Please, make sure to save this data as it is shown only once.
Congratulations. You should have successfully managed to integrate our API functionality. In case you have any questions - feel free to contact us (support@capital.com). We will be glad to help you.
Currently we have only 1 type of the API Keys privileges which allows trading. No Read Only API Keys can be generated.
A Custom password
field allows you to generate a separate password for your API key. You should use this Custom password
for the API key in order to start the session.
In order to pause or launch an API key you can click on the Pause
or Play
icons next to the API key in the Settings
> API integrations
section. This functionality allows you to either disable or enable a key when you need to do it without deleting a key itself and re-generating a new one.
In order to view more information about the API key you have generated please click on an Eye
icon next to the key in the Settings
> API integrations
section.
There are 2 reasons for your API Key to be deleted:
SUSPENDED
or BLOCKED
;In all other cases your API Keys should work as expected.
According to the existing procedure the only moment you can see your API Key is during its creation. After that it will always be masked.
In case you have lost your API Key or didn't record it, you will have to create a new one and make sure that you store a new key in a secure place.
In order to start using WebSocket connect to wss://api-streaming-capital.backend-capital.com/connect
.
In order to keep the connection alive, ping service at least once every 10 minutes.
More information regarding the WebSocket API requests and responses parameters can be found in the table below:
Parameter | Description |
---|---|
destination | The subscription destination which performs as an analogue for the request endpoint in the REST API model. |
correlationId | Is set to understand for which request the message was received. Helps to track the correlation between the subscription destination and response. |
cst | Access token identifying the client. Can be received upon starting the session. Is equal to CST parameter. |
securityToken | Account token or account id identifying the client's current account. Can be received upon starting the session. Is equal to X-SECURITY-TOKEN parameter. |
payload | An object which contains the data regarding the corresponding markets. |
Destination: marketData.subscribe
Subscribe to the price updates by mentioning the epics
The maximum number of epics: 40
Request message example:
{
"destination": "marketData.subscribe",
"correlationId": "1",
"cst": "zvkT26****nsHKk",
"securityToken": "g6K90****QKvCS7",
"payload": {
"epics": [
"OIL_CRUDE"
]
}
}
Example of the response message about successful subscription:
{
"status": "OK",
"destination": "marketData.subscribe",
"correlationId": "1",
"payload": {
"subscriptions": {
"OIL_CRUDE": "PROCESSED"
}
}
}
Example of the response message with market data updates:
{
"status": "OK",
"destination": "quote",
"payload": {
"epic": "OIL_CRUDE",
"product": "CFD",
"bid": 93.87,
"bidQty": 4976.0,
"ofr": 93.9,
"ofrQty": 5000.0,
"timestamp": 1660297190627
}
}
Destination: marketData.unsubscribe
Unsubscribe from the prices updates
Request message example:
{
"destination": "marketData.unsubscribe",
"correlationId": "2",
"cst": "zvkT26****nsHKk",
"securityToken": "g6K90****QKvCS7",
"payload": {
"epics": [
"OIL_CRUDE"
]
}
}
Example of the response message about successful unsubscription:
{
"status": "OK",
"destination": "marketData.unsubscribe",
"correlationId": "2",
"payload": {
"subscriptions": {
"OIL_CRUDE": "PROCESSED"
}
}
}
Destination: OHLCMarketData.subscribe
Subscribe to the candlestick bars updates by mentioning the epics, resolutions and bar type
List of request payload parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
epics | string[] | YES | The list of instruments epics Notes: - Max number of epics is limited to 40 |
resolutions | string[] | NO | The list of resolutions of requested prices Notes: - Default value: MINUTE - Possible values: MINUTE , MINUTE_5 , MINUTE_15 , MINUTE_30 , HOUR , HOUR_4 , DAY , WEEK |
type | string | NO | Type of candlesticks Notes: - Default value: classic - Possible values: classic , heikin-ashi |
Request message example:
{
"destination": "OHLCMarketData.subscribe",
"correlationId": "3",
"cst": "zvkT26****nsHKk",
"securityToken": "g6K90****QKvCS7",
"payload": {
"epics": [
"OIL_CRUDE",
"AAPL"
],
"resolutions": [
"MINUTE_5"
],
"type": "classic"
}
}
Example of the response message about successful subscription:
{
"status": "OK",
"destination": "OHLCMarketData.subscribe",
"correlationId": "3",
"payload": {
"subscriptions": {
"OIL_CRUDE:MINUTE_5:classic": "PROCESSED",
"AAPL:MINUTE_5:classic": "PROCESSED"
}
}
}
Example of the response message with market data updates:
{
"status": "OK",
"destination": "ohlc.event",
"payload": {
"resolution": "MINUTE_5",
"epic": "AAPL",
"type": "classic",
"priceType": "bid",
"t": 1671714000000,
"h": 134.95,
"l": 134.85,
"o": 134.86,
"c": 134.88
}
}
Destination: OHLCMarketData.unsubscribe
Unsubscribe from candlestick bars updates for specific epics, resolutions and bar types.
The general principle is as follows: you unsubscribe from the parameter you mention in the request. In case you mention epic you unsubscribe from all of the corresponding bar types and resolutions.
List of request payload parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
epics | string[] | YES | The list of instruments epics to be unsubscribed |
resolutions | string[] | NO | The list of price resolutions to be unsubscribed Notes: - Default value: All possible values - Possible values: MINUTE , MINUTE_5 , MINUTE_15 , MINUTE_30 , HOUR , HOUR_4 , DAY , WEEK |
types | string[] | NO | Types of candlesticks to be unsubscribed Notes: - Default value: all possible values - Possible values: classic , heikin-ashi |
Request message example:
// Unsubscribe from candlestick bars updates of OIL_CRUDE epic with MINUTE and MINUTE_5 resolutions and heikin-ashi candlestick type
{
"destination": "OHLCMarketData.unsubscribe",
"correlationId": "4",
"cst": "zvkT26****nsHKk",
"securityToken": "g6K90****QKvCS7",
"payload": {
"epics": [
"OIL_CRUDE"
],
"resolutions": [
"MINUTE",
"MINUTE_5"
],
"types": [
"heikin-ashi"
]
}
}
Example of the response message about successful unsubscription:
{
"status": "OK",
"destination": "OHLCMarketData.unsubscribe",
"correlationId": "4",
"payload": {
"subscriptions": {
"OIL_CRUDE:MINUTE_5:heikin-ashi": "PROCESSED",
"OIL_CRUDE:MINUTE:heikin-ashi": "PROCESSED"
}
}
}
Destination: ping
Ping the service for keeping the connection alive
Request message example:
{
"destination": "ping",
"correlationId": "5",
"cst": "zvkT26****nsHKk",
"securityToken": "g6K90****QKvCS7"
}
Response message example:
{
"status": "OK",
"destination": "ping",
"correlationId": "5",
"payload": {}
}
Test connectivity to the API and get the current server time
Authentication is not required for this endpoint
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/time", Method.Get); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "serverTime": 1649259764171
}
Ping the service to keep a trading session alive
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token or account id identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/ping", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "status": "OK"
}
Get the encryption key to use in order to send the API key password in an encrypted form
X-CAP-API-KEY | string Example: ENTER_GENERATED_API_KEY The API key obtained from Settings > API Integrations page on the Capital.com trading platform |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/session/encryptionKey", Method.Get); request.AddHeader("X-CAP-API-KEY", "ENTER_GENERATED_API_KEY"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "encryptionKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxOZgr4OMjNBMKpR+fZpxrDGGwDk3eGnrI+AvRq1X+psNZEjcQ/tR7XkXfy/BzhXKsrdJO4dqwFrULg03olkhapNpo0wr3Jhr3QLPOeX7bAvgL1pkg/1/ySX4ZPZ8tYuGFXRX0v/DeMYJFFiW1NjHS2phTlmVAHy6a5VRx/GmkvBxo/Xh6L0uaIZIbxNRoU1T+4oR7eaIVKtDL5uxX518EgvpU5QNFMg03Z+e5BTczCPR7xmnpKFMsu40zdICtdylxHXBupuh9zeQ5Rbx1xc72x3emUxL4PRCTh/t0gb9mCID4/AIQqSRykY9NpfkXGJV5mBN/3ZHJanHiE2mnVTlbwIBOOBA",
- "timeStamp": 1649058606014
}
Returns the user's session details
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token or account id identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/session", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "clientId": "12345678",
- "accountId": "12345678901234567",
- "timezoneOffset": 3,
- "locale": "en",
- "currency": "USD",
- "streamEndpoint": "wss://api-streaming-capital.backend-capital.com/"
}
Create a trading session, obtaining session tokens for subsequent API access
Session is active for 10 minutes. In case your inactivity is longer than this period then you need to create a new session
Endpoint limit: 1 request per second
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
identifier | string | YES | Client login identifier |
password | string | YES | API key custom password |
encryptedPassword | boolean | NO | Whether the password has been encrypted. Default value: false |
X-CAP-API-KEY | string Example: ENTER_GENERATED_API_KEY The API key obtained from Settings > API Integrations page on the Capital.com trading platform |
{- "identifier": "ENTER_YOUR_EMAIL",
- "password": "ENTER_YOUR_PASSWORD"
}
{ "accountType": "CFD", "accountInfo": { "balance": 92.89, "deposit": 90.38, "profitLoss": 2.51, "available": 64.66 }, "currencyIsoCode": "USD", "currencySymbol": "$", "currentAccountId": "12345678901234567", "streamingHost": "wss://api-streaming-capital.backend-capital.com/", "accounts": [ { "accountId": "12345678901234567", "accountName": "USD", "preferred": true, "accountType": "CFD", "currency": "USD", "symbol": "$", "balance": { "balance": 92.89, "deposit": 90.38, "profitLoss": 2.51, "available": 64.66 } }, { "accountId": "12345678907654321", "accountName": "EUR", "preferred": false, "accountType": "CFD", "currency": "EUR", "symbol": "€", "balance": { "balance": 0.0, "deposit": 0.0, "profitLoss": 0.0, "available": 0.0 } } ], "clientId": "12345678", "timezoneOffset": 3, "hasActiveDemoAccounts": true, "hasActiveLiveAccounts": true, "trailingStopsEnabled": false }
Switch active account
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
accountId | string | YES | The identifier of the account being switched to |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "accountId": "12345678907654321"
}
{- "trailingStopsEnabled": false,
- "dealingEnabled": true,
- "hasActiveDemoAccounts": false,
- "hasActiveLiveAccounts": true
}
Log out of the current session
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/session", Method.Delete); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{ "status": "SUCCESS" }
Returns a list of accounts belonging to the logged-in client
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/accounts", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "accounts": [
- {
- "accountId": "12345678901234567",
- "accountName": "USD",
- "status": "ENABLED",
- "accountType": "CFD",
- "preferred": true,
- "balance": {
- "balance": 92.89,
- "deposit": 90.38,
- "profitLoss": 2.51,
- "available": 64.66
}, - "currency": "USD",
- "symbol": "$"
}, - {
- "accountId": "12345678901234567",
- "accountName": "EUR",
- "status": "ENABLED",
- "accountType": "CFD",
- "preferred": false,
- "balance": {
- "balance": 0,
- "deposit": 0,
- "profitLoss": 0,
- "available": 0
}, - "currency": "EUR",
- "symbol": "€"
}
]
}
Returns account preferences, i.e. leverage settings and trading mode
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/accounts/preferences", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "hedgingMode": false,
- "leverages": {
- "SHARES": {
- "current": 2,
- "available": [
- 1,
- 2,
- 3,
- 5
]
}, - "CURRENCIES": {
- "current": 1,
- "available": [
- 1,
- 10,
- 20,
- 30
]
}, - "INDICES": {
- "current": 10,
- "available": [
- 1,
- 10,
- 20
]
}, - "CRYPTOCURRENCIES": {
- "current": 1,
- "available": [
- 1,
- 2
]
}, - "COMMODITIES": {
- "current": 5,
- "available": [
- 1,
- 5,
- 10,
- 20
]
}
}
}
Update account preferences
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
leverages | object | NO | Set new leverage values |
hedgingMode | boolean | NO | Enable or disable hedging mode |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "leverages": {
- "SHARES": 5,
- "CURRENCIES": 10,
- "INDICES": 20,
- "CRYPTOCURRENCIES": 2,
- "COMMODITIES": 5
}, - "hedgingMode": false
}
{- "status": "SUCCESS"
}
Returns the account activity history
All query parameters are optional for this request
The maximum possible date range between from
and to
parameters is 1 day. If only one of the parameters is specified (from
or to
), the 1-day date range will be selected by default
Possible enum values for parameters in FIQL filter:
Parameter | ENUM |
---|---|
source | CLOSE_OUT , DEALER , SL , SYSTEM , TP , USER |
status | ACCEPTED , CREATED , EXECUTED , EXPIRED , REJECTED , MODIFIED , MODIFY_REJECT , CANCELLED , CANCEL_REJECT , UNKNOWN |
type | POSITION , WORKING_ORDER , EDIT_STOP_AND_LIMIT , SWAP , SYSTEM |
from | string Example: from=2022-01-17T15:09:47 Start date. Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-04-01T01:01:00). Filtration by date based on dateUTC parameter |
to | string Example: to=2022-01-17T15:10:05 End date. Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-04-01T01:01:00). Filtration by date based on dateUTC parameter |
lastPeriod | integer Example: lastPeriod=600 Limits the timespan in seconds through to current time (not applicable if a date range has been specified). Cannot be bigger than current Unix timestamp value. Default = 600, max = 86400 |
detailed | boolean Example: detailed=true Indicates whether to retrieve additional details about the activity. False by default |
dealId | string Example: dealId={{dealId}} Get activity information for specific dealId |
filter | string Example: filter=source!=DEALER;type!=POSITION;status==REJECTED;epic==OIL_CRUDE,GOLD Filter activity list using FIQL. List of supported parameters: epic, source, status, type |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/history/activity?from=2022-01-17T15:09:47&to=2022-01-17T15:10:05&lastPeriod=600&detailed=true&dealId={{dealId}}&filter=source!=DEALER;type!=POSITION;status==REJECTED;epic==OIL_CRUDE,GOLD", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "activities": [
- {
- "date": "2022-01-17T18:09:47.344",
- "dateUTC": "2022-01-17T15:09:47.344",
- "epic": "OIL_CRUDE",
- "dealId": "00018509-0001-54c4-0000-000080430164",
- "source": "USER",
- "type": "POSITION",
- "status": "ACCEPTED"
}, - {
- "date": "2022-01-17T18:09:47.344",
- "dateUTC": "2022-01-17T15:09:47.344",
- "epic": "OIL_CRUDE",
- "dealId": "00018509-0001-54c4-0000-000080430163",
- "source": "SYSTEM",
- "type": "WORKING_ORDER",
- "status": "ACCEPTED"
}, - {
- "date": "2022-01-17T18:09:47.344",
- "dateUTC": "2022-01-17T15:09:47.344",
- "epic": "OIL_CRUDE",
- "dealId": "00018509-0001-54c4-0000-000080430163",
- "source": "USER",
- "type": "WORKING_ORDER",
- "status": "ACCEPTED"
}
]
}
Returns the transaction history. By default returns the transactions within the last 10 minutes
All query parameters are optional for this request
from | string Example: from=2021-08-10T00:00:00 Start date. Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-04-01T01:01:00). Filtration by date based on dateUTC parameter |
to | string Example: to=2021-09-10T00:00:01 End date. Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-04-01T01:01:00). Filtration by date based on dateUTC parameter |
lastPeriod | integer Example: lastPeriod=600 Limits the timespan in seconds through to current time (not applicable if a date range has been specified). Cannot be bigger than current Unix timestamp value. Default = 600 |
type | string Example: type=DEPOSIT Transaction type. Possible values: INACTIVITY_FEE, RESERVE, VOID, UNRESERVE, WRITE_OFF_OR_CREDIT, CREDIT_FACILITY, FX_COMMISSION, COMPLAINT_SETTLEMENT, DEPOSIT, WITHDRAWAL, REFUND, WITHDRAWAL_MONEY_BACK, TRADE, SWAP, TRADE_COMMISSION, TRADE_COMMISSION_GSL, NEGATIVE_BALANCE_PROTECTION, TRADE_CORRECTION, CHARGEBACK, ADJUSTMENT, BONUS, TRANSFER, CORPORATE_ACTION, CONVERSION, REBATE, TRADE_SLIPPAGE_PROTECTION |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/history/transactions?from=2021-08-10T00:00:00&to=2021-09-10T00:00:01&lastPeriod=600&type=DEPOSIT", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "transactions": [
- {
- "date": "2022-04-04T16:51:05.648",
- "dateUtc": "2022-04-04T16:51:05.648",
- "instrumentName": "NATURALGAS",
- "transactionType": "TRADE",
- "note": "Trade closed",
- "reference": "12345678",
- "size": "1.05",
- "currency": "USD",
- "status": "PROCESSED"
}, - {
- "date": "2022-04-04T16:51:00.788",
- "dateUtc": "2022-04-04T16:51:00.788",
- "instrumentName": "US500",
- "transactionType": "TRADE",
- "note": "Trade closed",
- "reference": "87654321",
- "size": "416.0",
- "currency": "USD",
- "status": "PROCESSED"
}
]
}
Adjust the balance of the current Demo account.
Note: The balance of the Demo account cannot exceed 100000.
Limits:
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
amount | number | YES | The amount of funds that will be added to the Demo account balance Notes: - Min value = -400000 - Max value = 400000 |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "amount": 1000
}
{- "successful": true
}
Returns a deal confirmation for the given deal reference
In case of mentioning the order prefix formed because of the position creation the opened positions IDs will be shown in the affectedDeals
array
dealReference required | string Example: {{dealReference}} Deal reference for an unconfirmed trade |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/confirms/{{dealReference}}", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "date": "2022-04-06T07:32:19.193",
- "status": "OPEN",
- "dealStatus": "ACCEPTED",
- "epic": "SILVER",
- "dealReference": "o_fcc7e6c0-c150-48aa-bf66-d6c6da071f1a",
- "dealId": "006011e7-0001-54c4-0000-000080560043",
- "affectedDeals": [
- {
- "dealId": "006011e7-0001-54c4-0000-000080560045",
- "status": "OPENED"
}
], - "level": 24.285,
- "size": 1,
- "direction": "BUY",
- "guaranteedStop": false,
- "trailingStop": false
}
Returns all open positions for the active account
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/positions", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "positions": [
- {
- "position": {
- "contractSize": 1,
- "createdDate": "2022-04-05T12:46:01.872",
- "createdDateUTC": "2022-04-05T09:46:01.872",
- "dealId": "00018387-0001-54c4-0000-000080560014",
- "dealReference": "p_00018387-0001-54c4-0000-000080560014",
- "workingOrderId": "00018387-0001-54c4-0000-000080560012",
- "size": 10,
- "leverage": 20,
- "upl": -0.05,
- "direction": "BUY",
- "level": 2.764,
- "currency": "USD",
- "guaranteedStop": false
}, - "market": {
- "instrumentName": "Natural Gas",
- "expiry": "-",
- "marketStatus": "TRADEABLE",
- "epic": "NATURALGAS",
- "symbol": "Natural Gas",
- "instrumentType": "COMMODITIES",
- "lotSize": 1,
- "high": 2.798,
- "low": 2.743,
- "percentageChange": 0.8053,
- "netChange": 0.022,
- "bid": 2.759,
- "offer": 2.764,
- "updateTime": "2022-04-05T17:41:38.492",
- "updateTimeUTC": "2022-04-05T14:41:38.492",
- "delayTime": 0,
- "streamingPricesAvailable": true,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
]
}
}, - {
- "position": {
- "contractSize": 1,
- "createdDate": "2022-04-05T12:46:10.139",
- "createdDateUTC": "2022-04-05T09:46:10.139",
- "dealId": "004d0627-0001-54c4-0000-000080560017",
- "dealReference": "p_004d0627-0001-54c4-0000-000080560017",
- "workingOrderId": "004d0627-0001-54c4-0000-000080560015",
- "size": 1,
- "leverage": 20,
- "upl": -0.8,
- "direction": "BUY",
- "level": 3985.1,
- "currency": "USD",
- "guaranteedStop": false
}, - "market": {
- "instrumentName": "S&P 500",
- "expiry": "2022-02-01",
- "marketStatus": "TRADEABLE",
- "epic": "US500",
- "symbol": "US500",
- "instrumentType": "INDICES",
- "lotSize": 1,
- "high": 3984.6,
- "low": 3950.3,
- "percentageChange": -0.0301,
- "netChange": -1.2,
- "bid": 3984.3,
- "offer": 3985.1,
- "updateTime": "2022-04-05T17:41:37.991",
- "updateTimeUTC": "2022-04-05T14:41:37.991",
- "delayTime": 0,
- "streamingPricesAvailable": true,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
]
}
}
]
}
Create orders and positions
Please note that when creating the position an order is created first with the 'o_' prefix in the dealReference
parameter
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
direction | string | YES | Deal direction Must be BUY or SELL |
epic | string | YES | Instrument epic identifier |
size | number | YES | Deal size |
guaranteedStop | boolean | NO | Must be true if a guaranteed stop is required Notes: - Default value: false - If guaranteedStop equals true , then set stopLevel , stopDistance or stopAmount - Cannot be set if trailingStop is true - Cannot be set if hedgingMode is true |
trailingStop | boolean | NO | Must be true if a trailing stop is required Notes: - Default value: false - If trailingStop equals true , then set stopDistance - Cannot be set if guaranteedStop is true |
stopLevel | number | NO | Price level when a stop loss will be triggered |
stopDistance | number | NO | Distance between current and stop loss triggering price Notes: - Required parameter if trailingStop is true |
stopAmount | number | NO | Loss amount when a stop loss will be triggered |
profitLevel | number | NO | Price level when a take profit will be triggered |
profitDistance | number | NO | Distance between current and take profit triggering price |
profitAmount | number | NO | Profit amount when a take profit will be triggered |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "epic": "SILVER",
- "direction": "BUY",
- "size": 1,
- "guaranteedStop": true,
- "stopLevel": 20,
- "profitLevel": 27
}
{- "dealReference": "o_98c0de50-9cd5-4481-8d81-890c525eeb49"
}
Returns an open position for the active account by deal identifier
dealId required | string Example: {{dealId}} Permanent deal reference for a confirmed trade |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/positions/{{dealId}}", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "position": {
- "contractSize": 1,
- "createdDate": "2022-04-06T10:49:52.056",
- "createdDateUTC": "2022-04-06T07:49:52.056",
- "dealId": "006011e7-0001-54c4-0000-00008056005e",
- "dealReference": "p_006011e7-0001-54c4-0000-00008056005e",
- "workingOrderId": "006011e7-0001-54c4-0000-00008056005c",
- "size": 1,
- "leverage": 20,
- "upl": -0.022,
- "direction": "BUY",
- "level": 21.059,
- "currency": "USD",
- "guaranteedStop": false
}, - "market": {
- "instrumentName": "Silver",
- "expiry": "-",
- "marketStatus": "TRADEABLE",
- "epic": "SILVER",
- "symbol": "Natural Gas",
- "instrumentType": "COMMODITIES",
- "lotSize": 1,
- "high": 21.167,
- "low": 20.823,
- "percentageChange": 1.8478,
- "netChange": 0.381,
- "bid": 21.037,
- "offer": 21.057,
- "updateTime": "2022-04-06T10:53:35.389",
- "updateTimeUTC": "2022-04-06T07:53:35.389",
- "delayTime": 0,
- "streamingPricesAvailable": true,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
]
}
}
Update the position
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
guaranteedStop | boolean | NO | Must be true if a guaranteed stop is required Notes: - Default value: false - If guaranteedStop equals true , then set stopLevel , stopDistance or stopAmount - Cannot be set if trailingStop is true - Cannot be set if hedgingMode is true |
trailingStop | boolean | NO | Must be true if a trailing stop is required Notes: - Default value: false - If trailingStop equals true , then set stopDistance - Cannot be set if guaranteedStop is true |
stopLevel | number | NO | Price level when a stop loss will be triggered |
stopDistance | number | NO | Distance between current and stop loss triggering price Notes: - Required parameter if trailingStop is true |
stopAmount | number | NO | Loss amount when a stop loss will be triggered |
profitLevel | number | NO | Price level when a take profit will be triggered |
profitDistance | number | NO | Distance between current and take profit triggering price |
profitAmount | number | NO | Profit amount when a take profit will be triggered |
dealId required | string Example: {{dealId}} Permanent deal reference for a confirmed trade |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "guaranteedStop": true,
- "stopDistance": 3,
- "profitAmount": 2
}
{- "dealReference": "p_006011e7-0001-54c4-0000-000080560068"
}
Close the position
dealId required | string Example: {{dealId}} Permanent deal reference for a confirmed trade |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/positions/{{dealId}}", Method.Delete); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "dealReference": "p_006011e7-0001-54c4-0000-000080560068"
}
Returns all open working orders for the active account
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/workingorders", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "workingOrders": [
- {
- "workingOrderData": {
- "dealId": "006011e7-0001-54c4-0000-000080560078",
- "direction": "BUY",
- "epic": "SILVER",
- "orderSize": 1,
- "leverage": 10,
- "orderLevel": 20,
- "timeInForce": "GOOD_TILL_DATE",
- "goodTillDate": "2022-06-09T04:01:00.000",
- "goodTillDateUTC": "2022-06-09T01:01:00.000",
- "createdDate": "2022-04-06T12:48:28.114",
- "createdDateUTC": "2022-04-06T09:48:28.114",
- "guaranteedStop": true,
- "orderType": "LIMIT",
- "stopDistance": -3,
- "profitDistance": 3,
- "trailingStop": false,
- "currencyCode": "USD"
}, - "marketData": {
- "instrumentName": "Silver",
- "expiry": "-",
- "marketStatus": "TRADEABLE",
- "epic": "SILVER",
- "symbol": "Silver",
- "instrumentType": "COMMODITIES",
- "lotSize": 50,
- "high": 24.398,
- "low": 24.193,
- "percentageChange": -0.6198,
- "netChange": -0.152,
- "bid": 24.387,
- "offer": 24.407,
- "updateTime": "2022-04-06T12:48:31.587",
- "updateTimeUTC": "2022-04-06T09:48:31.587",
- "delayTime": 0,
- "streamingPricesAvailable": true,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
]
}
}, - {
- "workingOrderData": {
- "dealId": "00018387-0001-54c4-0000-000080560019",
- "direction": "BUY",
- "epic": "NATURALGAS",
- "orderSize": 1,
- "leverage": 10,
- "orderLevel": 6,
- "timeInForce": "GOOD_TILL_CANCELLED",
- "createdDate": "2022-04-06T12:13:46.571",
- "createdDateUTC": "2022-04-06T09:13:46.571",
- "guaranteedStop": false,
- "orderType": "LIMIT",
- "trailingStop": false,
- "currencyCode": "USD"
}, - "marketData": {
- "instrumentName": "Natural Gas",
- "expiry": "-",
- "marketStatus": "TRADEABLE",
- "epic": "NATURALGAS",
- "symbol": "Natural Gas",
- "instrumentType": "COMMODITIES",
- "lotSize": 1000,
- "high": 6.194,
- "low": 6.073,
- "percentageChange": 6.4472,
- "netChange": 0.374,
- "bid": 6.185,
- "offer": 6.195,
- "updateTime": "2022-04-06T12:48:24.795",
- "updateTimeUTC": "2022-04-06T09:48:24.795",
- "delayTime": 0,
- "streamingPricesAvailable": true,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
]
}
}
]
}
Create a limit or stop order
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
direction | string | YES | Order direction Must be BUY or SELL |
epic | string | YES | Instrument epic identifier |
size | number | YES | Order size |
level | number | YES | Order price |
type | string | YES | Order type Must be LIMIT or STOP |
goodTillDate | string | NO | Order cancellation date in UTC time Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-06-09T01:01:00 ) |
guaranteedStop | boolean | NO | Must be true if a guaranteed stop is required Notes: - Default value: false - If guaranteedStop equals true , then set stopLevel , stopDistance or stopAmount - Cannot be set if trailingStop is true - Cannot be set if hedgingMode is true |
trailingStop | boolean | NO | Must be true if a trailing stop is required Notes: - Default value: false - If trailingStop equals true , then set stopDistance - Cannot be set if guaranteedStop is true |
stopLevel | number | NO | Price level when a stop loss will be triggered |
stopDistance | number | NO | Distance between current and stop loss triggering price Notes: - Required parameter if trailingStop is true |
stopAmount | number | NO | Loss amount when a stop loss will be triggered |
profitLevel | number | NO | Price level when a take profit will be triggered |
profitDistance | number | NO | Distance between current and take profit triggering price |
profitAmount | number | NO | Profit amount when a take profit will be triggered |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "epic": "SILVER",
- "direction": "BUY",
- "size": 1,
- "level": 20,
- "type": "LIMIT"
}
{- "dealReference": "o_307bb379-6dd8-4ea7-8935-faf725f0e0a3"
}
Update a limit or stop order
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
level | number | NO | Order price |
goodTillDate | string | NO | Order cancellation date in UTC time Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-06-09T01:01:00 ) |
guaranteedStop | boolean | NO | Must be true if a guaranteed stop is required Notes: - Default value: false - If guaranteedStop equals true , then set stopLevel , stopDistance or stopAmount - Cannot be set if trailingStop is true - Cannot be set if hedgingMode is true |
trailingStop | boolean | NO | Must be true if a trailing stop is required Notes: - Default value: false - If trailingStop equals true , then set stopDistance - Cannot be set if guaranteedStop is true |
stopLevel | number | NO | Price level when a stop loss will be triggered |
stopDistance | number | NO | Distance between current and stop loss triggering price Notes: - Required parameter if trailingStop is true |
stopAmount | number | NO | Loss amount when a stop loss will be triggered |
profitLevel | number | NO | Price level when a take profit will be triggered |
profitDistance | number | NO | Distance between current and take profit triggering price |
profitAmount | number | NO | Profit amount when a take profit will be triggered |
dealId required | string Example: {{dealId}} Permanent deal reference for an order |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "goodTillDate": "2022-06-09T01:01:00",
- "guaranteedStop": true,
- "stopDistance": 4,
- "profitDistance": 4
}
{- "dealReference": "o_56e73aad-45fe-4058-a05b-569b1a6e8ba0"
}
Delete a limit or stop order
dealId required | string Example: {{dealId}} Permanent deal reference for an order |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/workingorders/{{dealId}}", Method.Delete); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "dealReference": "o_38323f0c-241a-43b3-8edf-a75d2ae989a5"
}
Returns the details of all or specific markets
If query parameters are not specified in the request, the list of all available markets will be returned
Request can include one of the query parameters: searchTerm
or epics
If both searchTerm
or epics
parameters are specified in the request, only searchTerm
will be used (due to higher priority)
searchTerm | string Example: searchTerm=silver The term to be used in the search. Has higher priority, than 'epics' parameter meaning that in case both searchTerm and epic are mentioned only searchTerm is taken into consideration. |
epics | string Example: epics=SILVER,NATURALGAS The epics of the market, separated by a comma. Max number of epics is limited to 50 |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/markets?searchTerm=silver&epics=SILVER,NATURALGAS", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "markets": [
- {
- "delayTime": 0,
- "epic": "SILVER",
- "symbol": "Silver",
- "netChange": -0.219,
- "lotSize": 1,
- "expiry": "-",
- "instrumentType": "COMMODITIES",
- "instrumentName": "Silver",
- "high": 24.405,
- "low": 24.119,
- "percentageChange": -0.8929,
- "updateTime": "2022-04-06T15:17:38.477",
- "updateTimeUTC": "2022-04-06T13:17:38.477",
- "bid": 24.366,
- "offer": 24.386,
- "streamingPricesAvailable": true,
- "marketStatus": "TRADEABLE",
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
], - "pipPosition": 2,
- "tickSize": 0.001
}, - {
- "delayTime": 0,
- "epic": "5CPSG",
- "symbol": "5CPsg",
- "netChange": 0.005,
- "lotSize": 1,
- "expiry": "-",
- "instrumentType": "SHARES",
- "instrumentName": "Silverlake Axis",
- "high": 0.318,
- "low": 0.313,
- "percentageChange": 1.5974,
- "updateTime": "2022-04-06T11:00:00.440",
- "updateTimeUTC": "2022-04-06T09:00:00.440",
- "bid": 0.318,
- "offer": 0.327,
- "streamingPricesAvailable": true,
- "marketStatus": "CLOSED",
- "scalingFactor": 1,
- "marketModes": [
- "VIEW_ONLY"
], - "pipPosition": 2,
- "tickSize": 0.001
}
]
}
Returns the details of the given market
epic required | string Example: {{epic}} The epic of the market |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/markets/{{epic}}", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "instrument": {
- "epic": "SILVER",
- "symbol": "Silver",
- "expiry": "-",
- "name": "Silver",
- "lotSize": 1,
- "type": "COMMODITIES",
- "guaranteedStopAllowed": true,
- "streamingPricesAvailable": true,
- "currency": "USD",
- "marginFactor": 10,
- "marginFactorUnit": "PERCENTAGE",
- "openingHours": {
- "mon": [
- "00:00 - 21:59",
- "23:05 - 00:00"
], - "tue": [
- "00:00 - 21:59",
- "23:05 - 00:00"
], - "wed": [
- "00:00 - 21:59",
- "23:05 - 00:00"
], - "thu": [
- "00:00 - 21:59",
- "23:05 - 00:00"
], - "fri": [
- "00:00 - 21:59"
], - "sat": [ ],
- "sun": [
- "23:05 - 00:00"
], - "zone": "UTC"
}, - "overnightFee": {
- "longRate": -0.0199715,
- "shortRate": 0.0117515,
- "swapChargeTimestamp": 1707948000000,
- "swapChargeInterval": 1440
}
}, - "dealingRules": {
- "minStepDistance": {
- "unit": "POINTS",
- "value": 0.001
}, - "minDealSize": {
- "unit": "POINTS",
- "value": 1
}, - "maxDealSize": {
- "unit": "POINTS",
- "value": 100000
}, - "minSizeIncrement": {
- "unit": "POINTS",
- "value": 0.1
}, - "minGuaranteedStopDistance": {
- "unit": "PERCENTAGE",
- "value": 1
}, - "minStopOrProfitDistance": {
- "unit": "PERCENTAGE",
- "value": 0.01
}, - "maxStopOrProfitDistance": {
- "unit": "PERCENTAGE",
- "value": 60
}, - "marketOrderPreference": "AVAILABLE_DEFAULT_ON",
- "trailingStopsPreference": "NOT_AVAILABLE"
}, - "snapshot": {
- "marketStatus": "TRADEABLE",
- "netChange": -0.627,
- "percentageChange": -0.27,
- "updateTime": "2022-04-06T11:23:00.955",
- "delayTime": 0,
- "bid": 22.041,
- "offer": 22.061,
- "high": 22.098,
- "low": 21.926,
- "decimalPlacesFactor": 3,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
]
}
}
Returns historical prices for a particular instrument
All query parameters are optional for this request
By default returns the minute prices within the last 10 minutes
epic required | string Example: {{epic}} Instrument epic |
resolution | string Example: resolution=MINUTE Defines the resolution of requested prices. Possible values are MINUTE, MINUTE_5, MINUTE_15, MINUTE_30, HOUR, HOUR_4, DAY, WEEK |
max | integer Example: max=10 The maximum number of the values in answer. Default = 10, max = 1000 |
from | string Example: from=2022-02-24T00:00:00 Start date. Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-04-01T01:01:00). Filtration by date based on snapshotTimeUTC parameter |
to | string Example: to=2022-02-24T01:00:00 End date. Date format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-04-01T01:01:00). Filtration by date based on snapshotTimeUTC parameter |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/prices/{{epic}}?resolution=MINUTE&max=10&from=2022-02-24T00:00:00&to=2022-02-24T01:00:00", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "prices": [
- {
- "snapshotTime": "2022-04-06T15:18:00",
- "snapshotTimeUTC": "2022-04-06T13:18:00",
- "openPrice": {
- "bid": 24.356,
- "ask": 24.376
}, - "closePrice": {
- "bid": 24.378,
- "ask": 24.398
}, - "highPrice": {
- "bid": 24.378,
- "ask": 24.398
}, - "lowPrice": {
- "bid": 24.355,
- "ask": 24.375
}, - "lastTradedVolume": 187
}, - {
- "snapshotTime": "2022-04-06T15:19:00",
- "snapshotTimeUTC": "2022-04-06T13:19:00",
- "openPrice": {
- "bid": 24.379,
- "ask": 24.399
}, - "closePrice": {
- "bid": 24.379,
- "ask": 24.399
}, - "highPrice": {
- "bid": 24.389,
- "ask": 24.409
}, - "lowPrice": {
- "bid": 24.373,
- "ask": 24.393
}, - "lastTradedVolume": 168
}, - {
- "snapshotTime": "2022-04-06T15:20:00",
- "snapshotTimeUTC": "2022-04-06T13:20:00",
- "openPrice": {
- "bid": 24.378,
- "ask": 24.398
}, - "closePrice": {
- "bid": 24.4,
- "ask": 24.42
}, - "highPrice": {
- "bid": 24.4,
- "ask": 24.42
}, - "lowPrice": {
- "bid": 24.375,
- "ask": 24.395
}, - "lastTradedVolume": 183
}, - {
- "snapshotTime": "2022-04-06T15:21:00",
- "snapshotTimeUTC": "2022-04-06T13:21:00",
- "openPrice": {
- "bid": 24.399,
- "ask": 24.419
}, - "closePrice": {
- "bid": 24.395,
- "ask": 24.415
}, - "highPrice": {
- "bid": 24.405,
- "ask": 24.425
}, - "lowPrice": {
- "bid": 24.388,
- "ask": 24.408
}, - "lastTradedVolume": 196
}, - {
- "snapshotTime": "2022-04-06T15:22:00",
- "snapshotTimeUTC": "2022-04-06T13:22:00",
- "openPrice": {
- "bid": 24.394,
- "ask": 24.414
}, - "closePrice": {
- "bid": 24.399,
- "ask": 24.419
}, - "highPrice": {
- "bid": 24.4,
- "ask": 24.42
}, - "lowPrice": {
- "bid": 24.383,
- "ask": 24.403
}, - "lastTradedVolume": 171
}, - {
- "snapshotTime": "2022-04-06T15:23:00",
- "snapshotTimeUTC": "2022-04-06T13:23:00",
- "openPrice": {
- "bid": 24.398,
- "ask": 24.418
}, - "closePrice": {
- "bid": 24.381,
- "ask": 24.401
}, - "highPrice": {
- "bid": 24.405,
- "ask": 24.425
}, - "lowPrice": {
- "bid": 24.38,
- "ask": 24.4
}, - "lastTradedVolume": 161
}, - {
- "snapshotTime": "2022-04-06T15:24:00",
- "snapshotTimeUTC": "2022-04-06T13:24:00",
- "openPrice": {
- "bid": 24.38,
- "ask": 24.4
}, - "closePrice": {
- "bid": 24.387,
- "ask": 24.407
}, - "highPrice": {
- "bid": 24.399,
- "ask": 24.419
}, - "lowPrice": {
- "bid": 24.38,
- "ask": 24.4
}, - "lastTradedVolume": 155
}, - {
- "snapshotTime": "2022-04-06T15:25:00",
- "snapshotTimeUTC": "2022-04-06T13:25:00",
- "openPrice": {
- "bid": 24.388,
- "ask": 24.408
}, - "closePrice": {
- "bid": 24.389,
- "ask": 24.409
}, - "highPrice": {
- "bid": 24.393,
- "ask": 24.413
}, - "lowPrice": {
- "bid": 24.384,
- "ask": 24.404
}, - "lastTradedVolume": 118
}, - {
- "snapshotTime": "2022-04-06T15:26:00",
- "snapshotTimeUTC": "2022-04-06T13:26:00",
- "openPrice": {
- "bid": 24.389,
- "ask": 24.409
}, - "closePrice": {
- "bid": 24.373,
- "ask": 24.393
}, - "highPrice": {
- "bid": 24.39,
- "ask": 24.41
}, - "lowPrice": {
- "bid": 24.37,
- "ask": 24.39
}, - "lastTradedVolume": 143
}, - {
- "snapshotTime": "2022-04-06T15:27:00",
- "snapshotTimeUTC": "2022-04-06T13:27:00",
- "openPrice": {
- "bid": 24.372,
- "ask": 24.392
}, - "closePrice": {
- "bid": 24.375,
- "ask": 24.395
}, - "highPrice": {
- "bid": 24.376,
- "ask": 24.396
}, - "lowPrice": {
- "bid": 24.371,
- "ask": 24.391
}, - "lastTradedVolume": 44
}
], - "instrumentType": "COMMODITIES"
}
Returns the client sentiment for the given market
marketIds | string Example: marketIds=SILVER,NATURALGAS Comma separated list of market identifiers |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/clientsentiment?marketIds=SILVER,NATURALGAS", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "clientSentiments": [
- {
- "marketId": "SILVER",
- "longPositionPercentage": 91.85,
- "shortPositionPercentage": 8.15
}, - {
- "marketId": "NATURALGAS",
- "longPositionPercentage": 62.97,
- "shortPositionPercentage": 37.03
}
]
}
Returns the client sentiment for the given market
marketId required | string Example: {{marketId}} Market identifier |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/clientsentiment/{{marketId}}", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "marketId": "SILVER",
- "longPositionPercentage": 91.85,
- "shortPositionPercentage": 8.15
}
Returns all watchlists belonging to the current user
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/watchlists", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "watchlists": [
- {
- "id": "123456",
- "name": "Hello world",
- "editable": true,
- "deleteable": true,
- "defaultSystemWatchlist": false
}, - {
- "id": "123457",
- "name": "watchlist1",
- "editable": true,
- "deleteable": true,
- "defaultSystemWatchlist": false
}
]
}
Create a watchlist
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
name | string | YES | Watchlist name Min length = 1 Max length = 20 |
epics | array[string] | NO | List of market epics to be associated with this new watchlist |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "epics": [
- "SILVER",
- "NATURALGAS"
], - "name": "Lorem"
}
{- "watchlistId": "123458",
- "status": "SUCCESS"
}
Returns a watchlist for the given watchlist identifier
watchlistId required | string Example: {{watchlistId}} Identifier of the watchlist |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/watchlists/{{watchlistId}}", Method.Get); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "markets": [
- {
- "instrumentName": "Silver",
- "expiry": "-",
- "epic": "SILVER",
- "symbol": "Silver",
- "instrumentType": "COMMODITIES",
- "marketStatus": "TRADEABLE",
- "lotSize": 1,
- "high": 22.098,
- "low": 21.926,
- "percentageChange": -0.27,
- "netChange": -0.627,
- "bid": 22.041,
- "offer": 22.061,
- "updateTime": "2022-04-06T11:24:09.756",
- "updateTimeUTC": "2022-04-06T11:24:09.756",
- "delayTime": 0,
- "streamingPricesAvailable": true,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
], - "pipPosition": 2,
- "tickSize": 0.001
}, - {
- "instrumentName": "Natural Gas",
- "expiry": "-",
- "epic": "NATURALGAS",
- "symbol": "Natural Gas",
- "instrumentType": "COMMODITIES",
- "marketStatus": "TRADEABLE",
- "lotSize": 1,
- "high": 1.719,
- "low": 1.693,
- "percentageChange": 0.12,
- "netChange": -0.077,
- "bid": 1.701,
- "offer": 1.706,
- "updateTime": "2022-04-06T11:24:10.889",
- "updateTimeUTC": "2022-04-06T11:24:10.889",
- "delayTime": 0,
- "streamingPricesAvailable": true,
- "scalingFactor": 1,
- "marketModes": [
- "REGULAR"
], - "pipPosition": 3,
- "tickSize": 0.0001
}
]
}
Add a market to the watchlist
List of request body parameters:
Parameter | Format | Required? | Description |
---|---|---|---|
epic | string | YES | Instrument epic identifier |
watchlistId required | string Example: {{watchlistId}} Identifier of the watchlist |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
{- "epic": "SILVER"
}
{- "status": "SUCCESS"
}
Delete the watchlist
watchlistId required | string Example: {{watchlistId}} Identifier of the watchlist |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/watchlists/{{watchlistId}}", Method.Delete); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "status": "SUCCESS"
}
Remove a market from the watchlist
watchlistId required | string Example: {{watchlistId}} Identifier of the watchlist |
epic required | string Example: {{epic}} Instrument epic identifier |
X-SECURITY-TOKEN | string Example: ENTER_OBTAINED_SECURITY_TOKEN Account token identifying the client's current account |
CST | string Example: ENTER_OBTAINED_CST_TOKEN Access token identifying the client |
var options = new RestClientOptions("https://api-capital.backend-capital.com") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("/api/v1/watchlists/{{watchlistId}}/{{epic}}", Method.Delete); request.AddHeader("X-SECURITY-TOKEN", "ENTER_OBTAINED_SECURITY_TOKEN"); request.AddHeader("CST", "ENTER_OBTAINED_CST_TOKEN"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);
{- "status": "SUCCESS"
}