alpaca-trade-api-js
alpaca-trade-api-js copied to clipboard
[Question]: page_token is null instead of empty string
Question form pre-submit checklist.
- [X] I have searched the existing issues to ensure there isn't already an issue about this question.
- [X] My question has to do with the JS SDK and isn't a general question about the API. (If it is please open your issue here)
- [X] My question isn't about how to do a specific algorithm or asking for trade advice (answers to these are outside the scope of this repo).
Question
For some reason I can't make a request. I look at the SDK and it seems like the problem is in wrong default value for page_token param in this line.
For me it works well with an empty string but doesn't work with null as default.
I mean the difference between request like this:
curl --location --request GET 'https://data.sandbox.alpaca.markets/v2/stocks/AAPL/bars?limit=2&page_token=null&timeframe=30Min&start=2020-04-01&end=2021-04-02' \
> --header 'Authorization: Basic TOKEN'
and that:
curl --location --request GET 'https://data.sandbox.alpaca.markets/v2/stocks/AAPL/bars?limit=2&page_token=&timeframe=30Min&start=2020-04-01&end=2021-04-02' \
> --header 'Authorization: Basic TOKEN'
Maybe I missed something, then please, point me out.
Sorry, I was wrong. The issue not in page_token but in authorization. For me it works only with basic authorization (like in example I provided above), but passing APCA-API-KEY-ID, APCA-API-SECRET-KEY doesn't work for me and I got "forbidden" error. What did I miss?
Hi @mrjazz
If you got the forbidden
error it means that your subscription doesn't let you query the requested data. Are you sure you wanted to call the sandbox endpoint?
Since this question is really old I am closing it but please feel free to open a new one if you have any further question.
Have a nice day 🌞