API Keys In Exercises Not Working

Hello, I’m having trouble with the API key working on an assignment. I think it is the key that’s the issue and not the code, which I explain below.

COURSE - Data I/O and Preprocessing with Python and SQL

MODULES - 2, 3

EXERCISES - Identifying Vulnerable Communities using the U.S. Census API, and NYC Restaurant Inspections

ISSUE - In the US Census exercise 1a, you load the API Key variable, then print the status code.

However, the status code returns only a 404.

I ran a snippet to detect the API key, and as shown in the screenshot, there is a key, but it is throwing a 404 error.

If the API Key that the course provides isn’t working, I think it needs to be refreshed by Coursera.

I ran into the same error code for the API in the NYC Restaurant Inspections exercise.

[staff edit: removed solution]

Hi. This is a mismatch in the instructions. Please use api_key instead of key when defining the params. That should be the default in the boilerplate code. We’ll update the instructions and hints to mention it as well. Thank you for pointing this out!

Got it, thank you!

Hello, can you look at the api key setup in the NYC Restaurant Inspections exercise for Module 4? I think it’s having a similar issue. Specifically, Exercise 2 is not running correctly.

I tried using “api_key” as a fix, but it still errored out.

The error I got was
HTTPSConnectionPool(host=‘2eraiuh.dl.ai.link’, port=443): Max retries exceeded … (Caused by SSLError: UNEXPECTED_EOF_WHILE_READING)

Hi. It’s working fine on my end. It expects api_key like in the boilerplate. That might be a temporary error. You can also try resetting your workspace just to make sure you didn’t accidentally overwrite non-graded code when you were trying to troubleshoot before. But let us know if it persists.

Hi Chris,

Unfortunately, I’ve updated my code to use api_key in the parameters like you suggested, but I’m still having an issue with Exercise 2. When I run the cell it throws an error of “SSLEOFError”.

The snippet I used was:

API_KEY = os.getenv(“RESTAURANTS_API_KEY”)

Define the parameters for the API request (setting up “key” as instructed)

params = {“api_key”: API_KEY, “limit”: 1000}

END CODE HERE

Further down in the error code, and one of the parts in red text is below. Does that mean there’s something wrong with the system timing or date, and could that be why I’m getting the error?

"f"System time is way off (before {RECENT_DATE}). This will probably "

Hi. Please send me your notebook via direct message. We’ll look into it tomorrow at the start of the week and update you asap. Thanks.

Sent!

Hi. It seems you modified code outside the START CODE HERE and END CODE HERE tags. That’s the main cause of the error (in particular, the url_info). You can refresh your workspace following the instructions here to get a blank copy of the assignment. From there, only modify code inside those tags to avoid unexpected errors. Hope this helps.

Confirming that worked :+1:

Great! Thanks for the update. Closing this topic now because the issue is resolved.