Access fundamental information about your trading account. Retrieve details such as your account ID, currency, and current cash balance.
Trading212 Public API (v0)
Welcome to the official API reference 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.
The API described here is enabled and usable only for Invest and Stocks ISA account types.
We provide two distinct environments for development and trading:
Paper Trading (Demo):
https://demo.trading212.com/api/v0Live Trading (Real Money):
https://live.trading212.com/api/v0
You 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 for any order placement:
Supported account types: The Trading 212 Public API is enabled and usable only for Invest and Stocks ISA account types.
Live trading order types: For the live (real money) environment, only Market Orders are supported for execution via the API.
Order execution: Orders can be executed only in the primary account currency
Multi-currency: Multi-currency accounts are not currently supported through the API. Meaning your account, position and result values in the responses will be in the primary account currency.
Authentication: Every request to the API must be authenticated using a secure key pair. See the Authentication section below for details.
Rate Limiting: All API calls are subject to rate limits to ensure fair usage and stability. See the Rate Limiting section for a full explanation.
IP Restrictions: For enhanced security, you can optionally restrict your API keys to a specific set of IP addresses from within your Trading 212 account settings.
Selling Orders: To execute a sell order, you must provide a negative value for the
quantityparameter (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 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" \
-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 .
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:
Make a burst of all 50 requests in the first 5 seconds of a minute. You would then need to wait for the reset time indicated by the
x-ratelimit-resetheader before making more requests.Pace your requests evenly, for example, by making one call every 1.2 seconds, ensuring you always stay within the limit.
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.
All list endpoints in the API that return a collection of items (such as historical orders, dividends, and transactions) use cursor-based pagination to handle large data sets.
limit(integer): Specifies the maximum number of items to return in a single request.- Default: 20
- Maximum: 50
cursor(string | number): A pointer to a specific item in the dataset. This tells the API where to start the next page of results.
The easiest way to paginate is by using the nextPagePath field returned in the response.
- Make your initial request to a list endpoint (e.g.,
/api/v0/equity/history/orders) with an optionallimitparameter. Do not include acursor. - The API will return a response object. This object will contain a list of
itemsand anextPagePathfield. - If the
nextPagePathfield isnull, you have reached the end of the data, and there are no more pages. - If
nextPagePathis notnull, use the entire string value ofnextPagePathas the path for your next request. This string contains all the necessary parameters (likelimitandcursor) to get the next page. - Repeat this process until
nextPagePathisnull.
Here is a step-by-step example of fetching all transactions, 2 at a time.
Request 1: Get the first page
curl -X GET "https://demo.trading212.com/api/v0/equity/history/orders?limit=2" \
-u "API_KEY:API_SECRET"Response 1: Note the nextPagePath
{
"items": [
{ "id": 987654321, "ticker": "AAPL_US_EQ", ... },
{ "id": 987654320, "ticker": "MSFT_US_EQ", ... }
],
"nextPagePath": "/api/v0/equity/history/orders?limit=2&cursor=1760346100000"
}Request 2: Use the full nextPagePath for the next request
curl -X GET "https://demo.trading212.com/api/v0/equity/history/orders?limit=2&cursor=1760346100000" \
-u "API_KEY:API_SECRET"Response 2: Get the next page (and a new nextPagePath)
{
"items": [
{ "id": 987654319, "ticker": "AAPL_US_EQ", ... },
{ "id": 987654320, "987654318": "MSFT_US_EQ", ... }
],
"nextPagePath": "/api/v0/equity/history/orders?limit=2&cursor=1660015723000"
}Request 3: Get the final page
curl -X GET "https://demo.trading212.com/api/v0/equity/history/orders?limit=2&cursor=1660015723000" \
-u "API_KEY:API_SECRET"Response 3: nextPagePath is null, indicating the end
{
"items": [
{ "id": 987654317, "ticker": "AMZN_US_EQ", ... }
],
"nextPagePath": null
}Here are some additional resources that you may find helpful.
Trading 212 Community Forum - A great place to ask questions and share what you've built.
- https://demo.trading212.com/api/v0/equity/metadata/exchanges
- https://live.trading212.com/api/v0/equity/metadata/exchanges
- curl
- Go
- Python
- Node.js
- Java
curl -i -X GET \
-u <username>:<password> \
https://demo.trading212.com/api/v0/equity/metadata/exchanges \
-H 'Authorization: YOUR_API_KEY_HERE'[ { "id": 0, "name": "string", "workingSchedules": [ … ] } ]
- https://demo.trading212.com/api/v0/equity/metadata/instruments
- https://live.trading212.com/api/v0/equity/metadata/instruments
- curl
- Go
- Python
- Node.js
- Java
curl -i -X GET \
-u <username>:<password> \
https://demo.trading212.com/api/v0/equity/metadata/instruments \
-H 'Authorization: YOUR_API_KEY_HERE'[ { "addedOn": "2019-08-24T14:15:22Z", "currencyCode": "USD", "extendedHours": true, "isin": "string", "maxOpenQuantity": 0, "name": "string", "shortName": "string", "ticker": "AAPL_US_EQ", "type": "ETF", "workingScheduleId": 0 } ]
Orders
⚠️ Order Limitations
Orders can be executed only in the main account currency
Only Market Orders are supported for the live (real money) environment
Place, monitor, and cancel equity trade orders. This section provides the core functionality for programmatically executing your trading strategies for stocks and ETFs.
Pies (Deprecated)
Manage your investment Pies. Use these endpoints to create, view, update, and delete your custom portfolios, making automated and diversified investing simple.
Deprecation notice: The current state of the Pies API, while still operational, won't be further supported and updated.