I would also be interested in having the possibility to execute multiple limit orders in one go. Currently there is a 1 execution every 2 seconds limit. That’s fine but perhaps that one execution can be a list of executions? That would be really nice!
When will the query for symbol details be available? … to be able to retrieve data such as its market cap, beta, etc.
… I think it’s something very necessary.
Looking at where to put my ISA for 24/25. Can you confirm when the API will allow orders to be placed in real account and when/if it will be available in ISA.
Is this correct?
is the API available for the ISA account?
I can only see the API option within Invest.
Other posters indicate the ISA account isn’t supported.
The API is supported for Investment and ISA accounts. I am using it.
I’ve been using the API fine, retrieving the instruments and pie holdings from the investor account. I’ve then created an API key under the ISA account. I was able to fetch all pies fine and received the pie ID in the response. However, I then passed the pie ID to the fetch pie endpoint and it returns with a 400 and message “Pie not found”. I’ve tested on the API documentation and checked the following:
- Sending request to the live URL
- Permissions for the API key (under my ISA account, which holds a pie). I’ve created an API key with all permissions.
- The ID, which I copy and pasted from the “Fetch all pies” endpoint.
I’ve been able to do it fine and coding in Java from the investor account but i’m unable to retrieve the pie from the ISA. Seems like an issue with the API?
Thanks
Hi, I just tested out the API, and it looks very promising. One thing I think is critically missing from historical order data is the exchange rate at which the order was executed. Since we can see this information on the app’s orders page, I think it would make sense to be able to retrieve it from the API as well.
Each order has to include the exchange rate in the order statement anyway if it is in a foreign currency, so it would be logical to provide users with the information on which rate the order was executed.
Hi, I’m getting error 403 with the history api.
https://live.trading212.com/api/v0/equity/history/orders
Other endpoints are working fine. I have naturally recreated the api key ensuring I have the history option enabled but still getting the error. I’ve tried with python, nodejs and postman, all give me the same 403 (forbidden) error.
Can you please help
When I send this request:
curl -s -X GET 'https://live.trading212.com/api/v0/equity/
history/orders?limit=1&ticker=SPX5l_EQ&cursor=0' -H 'Authorization: XXX'
I get a reply like:
{
"items": [
{
"type": "MARKET",
"id": 123123123123123,
"fillId": 123123123123123,
"parentOrder": 123123123123123,
"ticker": "SPX5l_EQ",
"orderedQuantity": null,
"filledQuantity": null,
"limitPrice": null,
"stopPrice": null,
"timeValidity": null,
"orderedValue": 26900.000000,
"filledValue": 26900.000000,
"executor": "WEB",
"dateModified": "2024-05-10T07:37:52.000Z",
"dateExecuted": null,
"dateCreated": "2024-05-10T07:37:46.000Z",
"fillResult": null,
"fillPrice": 416.919900,
"fillCost": null,
"taxes": [],
"fillType": "OTC",
"status": "FILLED"
}
],
"nextPagePath": "/api/v0/equity/history/orders?cursor=XXX&limit=1&instrumentCode=SPX5l_EQ"
}
The order ID matches what I find in the web UI, but what’s missing from the API output is the “filled quantity” of 1.8391294 (for this order).
The £26900 in the JSON output is the full order amount, but this is just a partial fill, worth £766.77. But since neither £766.77 nor 1.8391294 appears in the JSON, I can’t even calculate one from the other using the fill price.
Maybe fillResult
or at least fillCost
should not be null
?
My home currency is GBP and I have a Euro account
I sold via the API on my practice Invest account 0.8442 of SXR8d_EQ which is priced in Euros
I was expecting the proceeds to be credited to my Euro account, but instead they were converted into GBP and I was charged a FX fee to convert the Euros into GBP
Is this a bug ?
Details of the transaction are =
{
“type”: “MARKET”,
“id”: 14050176477,
“fillId”: 14050176712,
“parentOrder”: 14050176477,
“ticker”: “SXR8d_EQ”,
“orderedQuantity”: -0.8442,
“filledQuantity”: -0.8442,
“limitPrice”: null,
“stopPrice”: null,
“timeValidity”: null,
“orderedValue”: null,
“filledValue”: null,
“executor”: “SYSTEM”,
“dateModified”: “2024-05-17T07:05:34.000Z”,
“dateExecuted”: null,
“dateCreated”: “2024-05-17T07:05:33.000Z”,
“fillResult”: null,
“fillPrice”: 513.8601,
“fillCost”: null,
“taxes”: ,
“fillType”: “OTC”,
“status”: “FILLED”
}
The API has been down for two days now. Can anyone tell me what’s going on?
Still not working 21/05/24 21:00 BST
To assist the programmers Error -
Status: 401 Unauthorized
Time: 765ms
Size: 1 B
Headers:
access-control-allow-origin:
*
cache-control:
max-age=0no-cacheno-store
connection:
keep-alive
content-length:
1
content-type:
text/plain; charset=utf-8
date:
Tue21 May 2024 19:58:46 GMT
expires:
Tue21 May 2024 19:58:46 GMT
pragma:
no-cache
strict-transport-security:
max-age=31536000 ; preload
x-content-type-options:
nosniff
x-envoy-upstream-service-time:
2
To get the api to work, generate a new api key, and use that instead
Never got any notification from Trading212 about this change
Realise that the api is in beta mode, and changes will happen, but would be nice to be kept informed
Problem with ordering by quantity
Via the api, I ordered a purchase 1.2547 shares of SXR8d_EQ and the system turned it into an order by value of €654.87 and instead purchased 1.2751572 shares
Order details -
{
"type": "MARKET",
"id": 14399986434,
"fillId": 14399986436,
"parentOrder": 14399986316,
"ticker": "SXR8d_EQ",
"orderedQuantity": null,
"filledQuantity": null,
"limitPrice": null,
"stopPrice": null,
"timeValidity": null,
"orderedValue": 654.87,
"filledValue": 654.87,
"executor": "WEB",
"dateModified": "2024-05-24T07:05:42.000Z",
"dateExecuted": null,
"dateCreated": "2024-05-24T07:05:41.000Z",
"fillResult": null,
"fillPrice": 513.5601,
"fillCost": null,
"taxes": [ ],
"fillType": "OTC",
"status": "FILLED"
},
Where do we report Api problems to
Do we have any details about updates to the historical orders API? It’s quite annoying that a year to fix a fairly basic programming issue is not enough.
@noop is it intentional that the operation/dividends endpoint does not include “equity” in its URL? The URL is without “v0/equity”, while other history endpoints are formatted as “https://live.trading212.com/api/v0/equity/history/orders”.
Additionally, I noticed an issue with the “nextPagePath” when a “ticker” is set for dividends. It returns "nextPagePath": "null&ticker=AAPL_US_EQ"
instead of simply being null
.
I also noticed that a dividend can be of type “DIVIDEND” which is not part of the enum listed on: #operation/dividends!c=200&path=items/type&t=response
Hey everyone, just wanted to let you know that we’re currently prioritising other core features. We plan to restart work on our API either late this year or early next year.
Following the API documentation, I see that I can request up to 50 transactions in one go. In the reply I get a nextPagePath
. It has a cursor (expected), limit (expected, same as original request), and then a valueless instrumentCode
. Not sure what that’s doing there.
Example:
[…]
"nextPagePath": "/api/v0/equity/history/orders?cursor=123456&limit=50&instrumentCode"
}
But when I use this nextPageToken. E.g. by using
curl -H "Authorization: $(cat creds)" \
https://live.trading212.com/api/v0/equity/history/orders?cursor=12345&limit=50
Then I always get an empty result. Valid JSON:
{"items": [], "nextPagePath": null}
What am I doing wrong? There should be more than 50 trading history items. I see more than 50 if I download a CSV, and I see specific missing trades. The newest 50 trades are there in the first request, but I can get nothing older than that.
If I only request 10 at a time, pagination does actually work, but I end up with only 34 entries.
Is historical orders API call some sort of best effort?
Hello Kris, these are the core features for me are:
- retrieve the historical stock info day by day: (Date,Open,High,Low,Close,Adj Close,Volume).
- retrieve the opening value of a stock during the day.
- retrieve the current value of a stock or (the closing value).
- buy and sell stocks with the same rules we can access through the app.
- IP whitelist for safety when connecting the API.
Personally I don’t need real time quotations. Having a delay of a few seconds is fine. I also do not need high throttling limits.