⬅️ [Previously] Account Setup: Creating an OpenWeather Account

<aside> 💡 [Beginner's Guide] If you're new to Python, click here to learn how to set up your development environment.

</aside>


In this chapter, we'll learn how to make API calls to extract current and forecasted weather data using the OpenWeather API.

🎬 Making our first API Calls

We will extract current and forecasted weather data from two different API endpoints:

Screenshot 2024-04-14 at 6.41.35 PM.png

To access the APIs we need to read their documentation. The documentations explain in detail how to use the APIs:

Selecting Locations

Based on the project requirements, we need to extract current and forecasted weather for five selected locations. Choose five locations and find their coordinates using a search engine (i.e. Google) by querying "{location} coordinates". For example, “Paris coordinates”.

Screenshot 2024-04-14 at 9.39.19 PM.png

Write down these coordinates because we will use them in our API calls. Save them in a Python dictionary, in a temporary Python file named temp.py (We will use the term ‘temporary’ for some files as we will remove them at the end, before deploying the code). We will use these coordinates later in the chapter:

File: temp.py

# Create a dictionary with the coordinates of 5 locations:
locations_dict = {
    'Thessaloniki, GR': {'lat': '40.6403', 'lon': '22.9439'},
    'Paris, FR': {'lat': '48.85341', 'lon': '2.3488'},
    'London, GB': {'lat': '51.50853', 'lon': '-0.12574'},
    'Dubai, AE': {'lat': '25.276987', 'lon': '55.296249'},
    'Los Angeles, US': {'lat': '34.0522', 'lon': '-118.2437'},
}