Get startedGet started for free

Making an API request

Forecasting systems start with a data pipeline that gathers new data from an API or other data source. So, it's essential that you know how to query an API to get data and put it into a format that can be easily worked with for downstream tasks such as exploratory data analysis, modeling, and database storage.

In this exercise, you'll write code that can be used to perform a GET request to the EIA API*.

*To complete the exercise, click Submit Answer. Do not run the main.py file, as an API key has not been correctly set and this will result in an error.

This exercise is part of the course

Forecasting in Practice

View Course

Exercise instructions

  • Create the api_url variable, setting equal to "https://api.eia.gov/v2/".
  • Add the eia_api_key to the end of the full_path variable.
  • Make a GET request to the full_path variable.
  • Create a pandas DataFrame from the data returned by the GET request.

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise