# DXtrade API POST /login

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/platforms/dxtrade/endpoints/post-login, written from the same records as that page.

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.

Log in with a username, a domain and a password and receive a session token to send with every later request.

- Request: `POST /login`
- Group: Sessions
- Status: verified. Source: [demo.dx.trade](https://demo.dx.trade/developers/#/DXtrade-REST-API), checked 2026-10-12.
- Official reference: https://demo.dx.trade/developers/#/DXtrade-REST-API?id=create-session-token

Note: 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 page shows the three body fields in its request example and marks none of them, so the required marks here are not confirmed. The reply carries sessionToken and timeout. The page says the token lapses after a set time without a request, on logout, or when the platform ends the session, after which a request is answered 401.

## Parameters

- `username` (in body, type string, required, not confirmed): The client's username. Read it from your own environment.
- `domain` (in body, type string, required, not confirmed): The client's domain.
- `password` (in body, type string, required, not confirmed): The client's password. Read it from your own environment. Never type it into this site.

The required marks on this page are this site's reading of secondary material, as the note above says. Which fields the API insists on is not confirmed on the provider's own reference.

## 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 at https://openbrokerapi.com/tools/request-builder writes these same snippets, from the same record.

This call takes a request body. The samples send it as JSON with a placeholder for each of the 3 body fields the record marks as required, a mark that is not confirmed. Each placeholder has to be replaced with a real value before the request can succeed.

### Python

```python
# Set DXTRADE_BASE_URL, DXTRADE_USERNAME, DXTRADE_PASSWORD as environment variables first. Never paste real values into code.
# 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.
import os
import requests

BASE_URL = os.environ["DXTRADE_BASE_URL"]
headers = {}
body = {"username": os.environ["DXTRADE_USERNAME"], "domain": "...", "password": os.environ["DXTRADE_PASSWORD"]}
resp = requests.post(BASE_URL + "/login", headers=headers, json=body, timeout=10)
resp.raise_for_status()
print(resp.json())
```

### JavaScript

```javascript
// Set DXTRADE_BASE_URL, DXTRADE_USERNAME, DXTRADE_PASSWORD as environment variables first. Never paste real values into code.
// 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.
// 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 + "/login", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"username": process.env.DXTRADE_USERNAME, "domain": "...", "password": process.env.DXTRADE_PASSWORD}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(await res.json());
```

### curl

```bash
# Set DXTRADE_BASE_URL, DXTRADE_USERNAME, DXTRADE_PASSWORD as environment variables first. Never paste real values into code.
# 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.
curl -X POST "$DXTRADE_BASE_URL/login" \
  -H "Content-Type: application/json" \
  -d "{\"username\": \"$DXTRADE_USERNAME\", \"domain\": \"...\", \"password\": \"$DXTRADE_PASSWORD\"}"
```

## Response

No mock response is recorded for this endpoint. That is a statement about this record, not about what the API returns: read the shape of the reply in the [official reference](https://demo.dx.trade/developers/#/DXtrade-REST-API?id=create-session-token).

## More on the DXtrade API

- [All DXtrade API endpoints](https://openbrokerapi.com/platforms/dxtrade/endpoints): 21 documented, grouped by what they do.
- [All DXtrade API error codes](https://openbrokerapi.com/errors/dxtrade)
- [DXtrade API page](https://openbrokerapi.com/platforms/dxtrade): The full record: access, authentication, limits and the source for each.
- [DXtrade API as an OpenAPI file](https://openbrokerapi.com/specs/dxtrade.json): Generated from these endpoint records. Independent and unofficial.

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: DXtrade API POST /login. Broker API Hub, https://openbrokerapi.com/platforms/dxtrade/endpoints/post-login, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
