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
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
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
Easiest way is with Guzzle.
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
private function postJSON($url, $payload)
{
$jar = CookieJar::fromArray(
[
'TRADING212_SESSION_LIVE' => $this->session
],
'trading212.com'
);
$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
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
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.
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 we will get in the new year
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
Hello.
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?
Selenium simulates users interactions, so I donât think it will be an issue