Skip to content

curl Examples

Practical examples for interacting with the XBTFX Trading API using curl. Replace your_api_key_here with your actual API key in all examples.

Terminal window
curl -X GET https://interface.xbtfx.com/v1/auth/status \
-H "Authorization: Bearer your_api_key_here"
Terminal window
curl -X GET https://interface.xbtfx.com/v1/account \
-H "Authorization: Bearer your_api_key_here"
Terminal window
curl -X GET https://interface.xbtfx.com/v1/symbols/EURUSD \
-H "Authorization: Bearer your_api_key_here"

Buy 0.1 lots of EURUSD with stop loss and take profit:

Terminal window
curl -X POST https://interface.xbtfx.com/v1/trade \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"symbol": "EURUSD",
"side": "buy",
"volume": 0.1,
"sl": 1.08000,
"tp": 1.09500
}'

Open a trade with an idempotency key:

Terminal window
curl -X POST https://interface.xbtfx.com/v1/trade \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000" \
-d '{
"symbol": "BTCUSD",
"side": "sell",
"volume": 0.01
}'

All positions:

Terminal window
curl -X GET https://interface.xbtfx.com/v1/positions \
-H "Authorization: Bearer your_api_key_here"

Filtered by symbol:

Terminal window
curl -X GET "https://interface.xbtfx.com/v1/positions?symbol=EURUSD" \
-H "Authorization: Bearer your_api_key_here"

Close a full position:

Terminal window
curl -X POST https://interface.xbtfx.com/v1/close \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"ticket": 12345678
}'

Partial close (0.05 of 0.1 lots):

Terminal window
curl -X POST https://interface.xbtfx.com/v1/close \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"ticket": 12345678,
"volume": 0.05
}'
Terminal window
curl -X POST https://interface.xbtfx.com/v1/modify \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"ticket": 12345678,
"sl": 1.08200,
"tp": 1.09800
}'

Remove stop loss:

Terminal window
curl -X POST https://interface.xbtfx.com/v1/modify \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"ticket": 12345678,
"sl": 0
}'

Using a named period:

Terminal window
curl -X GET "https://interface.xbtfx.com/v1/history?period=last_week" \
-H "Authorization: Bearer your_api_key_here"

Using a custom date range:

Terminal window
curl -X GET "https://interface.xbtfx.com/v1/history?from=2026-01-01&to=2026-03-31" \
-H "Authorization: Bearer your_api_key_here"
Terminal window
curl -X GET https://interface.xbtfx.com/v1/orders \
-H "Authorization: Bearer your_api_key_here"
Terminal window
curl -X POST https://interface.xbtfx.com/v1/close-all \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{}'