nickmccullum / algorithmic-trading-python

The repository for freeCodeCamp's YouTube course, Algorithmic Trading in Python
2.35k stars 2.37k forks source link

403 Error when pulling data from api #49

Open ramk01 opened 1 year ago

ramk01 commented 1 year ago

symbol="AAPL" api_url = f'https://sandbox.iexapis.com/stable/stock/{symbol}/quote/?token={IEX_CLOUD_API_TOKEN}'#base url

print(api_url)

data=requests.get(api_url) print(data.status_code)

Hi I am using this code to pull data but instead end up getting 403 error. Any solutions?

NTYDOLab commented 1 year ago

Solution:

  1. Open a https://iexcloud.io/ account a.Create a new account b.Go to Dashboard and copy "secret" from WORKSPACE API token. #https://iexcloud.io/console/home c.open Jupyter file secrets.py and paste your new "secret". #http://localhost:XXXX/tree/algorithmic-trading-python/starter_files d.retry pulling data.
anilegin commented 1 year ago

Solution:

  1. Open a https://iexcloud.io/ account a.Create a new account b.Go to Dashboard and copy "secret" from WORKSPACE API token. #https://iexcloud.io/console/home c.open Jupyter file secrets.py and paste your new "secret". #http://localhost:XXXX/tree/algorithmic-trading-python/starter_files d.retry pulling data.

still getting the 403 status code

johnpd commented 1 year ago

This works (get your public key and change your secrets.py (in my case I had to change secrets.py to api.py as it breaks numpy)

My workspace is called Algorithmic (you can call it anilegin as an example in the console you create it.

symbol = 'AAPL' api_url = f'https://ALGORITHMIC.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}' print(api_url) data = requests.get(api_url).json() print(data)

munirahd commented 1 year ago

better to follow the same steps as above

This works (get your public key and change your secrets.py (in my case I had to change secrets.py to api.py as it breaks numpy)

My workspace is called Algorithmic (you can call it anilegin as an example in the console you create it.

symbol = 'AAPL' api_url = f'https://ALGORITHMIC.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}' print(api_url) data = requests.get(api_url).json() print(data)

thank you your solution had helped so much .. however I advise to do the following this what worked for me

  1. Create a new account
  2. Go to Dashboard and copy "public key" from WORKSPACE API token.
  3. open Jupyter file secrets.py and paste your new key.
  4. paste API URL instead it mentioned in thier docs and it is the same data as the video https://cloud.iexapis.com/stable/stock/aapl/quote?token=YOUR_TOKEN_HERE
  5. restart the kernal and try to pull the data again

the link is displayed in their website

image
Shanu2092 commented 1 year ago

import requests

symbol = "AAPL"

IEX_CLOUD_API_TOKEN = "your_api_token_here" # replace with your actual API token

api_url = f'https://sandbox.iexapis.com/stable/stock/{symbol}/quote/?token=sk_47bb0c7b1acd49fe883ab7bde495b8b8' # base url

response = requests.get(api_url)

if response.status_code == 200: data = response.json() print(data) else: print(f"Error: {response.status_code}")

Still giving error 403

  1. Added new token from a new account
  2. Changed names,didnt work
  3. replaced token id with the token itself
yichenCY commented 1 year ago

But this one is real-time data which need to purchase after 7 days trial

rayna0921 commented 1 year ago

Solution:

  1. Open a https://iexcloud.io/ account a.Create a new account b.Go to Dashboard and copy "secret" from WORKSPACE API token. #https://iexcloud.io/console/home c.open Jupyter file secrets.py and paste your new "secret". #http://localhost:XXXX/tree/algorithmic-trading-python/starter_files d.retry pulling data.

and i change the sandbox into https://cloud.iexapis.com/, it worked then

kiet-doki commented 11 months ago

This works (get your public key and change your secrets.py (in my case I had to change secrets.py to api.py as it breaks numpy)

My workspace is called Algorithmic (you can call it anilegin as an example in the console you create it.

symbol = 'AAPL' api_url = f'https://ALGORITHMIC.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}' print(api_url) data = requests.get(api_url).json() print(data)

works for me! thanks a lot

Ni-zav commented 3 weeks ago

In my case there is no register new account button on the login/register page on IEX cloud, is there any help for this?

Surtur-Rising commented 2 weeks ago

In my case there is no register new account button on the login/register page on IEX cloud, is there any help for this?

I have the same issue and cannot make a new account but found this site

https://iexcloud.io/product-bulletin

They are ending their service and the data will be availibly from intrinio.com https://intrinio.com/iex-cloud