Skip to main content

Building on APIs

Let’s take the weather API from the previous page and create something useful. We’ll get weather data for the past 7 days, analyze it, visualize it, and save it. This brings together everything you’ve learned: APIs, data processing, file handling, and visualization.
Install required libraries: pip install requests pandas matplotlib

Get 7 days of weather

The Open-Meteo API can give us historical data:

Load into pandas

Now let’s organize this data:
Output:

Visualize the data

Create a simple line chart:

Save to CSV

Let’s save our data for later use:

Complete example

Here’s everything together:

What you’ve accomplished

Look at what you just did:
  • Connected to a real API
  • Worked with dates and time
  • Processed data with pandas
  • Created a visualization
  • Handled files and folders
  • Saved your results
This is exactly how data analysis works in the real world!
Try modifying the code to get weather for your city. Find your coordinates at latlong.net.

Next steps

Ready to organize your code like a pro? Let’s learn proper project structure!

Practical Python

Build real programs with proper structure