Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Sandbox Deprecated #47

Open
Indianapolis-Jones opened this issue Jan 6, 2023 · 12 comments
Open

Testing Sandbox Deprecated #47

Indianapolis-Jones opened this issue Jan 6, 2023 · 12 comments

Comments

@Indianapolis-Jones
Copy link

I am getting a 403 error when making API call for AAPL around minute 41 of the video. Is this because it is deprecated? Is there a work around?

@npomfret
Copy link

npomfret commented Jan 6, 2023

The sandbox is on more unfortunately. Also you will find part 3 of the course requires a paid version of the api sadly. But you can do the first two for free, just use base_url = 'https://cloud.iexapis.com'

@christianperera
Copy link

@npomfret @nickmccullum Love the course!! Unfortunately even when I use a new base_url = 'https://cloud.iexapis.com' I still get errors shown below. Anything I could try next?
image
image
image
This just happened - this section was working two days ago.

@npomfret
Copy link

npomfret commented Jan 9, 2023

Can you print out the http status code? Change your request to something like:

response = requests.get(api_url)
print(response.status_code).  <-- need to see this
data = response.json()

It should be 200.

@npomfret
Copy link

403 means Forbidden. You are making a request that is in one way not authorised. I think it's because you are using the sandbox which isn't allowed any more.

@djangovanderplas
Copy link

djangovanderplas commented Feb 11, 2023

Found a solution to this issue. I had the same issue also with the 403 code.

It seems like IEX Cloud has abandoned the system of API's mentioned in the video (docs also call it old now). You can find the new documentation at https://iexcloud.io/docs/. What I did was make an account with IEX Cloud (for free). This will give you access for 30 days to their API platform, should be enough for the course. On the upside: the data will be actual data and not the random data like in the old sandbox.

The new api-url looks like this:

api_url = f'https://api.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}'

And you have to replace the token in the secrets.py file with the private key from your account you just made.

My final code block looks like this:

api_url = f'https://api.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}'
response = requests.get(api_url)
print(response.status_code)
data = response.json()[0]
print(data)```

Now it gives a 200 code for me, hopefully it'll work for you too!
Edit: Also note that the data is now returned in a list, if you place [0] after the .json() you get the normal dictionary like in the code.

@itsmarcotime
Copy link

itsmarcotime commented Feb 16, 2023

@djangovanderplas have you made it to the Batch API Calls section yet?
image
I am able to print my batchApiCallUrl but when I run a .status_code on the url the response I get back is a 404 response. did you have this problem? or could there be something wrong with my url?

@senile-optimist
Copy link

Having issues making batch url. Tried playing around a little.
Tried the below as docs mention

Format:
GET /data/WORKSPACE/DATASET_A,DATASET_B/KEY_1,KEY_2

Tried doing this

payment_needed

402

which apparently is payment needed!!!

This sucks!!!

Someone suggest a hack if they have.

@johnpd
Copy link

johnpd commented Feb 23, 2023

Found a solution to this issue. I had the same issue also with the 403 code.

It seems like IEX Cloud has abandoned the system of API's mentioned in the video (docs also call it old now). You can find the new documentation at https://iexcloud.io/docs/. What I did was make an account with IEX Cloud (for free). This will give you access for 30 days to their API platform, should be enough for the course. On the upside: the data will be actual data and not the random data like in the old sandbox.

The new api-url looks like this:

api_url = f'https://api.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}'

And you have to replace the token in the secrets.py file with the private key from your account you just made.

My final code block looks like this:

api_url = f'https://api.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}'
response = requests.get(api_url)
print(response.status_code)
data = response.json()[0]
print(data)```

Now it gives a 200 code for me, hopefully it'll work for you too!
Edit: Also note that the data is now returned in a list, if you place [0] after the .json() you get the normal dictionary like in the code.

thanks for the tip regarding the json()[0]
my code now works with
data = requests.get(api_url).json()[0]

@inaG17
Copy link

inaG17 commented Mar 16, 2023

batch api url?

@senile-optimist
Copy link

@inaG17 batch api url mentioned in the pic in my comment throws 402 which says payment needed to make the api call

@Smogryd
Copy link

Smogryd commented Apr 2, 2023

For those who are stuck on the batch call, here's my code. (Definitely could be better, but i'm still a beginner)

#Parsing function shown on the video
def chunks(lst, n):
    for i in range(0, len(lst), n):
        yield lst[i:i+n]

#The actual batch call
symbol_groups = list(chunks(stocks['Ticker'], 100))
symbol_strings = []
for i in range(0, len(symbol_groups)):
    symbol_strings.append(','.join(symbol_groups[i]))

final_dataframe = pd.DataFrame(columns = my_columns)      
for symb_str in symbol_strings:
    batch_api_call_url = f'https://api.iex.cloud/v1/data/core/quote/{symb_str}?token={IEX_CLOUD_API_TOKEN}'
    data = requests.get(batch_api_call_url).json()
    
    for symb in symb_str.split(','):
        for d in data :
            if d['symbol'] == symb:
            	new_row = pd.Series([symb, d['latestPrice'], d['marketCap'], 'N/A'], index = my_columns)
        final_dataframe = pd.concat([final_dataframe,new_row.to_frame().T], ignore_index=True)
        
final_dataframe

@Hongyac
Copy link

Hongyac commented Apr 4, 2023

Found a solution to this issue. I had the same issue also with the 403 code.

It seems like IEX Cloud has abandoned the system of API's mentioned in the video (docs also call it old now). You can find the new documentation at https://iexcloud.io/docs/. What I did was make an account with IEX Cloud (for free). This will give you access for 30 days to their API platform, should be enough for the course. On the upside: the data will be actual data and not the random data like in the old sandbox.

The new api-url looks like this:

api_url = f'https://api.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}'

And you have to replace the token in the secrets.py file with the private key from your account you just made.

My final code block looks like this:

api_url = f'https://api.iex.cloud/v1/data/core/quote/{symbol}?token={IEX_CLOUD_API_TOKEN}'
response = requests.get(api_url)
print(response.status_code)
data = response.json()[0]
print(data)```

Now it gives a 200 code for me, hopefully it'll work for you too!
Edit: Also note that the data is now returned in a list, if you place [0] after the .json() you get the normal dictionary like in the code.

Just want to add that Public token of my new account also works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants