Does trading212 have an API?

I’m not familiar with Swagger so have no idea what to do.

the cookies expire in about 50 years. If you go through the lines, you can find an expiring date.
the only thing that makes a cookie invalid, is when you generate a new one. and that is happening if you refresh you´re login. so if you never login after you copied a cookie, it will work for years :wink:

I did so. but you can´t do it without running through a script (in my case) and that is nothing for a swagger docu.

it´s not very easy to use the cookie with a login script, but it is possible.

what is your´re plan, that you need an API?
possibly i can help you anouther way than swagger

It doesn’t expire with a new login. Well at least not for me. I login daily and the cookie I have in my script was pasted in about 4+ months ago.

It’s a bit of a security issue in my mind, as they should be being revoked or have a shorter expiry in case they got exposed.

ok then please give me you`re cookie :stuck_out_tongue:

but you could compare the old one from your script with a new one, generated today.
maybe you can find some differences and tell me them. a constant working cookie would be very nice :blush:

Easiest way is with Guzzle.

Screenshot 2020-11-20 at 14.40.04

use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
	private function postJSON($url, $payload)

        $jar = CookieJar::fromArray(
                'TRADING212_SESSION_LIVE' => $this->session

        $client = new Client(['cookies' => $jar]);

        $response = $client->post($url, ['json' => $payload,]);

        return json_decode($response->getBody());

Yeah the session I got just logging in is fresh, and it doesn’t kill previous sessions getting new ones. So once that SESSION_LIVE is pasted in it’ll last forever.

I was just maybe gonna play with it, see what’s exposed and maybe get inspired to come up with a plan. No worries, though; got enough on my plate without learning another framework :smiley:

ok thank you. i will check this out.

+1 for official REST API

hey alextee, you can check out my swagger. possibly it is helpful for you.
you can find it in this message thread

1 Like

An official REST API would be really useful.

I need read-only access for generating a stock tracker so I can have a consolidated view of my investments with additional information that Trading 212 doesn’t provide.


I subscribe. @kingrio how did you generate the swagger?

Would be so nice to get an (open to the public) API available in 2021 especially now that ProQuant has been closed. I believe PQ have proven that there is interest for algorithmic trading on T212 and this would open up more revenue streams for T212 so hopefully :pray: we will get in the new year :pleading_face:


What type of API are people expecting? stock prices? buy and sell stocks?

Am I the only one thinking that the Trading 212 API when it is available won’t be free? or maybe have different sub levels. I mean have you tried finding stock market data API, almost all of them offer a very basic tier of limits per day and even to get a decent level you need to pay £10 a month or even up to £1000 a month for a realtime one. Anything free would be subject to abuse possibly.

Well “GET” should be free imho. “POST” ,“PUT” might be behind pay wall.

yeah let’s hope there is some kind of free access, I think it will probably be like any other API with a ‘play’ level of access for free and anything else pay wall. I’ve just looked and interactive brokers have an API and there are multiple types of API access but it’s hard to find out what they actually cost, the market data has loads of different prices for different markets, if anyone wants to help me decipher it the link is below.

general API home:

market data cost:

realtime quotes and even detailed historical data is expensive and even very expensive api’s have rate limits (naturally)

I have posted following a while ago

trial and error :man_mechanic:


I didn’t see any official Trading212 API. I want to build my own bot with Selenium to place automated trades. If you don’t know what Selenium is, it’s a python framework that is used in website testing. It performs manual tasks but much faster than a human could. like I want to tell my bot to search for tesla in the search bar, click on the first result, click buy, place the amount and confirm.

This would take a human around 5-10 seconds to perform, but my bot could do it in 1-2 seconds.

Is there anything illegal/against the TOS for this?

1 Like

Selenium simulates users interactions, so I don’t think it will be an issue