Get Started with OpenWeatherMap APIs

Learn to access the OpenWeatherMap APIs, and about some important security considerations.

In this lesson, we’ll learn to create an account and generate the API key that’ll enable us to use the OpenWeatherMap APIs. However, before we make our first call to the API, let’s go over some important security considerations that we need to be mindful of while using the OpenWeatherMap APIs. We’ll also look at what we should do in case we exhaust our API call limit.

Please read the following guidelines carefully to use the API properly:

  • We should not use the server’s IP address to make free API calls. The only endpoint available for this purpose is api.openweathermap.org. However, we cannot use it for paid subscription plans. Once the subscription is activated, a different endpoint is duly communicated via email.
  • Whenever we make an API call, we must not send multiple requests to the API for a location in a 10-minute interval. This is due to the fact that the OpenWeather model only updates once every 10 minutes at max.
  • While some API endpoints support requests using location names, it is advised to use geographical coordinates to get a precise geocoding search result. The Geocoding API provides the geographical coordinates for a given location.
  • The permitted number of calls to the API depends on the subscription plan. In case our API call isn’t answered due to exceeding the maximum number of calls, we can repeat our request after 10 minutes. In such a scenario, we should not change the API request. This allows us to timely process it using the internal caching service.

In case we exceed the API call limit, our API key will not be suspended immediately. This is to ensure that there is no service interruption, and that our solutions remain stable. In this case, we’d also be notified by email with a recommendation to subscribe to one of the paid subscription plans that aligns with our needs. Our API key will be suspended if we do not respond. We could, however, resume the subscription by contacting the customer support teaminfo@openweathermap.org.

{
"cod": 429,
"message": "Your account is temporary blocked due to exceeding of requests limitation of your subscription type. Please choose the proper subscription http://openweathermap.org/price"
}

To use the OpenWeatherMap APIs, we need to create an account and retrieve our API key.

OpenWeatherMap APIs provide a number of subscriptions with varying functionalities to choose from depending on our requirements and usage. These subscription plans vary on the basis of the number of API calls allowed per minute. They also offer a wide range of products and features in addition to varying levels of service.

Note: Read more about the various subscription plans on offer here.

For this course, we’ll use the free subscription plan. However, you may opt for one of the paid subscription plans in case the free plan doesn’t meet your weather data requirements.

Create an account

Follow the steps below to create an account:

Step 1: Head over to this link and sign up to create an account.

Step 2: Fill out the account creation form, and click the “Create Account” button.

Step 3: For “Purpose,” select “Education/Science” and click the “Save” button. This will send an account confirmation email to your registered email address.

Step 4: Click the button given in the email to verify your email address. This will redirect you to a page with a confirmation message stating that your email has been verified.

Generate an API key

Next, let’s retrieve the API key that enables us to call the various endpoints of the OpenWeatherMap APIs.

Step 1: From the top menu bar, click on your username next to the “For Business” label and select “My API keys” from the dropdown list. This will redirect you to a page where you’ll see an API key named “Default.”

Note: You can use the default key or generate a new one. The key name is not important. Moreover, the API key may take up to a couple of hours to activate.

Step 2: Copy the key and click the “Edit” button in the widget below.

Step 3: Enter the key in the textbox for APP_ID and click the “Save” button.

Step 4: Click the “Run” to validate your APP_ID.

# Testing the API Key!