WeatherStack API: Get the Real-time Weather Data for Your Website or App


If you are developing an app or a website where you display or use weather data then the questions you would ask are:

From where to get the latest or historical weather data?

How to fetch data from the app or website?

The data we get is in the JSON format?

Is it fast?

All your questions lead to a single answer - WeatherStack API

WeatherStack API provides you accurate weather data for any location in the world in lightweight JSON format.

You can call WeatherStack API from your mobile app or website and fetch the current, historical and forecast weather data for any location worldwide.

WeatherStack is one of the most popular weather data REST API providers due to it's easy to use and data accuracy. It is trusted by 75000 companies including Deloitte, Microsoft, Warner Brothers, etc.

WeatherStack API Features:

  • Provides accurate real-time, historic and forecast weather data.
  • Provides hour-by-hour weather data for any location in the world.
  • Provides the response data in JSON format which makes it fast.
  • Supports different location identifiers e.g. by name, zip code, coordinates, IP Address.
  • Provides weather data in different units e.g. Celsius, Kelvin, Fahrenheit for temperature and Centimeter or Inch for snow.
  • Provides results in a total of 40 world languages.
  • Secured using industry-standard 256-bit HTTPS (SSL) encryption.
  • Powered by a strong backbone of data sources and so nearly 100% uptime.
  • Backed by scalable cloud infrastructure built and maintained by apilayer, capable of handling billions of requests per day.
  • Can be used in any server or client-side languages such as PHP, Python, Nodejs, jQuery, Go, or Ruby.

To use WeatherStack API in your app, start by signing up for free. Once signed up, you will immediately get your API access key. In order to authenticate, you will have to pass this API access key in each call to WeatherStack API. Simply use the base URL below and pass your API access key to the API's access_key parameter.

https://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=New York

https://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=New York

The above request would give the following JSON response:

{
    "request": {
        "type": "City",
        "query": "New York, United States of America",
        "language": "en",
        "unit": "m"
    },
    "location": {
        "name": "New York",
        "country": "United States of America",
        "region": "New York",
        "lat": "40.714",
        "lon": "-74.006",
        "timezone_id": "America/New_York",
        "localtime": "2019-09-07 08:14",
        "localtime_epoch": 1567844040,
        "utc_offset": "-4.0"
    },
    "current": {
        "observation_time": "12:14 PM",
        "temperature": 13,
        "weather_code": 113,
        "weather_icons": [
            "https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
        ],
        "weather_descriptions": [
            "Sunny"
        ],
        "wind_speed": 0,
        "wind_degree": 349,
        "wind_dir": "N",
        "pressure": 1010,
        "precip": 0,
        "humidity": 90,
        "cloudcover": 0,
        "feelslike": 13,
        "uv_index": 4,
        "visibility": 16
        }
}

Getting Historical Data

As mentioned before, the WeatherStack API also provides you historical data for any location.

To look up historical weather data all the way back to 2008, simply pass one date of your choice (later than July 2008) or multiple semicolon-separated dates to the weatherstack API's historical endpoint using the historical_date parameter, as shown below.

https://api.weatherstack.com/historical
    ?access_key = YOUR_ACCESS_KEY
    &query = New York
    &historical_date = 2015-01-21
    &hourly = 1

You can also get the data between the two dates using two parameters historical_date_start and historical_date_end, as shown below.

https://api.weatherstack.com/historical
    ?access_key = YOUR_ACCESS_KEY
    &query = New York
    &historical_date_start = 2015-01-21
    &historical_date_end = 2015-01-25

Getting Forecast Data

The weatherstack is capable of returning weather forecast data for up to 14 days into the future. To get weather forecasts, simply use the API's forecast and define your preferred number of forecast days using the forecast_days parameter.

https://api.weatherstack.com/forecast
    ?access_key = YOUR_ACCESS_KEY
    &query = New York
    &forecast_days = 1
    &hourly = 1

Visit WeatherStack documentation for more information.

So, WeatherStack is a simple and powerful API to get the weather data for any location. If you want to provide an awesome weather experience for your users, try weatherstack