New Equity Trading API in Beta - Try it Out in Practice Mode!

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.

1 Like

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:

  1. Sending request to the live URL
  2. Permissions for the API key (under my ISA account, which holds a pie). I’ve created an API key with all permissions.
  3. 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.

1 Like

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