Skip to content
Advertisement

Converting cURL request to Python

I’m trying to turn this cURL request into a Python code. I want to eventually be able to save this to a CSV file but I need to get connected first.

JavaScript

I started with this:

JavaScript

The docs say this needs to be in the header:

JavaScript

How do I include the API key? how do I save the data once its returned?

Advertisement

Answer

X-Api-Key would be a request header, so you can include it in your headers variable, like this:

JavaScript

(took the others ones from your current curl request)

You can get the data by using r.text, like this:

JavaScript

Your code should look like this:

JavaScript

If you want to get a json object instead, you can use r.json()

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement