API Documentation
Request examples
POST /sessionLogin to the account and start the session.
Request:
curl -L -X POST 'https://api-capital.backend-capital.com/api/v1/session' \
-H 'X-CAP-API-KEY: evSl********S26P' \
-H 'Content-Type: application/json' \
--data-raw '{
"encryptedPassword": "false",
"identifier": "test@gmail.com",
"password": "Xxxx9999_"
}'
Request parameters
Parameter | Format | Mandatory? | Description |
---|---|---|---|
encryptedPassword | boolean | NO | Shows whether the mentioned password is encrypted with the AES encryption method. This parameter value = FALSE by default. |
identifier | string | YES | Login value. |
password | string | YES | Password value. |
Response:
{
"accountType": "CFD",
"accountInfo": {
"balance": 602.63,
"deposit": 602.35,
"profitLoss": -7.72,
"available": 600.78
},
"currencyIsoCode": "USD",
"currencySymbol": "$",
"currentAccountId": "23116495826791396",
"streamingHost": "wss://api-streaming-capital.backend-capital.com/",
"accounts": [
{
"accountId": "23116495826791396",
"accountName": "USD",
"preferred": true,
"accountType": "CFD"
},
{
"accountId": "24550935676066052",
"accountName": "secondAcc",
"preferred": false,
"accountType": "CFD"
}
],
"clientId": "1111111",
"timezoneOffset": 3,
"hasActiveDemoAccounts": false,
"hasActiveLiveAccounts": true,
"trailingStopsEnabled": false
}
POST /positions
Open a position.
Response:
curl -L -X POST 'https://api-capital.backend-capital.com/api/v1/positions' \
-H 'X-SECURITY-TOKEN: Flg82****kk9313' \
-H 'CST: Lp3e5WLALdkfsfN2MNdr7vk5' \
-H 'Content-Type: application/json' \
--data-raw '{
"epic": "NATURALGAS",
"direction": "BUY",
"size": 100
}'
Request parameters
Parameter | Format | Mandatory? | Description |
---|---|---|---|
direction | enum | YES | Direction of the trade: BUY or SELL. |
epic | string | YES | The market in which the trade should take place. |
guaranteedStop | boolean | NO | Guaranteed or normal stop loss. |
trailingStop | boolean | NO | Trailing or normal stop loss. |
profitAmount | number | NO | Take profit amount. |
profitDistance | number | NO | Take profit distance from the current asset price. |
profitLevel | number | NO | Take profit price. |
size | number | YES | Size of the trade. |
stopAmount | number | NO | Stop loss amount. |
stopDistance | number | NO | Stop loss distance from the current asset price. |
stopLevel | number | NO | Stop loss price. |
Response:
{
"dealReference": "o_43839486-f53j-478o-8162-193j7kcd509i"
}
POST /workingorders
Create a limit/stop order.
Response:
curl -L -X POST 'https://api-capital.backend-capital.com/api/v1/workingorders' \
-H 'X-SECURITY-TOKEN: Flg82****kk9313' \
-H 'CST: Lp3e5WLALdkfsfN2MNdr7vk5'\
-H 'Content-Type: application/json' \
--data-raw '{
"epic": "NATURALGAS",
"direction": "BUY",
"size": 1,
"level": 2300,
"type": "LIMIT",
"stopLevel": 2000
}'
Parameter | Format | Mandatory? | Description |
---|---|---|---|
direction | enum | YES | Direction of the trade: BUY or SELL. |
epic | string | YES | The market in which the trade should take place. |
goodTillDate | string | NO | Order expiration date. Format: YYYY-MM-DDTHH:MM:SS (e.g. 2022-04-01T01:01:00) |
guaranteedStop | boolean | NO | Guaranteed or normal stop loss. Set to normal by default. |
trailingStop | boolean | NO | Trailing or normal stop loss. |
level | number | YES | Order price level. |
profitAmount | number | NO | Take profit amount. |
profitDistance | number | NO | Take profit distance from the current asset price. |
profitLevel | number | NO | Take profit price. |
size | number | YES | Size of the trade. |
stopAmount | number | NO | Stop loss amount. |
stopDistance | number | NO | Stop loss distance from the current asset price. |
stopLevel | number | NO | Stop loss price. |
type | enum | YES | Order type: LIMIT or STOP. |
Response:
{
"dealReference": "o_da3727b2-eafb-4efa-a05a-63f8a632ab58"
}