Download OpenAPI specification:Download
Please note that this documentation site is deprecated and is no longer being maintained. For the latest, most accurate information, please visit our new API documentation portal:
Welcome to the official documentation for the Trading 212 Public API! This guide provides all the information you need to start building your own trading applications and integrations.
This API is currently in beta and is under active development. We're continuously adding new features and improvements, and we welcome your feedback.
We provide two distinct environments for development and trading:
https://demo.trading212.com/api/v0https://live.trading212.com/api/v0You can test your applications extensively in the paper trading environment without risking real funds before moving to live trading.
Please be aware of the following limitations during the beta period:
quantity parameter (e.g., -10.5). This is a core convention of the API.This simple example shows you how to retrieve your account's cash balance.
First, you must generate your API keys from within the Trading 212 mobile app. For detailed instructions, please visit our Help Centre:
Once you have your API Key and API Secret, you can make your first call using cURL:
# Step 1: Replace with your actual credentials and Base64-encode them.
# The `-n` is important as it prevents adding a newline character.
CREDENTIALS=$(echo -n "<YOUR_API_KEY>:<YOUR_API_SECRET>" | base64)
# Step 2: Make the API call to the live environment using the encoded credentials.
curl -X GET "[https://live.trading212.com/api/v0/equity/account/cash](https://live.trading212.com/api/v0/equity/account/cash)" \
-H "Authorization: Basic $CREDENTIALS"
The API uses a secure key pair for authentication on every request. You must provide your API Key as the username and your API Secret as the password, formatted as an HTTP Basic Authentication header.
The Authorization header is constructed by Base64-encoding your API_KEY:API_SECRET string and prepending it with Basic .
Here are examples of how to generate the required value in different environments.
Linux or macOS (Terminal)
You can use the echo and base64 commands. Remember to use the -n flag with echo to prevent it from adding a trailing newline, which would invalidate the credential string.
# This command outputs the required Base64-encoded string for your header.
echo -n "<YOUR_API_KEY>:<YOUR_API_SECRET>" | base64
Python
This simple snippet shows how to generate the full header value.
import base64
# 1. Your credentials
api_key = "<YOUR_API_KEY>"
api_secret = "<YOUR_API_SECRET>"
# 2. Combine them into a single string
credentials_string = f"{api_key}:{api_secret}"
# 3. Encode the string to bytes, then Base64 encode it
encoded_credentials = base64.b64encode(credentials_string.encode('utf-8')).decode('utf-8')
# 4. The final header value
auth_header = f"Basic {encoded_credentials}"
print(auth_header)
To ensure high performance and fair access for all users, all API endpoints are subject to rate limiting.
IMPORTANT NOTE: All rate limits are applied on a per-account basis, regardless of which API key is used or which IP address the request originates from.
Specific rate limits are detailed in the reference for each endpoint.
Every API response includes the following headers to help you manage your request frequency and avoid hitting limits.
x-ratelimit-limit: The total number of requests allowed in the current time period.x-ratelimit-period: The duration of the time period in seconds.x-ratelimit-remaining: The number of requests you have left in the current period.x-ratelimit-reset: A Unix timestamp indicating the exact time when the limit will be fully reset.x-ratelimit-used: The number of requests you have already made in the current period.The rate limiter allows for requests to be made in bursts. For example, an endpoint with a limit of 50 requests per 1 minute does not strictly mean you can only make one request every 1.2 seconds. Instead, you could:
x-ratelimit-reset header before making more requests.In addition to the general rate limits on HTTP calls, some actions have their own functional limits. For example, there is a maximum of 50 pending orders allowed per ticker, per account.
Here are some additional resources that you may find helpful.
Manage your investment Pies. Use these endpoints to create, view, update, and delete your custom portfolios, making automated and diversified investing simple.
Fetches all pies for the account
OK
Bad API key
Scope( pies:read ) missing for API key
Timed-out
Limited: 1 / 30s
[- {
- "cash": 0,
- "dividendDetails": {
- "gained": 0,
- "inCash": 0,
- "reinvested": 0
}, - "id": 0,
- "progress": 0.5,
- "result": {
- "priceAvgInvestedValue": 0,
- "priceAvgResult": 0,
- "priceAvgResultCoef": 0,
- "priceAvgValue": 0
}, - "status": "AHEAD"
}
]Creates a pie for the account by given params
OK
Bad create request
Bad API key
Scope( pies:write ) missing for API key
Timed-out
Limited: 1 / 5s
{- "dividendCashAction": "REINVEST",
- "endDate": "2019-08-24T14:15:22Z",
- "goal": 0,
- "icon": "string",
- "instrumentShares": {
- "AAPL_US_EQ": 0.5,
- "MSFT_US_EQ": 0.5
}, - "name": "string"
}{- "instruments": [
- {
- "currentShare": 0,
- "expectedShare": 0,
- "issues": [
- {
- "name": "DELISTED",
- "severity": "IRREVERSIBLE"
}
], - "ownedQuantity": 0,
- "result": {
- "priceAvgInvestedValue": 0,
- "priceAvgResult": 0,
- "priceAvgResultCoef": 0,
- "priceAvgValue": 0
}, - "ticker": "string"
}
], - "settings": {
- "creationDate": "2019-08-24T14:15:22Z",
- "dividendCashAction": "REINVEST",
- "endDate": "2019-08-24T14:15:22Z",
- "goal": 0,
- "icon": "string",
- "id": 0,
- "initialInvestment": 0,
- "instrumentShares": {
- "property1": 0,
- "property2": 0
}, - "name": "string",
- "publicUrl": "string"
}
}Fetches a pies for the account with detailed information
OK
Bad API key
Scope( pies:read ) missing for API key
Timed-out
Limited: 1 / 5s
{- "instruments": [
- {
- "currentShare": 0,
- "expectedShare": 0,
- "issues": [
- {
- "name": "DELISTED",
- "severity": "IRREVERSIBLE"
}
], - "ownedQuantity": 0,
- "result": {
- "priceAvgInvestedValue": 0,
- "priceAvgResult": 0,
- "priceAvgResultCoef": 0,
- "priceAvgValue": 0
}, - "ticker": "string"
}
], - "settings": {
- "creationDate": "2019-08-24T14:15:22Z",
- "dividendCashAction": "REINVEST",
- "endDate": "2019-08-24T14:15:22Z",
- "goal": 0,
- "icon": "string",
- "id": 0,
- "initialInvestment": 0,
- "instrumentShares": {
- "property1": 0,
- "property2": 0
}, - "name": "string",
- "publicUrl": "string"
}
}Updates a pie for the account by given params
OK
Bad update request
Bad API key
Scope( pies:write ) missing for API key
Timed-out
Limited: 1 / 5s
{- "dividendCashAction": "REINVEST",
- "endDate": "2019-08-24T14:15:22Z",
- "goal": 0,
- "icon": "string",
- "instrumentShares": {
- "AAPL_US_EQ": 0.5,
- "MSFT_US_EQ": 0.5
}, - "name": "string"
}{- "instruments": [
- {
- "currentShare": 0,
- "expectedShare": 0,
- "issues": [
- {
- "name": "DELISTED",
- "severity": "IRREVERSIBLE"
}
], - "ownedQuantity": 0,
- "result": {
- "priceAvgInvestedValue": 0,
- "priceAvgResult": 0,
- "priceAvgResultCoef": 0,
- "priceAvgValue": 0
}, - "ticker": "string"
}
], - "settings": {
- "creationDate": "2019-08-24T14:15:22Z",
- "dividendCashAction": "REINVEST",
- "endDate": "2019-08-24T14:15:22Z",
- "goal": 0,
- "icon": "string",
- "id": 0,
- "initialInvestment": 0,
- "instrumentShares": {
- "property1": 0,
- "property2": 0
}, - "name": "string",
- "publicUrl": "string"
}
}Duplicates a pie for the account
OK
Bad update request
Bad API key
Scope( pies:write ) missing for API key
Timed-out
Limited: 1 / 5s
{- "icon": "string",
- "name": "string"
}{- "instruments": [
- {
- "currentShare": 0,
- "expectedShare": 0,
- "issues": [
- {
- "name": "DELISTED",
- "severity": "IRREVERSIBLE"
}
], - "ownedQuantity": 0,
- "result": {
- "priceAvgInvestedValue": 0,
- "priceAvgResult": 0,
- "priceAvgResultCoef": 0,
- "priceAvgValue": 0
}, - "ticker": "string"
}
], - "settings": {
- "creationDate": "2019-08-24T14:15:22Z",
- "dividendCashAction": "REINVEST",
- "endDate": "2019-08-24T14:15:22Z",
- "goal": 0,
- "icon": "string",
- "id": 0,
- "initialInvestment": 0,
- "instrumentShares": {
- "property1": 0,
- "property2": 0
}, - "name": "string",
- "publicUrl": "string"
}
}Place, monitor, and cancel equity trade orders. This section provides the core functionality for programmatically executing your trading strategies for stocks and ETFs.
Retrieves a list of all orders that are currently active (i.e., not yet filled, cancelled, or expired). This is useful for monitoring the status of your open positions and managing your trading strategy.
OK
Bad API key
Scope( orders:read ) missing for API key
Timed-out
Limited: 1 / 5s
[- {
- "creationTime": "2019-08-24T14:15:22Z",
- "extendedHours": true,
- "filledQuantity": 0,
- "filledValue": 0,
- "id": 0,
- "limitPrice": 0,
- "quantity": 0,
- "status": "LOCAL",
- "stopPrice": 0,
- "strategy": "QUANTITY",
- "ticker": "AAPL_US_EQ",
- "type": "LIMIT",
- "value": 0
}
]Creates a new Limit order, which executes at a specified price or better.
quantity. The order will fill at the limitPrice or lower.quantity. The order will fill at the limitPrice or higher.Important: In this beta version, this endpoint is not idempotent. Sending the same request multiple times may result in duplicate orders.
OK
Failed validation
Bad API key
Scope( orders:execute ) missing for API key
Timed-out
Limited: 1 / 2s
{- "limitPrice": 100.23,
- "quantity": 0.1,
- "ticker": "AAPL_US_EQ",
- "timeValidity": "DAY"
}{- "creationTime": "2019-08-24T14:15:22Z",
- "extendedHours": true,
- "filledQuantity": 0,
- "filledValue": 0,
- "id": 0,
- "limitPrice": 0,
- "quantity": 0,
- "status": "LOCAL",
- "stopPrice": 0,
- "strategy": "QUANTITY",
- "ticker": "AAPL_US_EQ",
- "type": "LIMIT",
- "value": 0
}Creates a new Market order, which is an instruction to trade a security immediately at the next available price.
To place a buy order, use a positive quantity.
To place a sell order, use a negative quantity.
extendedHours: Set to true to allow the order to be filled outside of the standard trading session.
If placed when the market is closed, the order will be queued to execute when the market next opens.
Warning: Market orders can be subject to price slippage, where the final execution price may differ from the price at the time of order placement.
Important: In this beta version, this endpoint is not idempotent. Sending the same request multiple times may result in duplicate orders.
OK
Failed validation
Bad API key
Scope( orders:execute ) missing for API key
Timed-out
Limited: 50 / 1m0s
{- "extendedHours": true,
- "quantity": 0.1,
- "ticker": "AAPL_US_EQ"
}{- "creationTime": "2019-08-24T14:15:22Z",
- "extendedHours": true,
- "filledQuantity": 0,
- "filledValue": 0,
- "id": 0,
- "limitPrice": 0,
- "quantity": 0,
- "status": "LOCAL",
- "stopPrice": 0,
- "strategy": "QUANTITY",
- "ticker": "AAPL_US_EQ",
- "type": "LIMIT",
- "value": 0
}Creates a new Stop order, which places a Market order once the stopPrice is reached.
To place a buy stop order, use a positive quantity.
To place a sell stop order (commonly a 'stop-loss'), use a negative quantity.
The stopPrice is triggered by the instrument's Last Traded Price (LTP).
Important: In this beta version, this endpoint is not idempotent. Sending the same request multiple times may result in duplicate orders.
OK
Failed validation
Bad API key
Scope( orders:execute ) missing for API key
Timed-out
Limited: 1 / 2s
{- "quantity": 0.1,
- "stopPrice": 100.23,
- "ticker": "AAPL_US_EQ",
- "timeValidity": "DAY"
}{- "creationTime": "2019-08-24T14:15:22Z",
- "extendedHours": true,
- "filledQuantity": 0,
- "filledValue": 0,
- "id": 0,
- "limitPrice": 0,
- "quantity": 0,
- "status": "LOCAL",
- "stopPrice": 0,
- "strategy": "QUANTITY",
- "ticker": "AAPL_US_EQ",
- "type": "LIMIT",
- "value": 0
}Creates a new Stop-Limit order, combining features of a Stop and a Limit order. The direction of the trade (buy/sell) is determined by the sign of the quantity field.
Execution Logic:
stopPrice, the order is triggered.limitPrice.This two-step process helps protect against price slippage that can occur with a standard Stop order.
Important: In this beta version, this endpoint is not idempotent. Sending the same request multiple times may result in duplicate orders.
OK
Failed validation
Bad API key
Scope( orders:execute ) missing for API key
Timed-out
Limited: 1 / 2s
{- "limitPrice": 100.23,
- "quantity": 0.1,
- "stopPrice": 100.23,
- "ticker": "AAPL_US_EQ",
- "timeValidity": "DAY"
}{- "creationTime": "2019-08-24T14:15:22Z",
- "extendedHours": true,
- "filledQuantity": 0,
- "filledValue": 0,
- "id": 0,
- "limitPrice": 0,
- "quantity": 0,
- "status": "LOCAL",
- "stopPrice": 0,
- "strategy": "QUANTITY",
- "ticker": "AAPL_US_EQ",
- "type": "LIMIT",
- "value": 0
}Attempts to cancel an active, unfilled order by its unique ID. Cancellation is not guaranteed if the order is already in the process of being filled. A successful response indicates the cancellation request was accepted.
OK
Not available for real money accounts
Bad API key
Scope( orders:execute ) missing for API key
Order not found
Timed-out
Limited: 50 / 1m0s
Retrieves a single pending order using its unique numerical ID. This is useful for checking the status of a specific order you have previously placed.
Order found
Bad API key
Scope( orders:read ) missing for API key
Order not found
Timed-out
Limited: 1 / 1s
{- "creationTime": "2019-08-24T14:15:22Z",
- "extendedHours": true,
- "filledQuantity": 0,
- "filledValue": 0,
- "id": 0,
- "limitPrice": 0,
- "quantity": 0,
- "status": "LOCAL",
- "stopPrice": 0,
- "strategy": "QUANTITY",
- "ticker": "AAPL_US_EQ",
- "type": "LIMIT",
- "value": 0
}Access fundamental information about your trading account. Retrieve details such as your account ID, currency, and current cash balance.
Provides a detailed breakdown of your account's cash and investment metrics, including available funds, invested capital, and total account value.
OK
Bad API key
Scope( account ) missing for API key
Timed-out
Limited: 1 / 2s
{- "blocked": 0,
- "free": 0,
- "invested": 0,
- "pieCash": 0,
- "ppl": 0,
- "result": 0,
- "total": 0
}Retrieves fundamental information about your trading account, such as your primary account number and its base currency.
OK
Bad API key
Scope( account ) missing for API key
Timed-out
Limited: 1 / 30s
{- "currencyCode": "USD",
- "id": 0
}View the current state of your portfolio. Get a real-time overview of all your open positions, including quantity, average price, and current profit or loss.
Fetch an open positions for your account
OK
Bad API key
Scope( portfolio ) missing for API key
Timed-out
Limited: 1 / 5s
[- {
- "averagePrice": 0,
- "currentPrice": 0,
- "frontend": "API",
- "fxPpl": 0,
- "initialFillDate": "2019-08-24T14:15:22Z",
- "maxBuy": 0,
- "maxSell": 0,
- "pieQuantity": 0,
- "ppl": 0,
- "quantity": 0,
- "ticker": "AAPL_US_EQ"
}
]Search for a open position by ticker
OK
Invalid ticker supplied
Bad API key
Scope( portfolio ) missing for API key
No open position with that ticker
Timed-out
Limited: 1 / 1s
{- "ticker": "string"
}{- "averagePrice": 0,
- "currentPrice": 0,
- "frontend": "API",
- "fxPpl": 0,
- "initialFillDate": "2019-08-24T14:15:22Z",
- "maxBuy": 0,
- "maxSell": 0,
- "pieQuantity": 0,
- "ppl": 0,
- "quantity": 0,
- "ticker": "AAPL_US_EQ"
}Fetch an open position by ticker
OK
Invalid ticker supplied
Bad API key
Scope( portfolio ) missing for API key
No open position with that ticker
Timed-out
Limited: 1 / 1s
{- "averagePrice": 0,
- "currentPrice": 0,
- "frontend": "API",
- "fxPpl": 0,
- "initialFillDate": "2019-08-24T14:15:22Z",
- "maxBuy": 0,
- "maxSell": 0,
- "pieQuantity": 0,
- "ppl": 0,
- "quantity": 0,
- "ticker": "AAPL_US_EQ"
}Discover what you can trade. These endpoints provide comprehensive lists of all tradable instruments and the exchanges they belong to, including details like tickers and trading hours.
Fetch all exchanges and their corresponding working schedules that your account has access to
OK
Bad API key
Scope( metadata ) missing for API key
Timed-out
Limited: 1 / 30s
[- {
- "id": 0,
- "name": "string",
- "workingSchedules": [
- {
- "id": 0,
- "timeEvents": [
- {
- "date": "2019-08-24T14:15:22Z",
- "type": "OPEN"
}
]
}
]
}
]Fetch all instruments that your account has access to
OK
Bad API key
Scope( metadata ) missing for API key
Timed-out
Limited: 1 / 50s
[- {
- "addedOn": "2019-08-24T14:15:22Z",
- "currencyCode": "USD",
- "isin": "string",
- "maxOpenQuantity": 0,
- "name": "string",
- "shortName": "string",
- "ticker": "AAPL_US_EQ",
- "type": "ETF",
- "workingScheduleId": 0
}
]Review your account's trading history. Access detailed records of past orders, dividend payments, and cash transactions, or generate downloadable CSV reports for analysis and record-keeping.
OK
Bad filtering arguments
Bad API key
Scope( history:orders ) missing for API key
Timed-out
Limited: 6 / 1m0s
{- "items": [
- {
- "dateCreated": "2019-08-24T14:15:22Z",
- "dateExecuted": "2019-08-24T14:15:22Z",
- "dateModified": "2019-08-24T14:15:22Z",
- "executor": "API",
- "extendedHours": true,
- "fillCost": 0,
- "fillId": 0,
- "fillPrice": 0,
- "fillResult": 0,
- "fillType": "TOTV",
- "filledQuantity": 0,
- "filledValue": 0,
- "id": 0,
- "limitPrice": 0,
- "orderedQuantity": 0,
- "orderedValue": 0,
- "parentOrder": 0,
- "status": "LOCAL",
- "stopPrice": 0,
- "taxes": [
- {
- "fillId": "string",
- "name": "COMMISSION_TURNOVER",
- "quantity": 0,
- "timeCharged": "2019-08-24T14:15:22Z"
}
], - "ticker": "string",
- "timeValidity": "DAY",
- "type": "LIMIT"
}
], - "nextPagePath": "string"
}OK
Bad filtering arguments
Bad API key
Scope( history:dividends ) missing for API key
Timed-out
Limited: 6 / 1m0s
{- "items": [
- {
- "amount": 0,
- "amountInEuro": 0,
- "grossAmountPerShare": 0,
- "paidOn": "2019-08-24T14:15:22Z",
- "quantity": 0,
- "reference": "string",
- "ticker": "string",
- "type": "string"
}
], - "nextPagePath": "string"
}Retrieves a list of all requested CSV reports and their current status.
Asynchronous Workflow:
POST /history/exports to request a report. You will receive a reportId.GET /history/exports) to check the status of the report corresponding to your reportId.Finished, the downloadLink field will contain a URL to download the CSV file.OK
Bad filtering arguments
Bad API key
Missing Permissions
Timed-out
Limited: 1 / 1m0s
[- {
- "dataIncluded": {
- "includeDividends": true,
- "includeInterest": true,
- "includeOrders": true,
- "includeTransactions": true
}, - "downloadLink": "string",
- "reportId": 0,
- "status": "Queued",
- "timeFrom": "2019-08-24T14:15:22Z",
- "timeTo": "2019-08-24T14:15:22Z"
}
]Initiates the generation of a CSV report containing historical account data. This is an asynchronous operation. The response will include a reportId which you can use to track the status of the generation process using the GET /history/exports endpoint.
OK
Bad filtering arguments
Bad API key
Missing Permissions
Timed-out
Limited: 1 / 30s
{- "dataIncluded": {
- "includeDividends": true,
- "includeInterest": true,
- "includeOrders": true,
- "includeTransactions": true
}, - "timeFrom": "2019-08-24T14:15:22Z",
- "timeTo": "2019-08-24T14:15:22Z"
}{- "reportId": 0
}Fetch superficial information about movements to and from your account
OK
Bad filtering arguments
Bad API key
Scope( history:transactions ) missing for API key
Timed-out
Limited: 6 / 1m0s
{- "items": [
- {
- "amount": 0,
- "dateTime": "2019-08-24T14:15:22Z",
- "reference": "string",
- "type": "WITHDRAW"
}
], - "nextPagePath": "string"
}