weatherstack: an Amazing Weather API

By (Sponsor)  on  

One of my first tasks each day is checking the weather; it's a necessity for knowing what my children and I should wear, if I'm going to need to water the lawn or need to shovel snow, and if I can take meetings out on my patio. It's also been one of my worst web experiences because is slow, difficult to navigate, and plastered with dozens of trackers and advertisements. Luckily I recently discovered an API so I can create my own weather dashboard with the WeatherStack API.

Quick Hits

  • Free to start!
  • Global weather information with one easy to use API
  • Get both realtime, historical, and forecast weather data
  • Sample code for implementing the API in Ruby, Node.js, Go, Python, PHP, and even jQuery
  • Trusted by 75,000 companies including Microsoft and Warner Brothers
  • From the creators of currencylayer, ipstack, mailboxlayer, and more rock solid APIs

Start by signing up for free -- you'll immediately be provided an API token to use, as well as get detailed API instructions for usage.

Basic Usage

To get the realtime weather data for a given location, make a simple API call with the language and method of your choice:

// Getting weather by postal code in Fahrenheit

You will receive a wealth of information in the response:

      "localtime":"2019-09-14 14:25",
      "observation_time":"07:25 PM",
         "Partly cloudy"

You can specify location by city name, latitude/longitude, postal code, IP address, or even Geolocation via the fetch:ip option.

You can also get weather information for multiple locations with on request by separating separate locations with a ;; you'll receive an array of objects representing each location.

Units and Languages

weatherstack also allows developers to specify language and units. Imagine being French and arriving in the United States. Ideally you want the weather information in your local language (French) in and units you understand (Celcius, kilometers, etc.). Add the following parameters to your request:

// Getting weather in French and metric system
    &query=New York

The response payload will provide temperature in Celcius, wind in kilometers, precipitation in millimeters, and snow in centimeters. Letting weatherstack do the localization for you (and your users) is a huge task you don't need to worry about!

Historical Weather

If you would like historical weather information for a given location and date, hit the /historical endpoint:

// Weather from last July 5th in hour increments

The historical endpoint allows a single past date or multiple dates separated by ; via the historical_date method.

The historical endpoint also offers two new options: hourly and interval. hourly values are 1 (on) or 0 (off) values which specify if you'd like hourly weather information. The interval represents the hour increments you'd like values for (1, 3, 6, 12, and 24).


A very typical use case is wanting to know a weeks worth of weather outlook. For that you can hit the /forecast API endpoint. The important parameter when using the forecast endpoint is forecast_days, with the maximum value being 14.

// Weather for the next 14 days

All of the previously mentioned parameters can be used for the forecast API!

weatherstack is just another amazing API from apilayer. You can always count on them to keep the API simple and reliable, and coupled with their numerous other APIs, you can create an insanely personalized experience for your users. If you want to provide an awesome weather experience for your users, try weatherstack!


    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!