Got a 403 Client Error: Forbidden url with the below Python program:
import pandas as pd
import alpaca_trade_api as tradeapi
api = tradeapi.REST(api_version=‘v2’)
result = api.get_barset(‘AAPL’, ‘minute’, start = ‘2021-01-28’, end = ‘2021-01-28’).df
print(result)
I also get the same error. get_bars or get_barset show the 403 error: “Forbidden for url: https://data.alpaca.markets…” alpaca.get_bars("AAPL", TimeFrame.Day, "2021-08-01", "2021-08-30", limit=10, adjustment='raw')
Somehow all other requests are working: alpaca.list_positions() or alpaca.get_account()
@Mirex A ‘Forbidden’ error is most likely one of three things 1) the API key/secret key are old or incorrect 2) the API key/secret key/ base url don’t align (eg one is using their paper API keys but accessing the live base url or 3) for market data one only has a Free subscription but is trying to access features only available in an “Unlimited” subscription.
Found out this a credentials key problem especially when installing a new set of keys after discarding some older ones. First I waited coupla minutes for new keys to populate, second I ensured the config file etc was properly copied new keys. Saved the whole lot and completely shut down my jupyter notebook and restarted the programs. Worked. I believe the old keys remained in the system and needed to be purged completely.