DXtrade API POST /marketdata
Ask for current quotes or for historical candles for one or more instruments. One call serves both, chosen by the event type in the body.
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.
Read on 12 Oct 2026 in the DXtrade REST API specification on DXtrade's developer portal. The portal draws its pages in the browser from Markdown files it also serves directly, and the Markdown file of this page (DXtrade-REST-API.md) is what was read, with the model files it includes. The portal writes each address after a base address it fills in from its own settings, which on this portal is https://demo.dx.trade/dxsca-web. A broker or firm that offers DXtrade hosts its own, so the path here is what follows that base. The specification says every request needs authentication unless it says otherwise, and this section says the Authorization header should be included, which is why it is recorded as required. The body is the Market Data Request model and its Market Data Event Type, with the models' own marks. The reply is a market data list. The page says a request for symbols with no quotes is answered 404 with error code 35.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| eventTypesrequired | body | array | The kinds of data wanted, each an object with the fields below. |
| eventTypes[].typerequired | body | string | Either Quote or Candle. |
| eventTypes[].format | body | string | Marked optional. Always COMPACT. |
| eventTypes[].candleType | body | string | Marked optional. The candle size, for candle requests. One of: m, 5m, 15m, 30m, h, 2h, 4h, d, w, mo. |
| eventTypes[].fromTime | body | string | Marked optional in the table, which also says it is required for Candle. UTC time the history starts at. |
| eventTypes[].toTime | body | string | Marked optional in the table, which also says it is required for Candle. UTC time the history ends at. |
| eventTypes[].count | body | number | Marked optional. The most candles to return. When the period holds more, the older ones are dropped. |
| symbolsrequired | body | string | Instrument symbols, as a list of strings or one comma separated string. |
| account | body | string | Marked optional. An account code, used only where a user's accounts have different pricing. |
Authentication headers
| Name | Type | Description |
|---|---|---|
| Authorizationrequired | string | With token authentication, send DXAPI followed by the sessionToken from POST /login. With HMAC authentication the same header carries DXAPI with a principal, a timestamp and a hash, signed for each request as the specification describes. Placeholder only: never paste a real token into this site. |
Request
Written from the method, path and parameters recorded on this page. No demo host is recorded as a plain address for this API, so the samples read the base address from an environment variable. Not executed against a live or demo account. Credentials are read from environment variables on your own machine and are never entered on this site. The request builder writes these same snippets, from the same record.
This call takes a request body. The samples send it as JSON with a Content-Type of application/json (in Python, passing json= sets that header) and a placeholder for each of the 3 body fields the record marks as required. Each placeholder has to be replaced with a real value before the request can succeed.
Python
# Set DXTRADE_BASE_URL, DXTRADE_SESSION_TOKEN as environment variables first. Never paste real values into code.
# DXTRADE_SESSION_TOKEN holds the Authorization header that POST /login returns.
# No demo host is recorded as a plain address for this API, so the base address is read from DXTRADE_BASE_URL.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: body fields eventTypes[].format, eventTypes[].candleType, eventTypes[].fromTime, eventTypes[].toTime, eventTypes[].count, account.
import os
import requests
BASE_URL = os.environ["DXTRADE_BASE_URL"]
headers = {
"Authorization": "DXAPI " + os.environ["DXTRADE_SESSION_TOKEN"],
}
body = {"eventTypes": [{"type": "..."}], "symbols": "..."}
resp = requests.post(BASE_URL + "/marketdata", headers=headers, json=body, timeout=10)
resp.raise_for_status()
print(resp.json())JavaScript
// Set DXTRADE_BASE_URL, DXTRADE_SESSION_TOKEN as environment variables first. Never paste real values into code.
// DXTRADE_SESSION_TOKEN holds the Authorization header that POST /login returns.
// No demo host is recorded as a plain address for this API, so the base address is read from DXTRADE_BASE_URL.
// Replace each {placeholder}, "..." and 0 with a real value before running.
// Optional and not shown: body fields eventTypes[].format, eventTypes[].candleType, eventTypes[].fromTime, eventTypes[].toTime, eventTypes[].count, account.
// Run as a module, for example a .mjs file, on a Node version that has fetch built in.
const BASE_URL = process.env.DXTRADE_BASE_URL;
const res = await fetch(BASE_URL + "/marketdata", {
method: "POST",
headers: {
"Authorization": "DXAPI " + process.env.DXTRADE_SESSION_TOKEN,
"Content-Type": "application/json",
},
body: JSON.stringify({"eventTypes": [{"type": "..."}], "symbols": "..."}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(await res.json());curl
# Set DXTRADE_BASE_URL, DXTRADE_SESSION_TOKEN as environment variables first. Never paste real values into code.
# DXTRADE_SESSION_TOKEN holds the Authorization header that POST /login returns.
# No demo host is recorded as a plain address for this API, so the base address is read from DXTRADE_BASE_URL.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: body fields eventTypes[].format, eventTypes[].candleType, eventTypes[].fromTime, eventTypes[].toTime, eventTypes[].count, account.
curl -X POST "$DXTRADE_BASE_URL/marketdata" \
-H "Authorization: DXAPI $DXTRADE_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"eventTypes": [{"type": "..."}], "symbols": "..."}'Response
No mock response is recorded for this endpoint. Where the record says why, or names the fields of the reply, it does so in the note at the top of this page. That is a statement about this record, not about what the API returns: read the shape of the reply in the official reference.
DXtrade API errors you may meet
- 1 Authorization requiredHTTP 401. DXtrade errorCode 1, description "Authorization required" (the vendor's wording).
- 100 Order with this id already existsHTTP 409. DXtrade errorCode 100, description "Order with this id already exists" (the vendor's wording).
- 1005 Reference order is closedHTTP 409. DXtrade errorCode 1005, description "Reference order is closed" (the vendor's wording).
- 101 Client-originated identifier is not validHTTP 400. DXtrade errorCode 101, description "Client-originated identifier is not valid" (the vendor's wording).
- 11 Malformed HMAC signatureHTTP 400. DXtrade errorCode 11, description "Malformed HMAC signature" (the vendor's wording).
- 110 A system error has occurredHTTP 500. DXtrade errorCode 110, description "A system error has occurred" (the vendor's wording).
All DXtrade API error codes, including 73 more not listed here.