fhqvst / avanza

A JavaScript client for the unofficial Avanza API
MIT License
229 stars 59 forks source link

Mobile paths changed #99

Open cfh-se opened 1 year ago

cfh-se commented 1 year ago

Hi, I just started using the library again after a year and it seems that many of the api paths are not available anymore. I tried to proxy my iOS requests to capture the mobile app urls but for some reason I cant do it on iOS 16. Does anyone else have the possibility to find the new urls?

frefor commented 1 year ago

Hi, Thanks for a great API. I got these urls to work. They are probably the same for mobile apps. I don't know much about the previous mobile urls but I'm guessing the data payload has changed quite a bit.


constants.paths.TOTP_PATH = '/_api/authentication/sessions/totp';

constants.paths.POSITIONS_PATH = '/_api/position-data/positions';
constants.paths.OVERVIEW_PATH = '/_api/account-performance/overview/total-values';
constants.paths.ORDERS_AND_DEALS_PATH = '/_api/trading/rest/allordersanddeals';
constants.paths.FUND_PATH = '/_api/fund-guide/guide/{0}';
constants.paths.INSTRUMENT_PATH = '/_api/market-guide/{0}/{1}';
constants.paths.SEARCH_PATH = '/_api/search/global-search';
constants.paths.TRANSACTIONS_PATH = '/_api/transactions';

constants.paths.ORDER_NEW_PATH = '/_api/trading-critical/rest/order/new';
constants.paths.ORDER_EDIT_PATH = '/_api/trading-critical/rest/order/modify';
constants.paths.ORDER_DELETE_PATH = '/_api/trading-critical/rest/order/delete';
constants.paths.ORDER_GET_PATH = '/_api/trading-critical/rest/order/find';

constants.paths.STOPLOSS_NEW_PATH = '/_api/trading-critical/rest/stoploss/new';
constants.paths.STOPLOSS_EDIT_PATH = '/_api/trading-critical/rest/stoploss/modify';
constants.paths.STOPLOSS_DELETE_PATH = '/_api/trading-critical/rest/stoploss/{0}/{1}';
constants.paths.STOPLOSS_GET_PATH = '/_api/trading-critical/rest/stoploss';```

Also attaching index.js which I modified a bit for my own needs.

[avanza.zip](https://github.com/fhqvst/avanza/files/11241581/avanza.zip)
jegt commented 7 months ago

I'm trying to use the new paths in my Elixir version of an Avanza client, and it does not respect my accept: application/json header. I get a bunch of HTML when requesting '/_api/account-performance/overview/total-values'.

Will we have to crawl the HTML to extract what we need now? Or do we need to make the requests look more like legit app requests? Properly setting user agents or stuff?

It works for me. I set both accept and content type to json and get json back.

simpers commented 7 months ago

I'm trying to use the new paths in my Elixir version of an Avanza client, and it does not respect my accept: application/json header. I get a bunch of HTML when requesting '/_api/account-performance/overview/total-values'. Will we have to crawl the HTML to extract what we need now? Or do we need to make the requests look more like legit app requests? Properly setting user agents or stuff?

It works for me. I set both accept and content type to json and get json back.

Yes, I had made a different mistake so it didn't compile properly to use the new endpoint. So my bad, and I am getting the JSON I expected now. That's why I deleted the comment hah

linus-skold commented 7 months ago

I'm getting a 302 http code, how did either of you solve that ?

simpers commented 7 months ago

I'm getting a 302 http code, how did either of you solve that ?

I did nothing special other than just swapping out the old URL for the new one. So if everything else is working for you, that should as well? I'm coding in Elixir though so I'm not using this client as I'm writing my own.

linus-skold commented 7 months ago

Strange, I will have to look into it a bit more then. Might be a user-agent issue or something else.