Weatherbit

Weatherbit

Weather

With our Weather API you can retrieve current weather observations from over 45,000 live weather stations, historical weather data for the past 10 years from our archive of more than 120,000 stations, and highly localized weather forecasts for any point on the globe using the world's most trusted weather models!

Visit APIπŸ” Alternatives

πŸ“š Documentation & Examples

Everything you need to integrate with Weatherbit

πŸš€ Quick Start Examples

Weatherbit Javascript Examplejavascript
// Weatherbit API Example
const response = await fetch('https://www.weatherbit.io/api', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Exploring Weatherbit API with JavaScript

Weatherbit API is a powerful tool that allows developers to access real-time and historical weather data for any location on earth. In this blog, we will explore some of the Weatherbit API endpoints and their usage using JavaScript programming language.

How to Get a Weatherbit API Key

Weatherbit requires a free API key for every request. To get one:

  1. Go to https://www.weatherbit.io/account/create and sign up for a free account.
  2. Confirm your email, then log in to your account dashboard.
  3. Copy the key shown under the API Keys section.

Free tier: The free "Weather API" plan allows 50 API calls per day and includes current weather plus 7-day/daily forecasts, for non-commercial use only. Hourly forecasts, historical data, and commercial use require a paid plan (see https://www.weatherbit.io/pricing).

The key is passed as a key query parameter on every request:

const apiKey = 'YOUR_API_KEY';
const url = `https://api.weatherbit.io/v2.0/current?city=New York,NY&key=${apiKey}`;

fetch(url)
  .then(res => res.json())
  .then(data => console.log(data.data[0].temp));

Note the historical weather endpoints shown in some older examples are not part of the free plan.

Current Weather

The Current Weather API endpoint returns the current weather conditions for a given location. Here is an example code in JavaScript that fetches the current weather information for New York City and logs it to the console:

const apiKey = 'YOUR_API_KEY';
const apiUrl = `https://api.weatherbit.io/v2.0/current?city=New%20York&country=USA&key=${apiKey}`;

async function getCurrentWeather() {
  const response = await fetch(apiUrl);
  const data = await response.json();
  console.log(data);
}

getCurrentWeather();

This code uses the fetch method to make a GET request to the Current Weather API endpoint. The async/await syntax is used to handle the asynchronous nature of the API request.

Historical Weather

The Historical Weather API endpoint returns the historical weather data for a given location and time range. Here is an example code in JavaScript that fetches the historical weather information for New York City during the month of June 2021 and logs it to the console:

const apiKey = 'YOUR_API_KEY';
const apiUrl = `https://api.weatherbit.io/v2.0/history/monthly?city=New%20York&country=USA&start_date=2021-06-01&end_date=2021-06-30&key=${apiKey}`;

async function getHistoricalWeather() {
  const response = await fetch(apiUrl);
  const data = await response.json();
  console.log(data);
}

getHistoricalWeather();

This code uses the fetch method to make a GET request to the Historical Weather API endpoint. The start_date and end_date parameters are used to specify the time range for which historical data is required.

Forecast

The Forecast API endpoint returns the weather forecast for a given location and time range. Here is an example code in JavaScript that fetches the weather forecast for New York City for the next 7 days and logs it to the console:

const apiKey = 'YOUR_API_KEY';
const apiUrl = `https://api.weatherbit.io/v2.0/forecast/daily?city=New%20York&country=USA&days=7&key=${apiKey}`;

async function getForecast() {
  const response = await fetch(apiUrl);
  const data = await response.json();
  console.log(data);
}

getForecast();

This code uses the fetch method to make a GET request to the Forecast API endpoint. The days parameter is used to specify the number of days for which the weather forecast is required.

Conclusion

Weatherbit API is a great tool for developers who want to access weather data for their projects. This blog explored some of the Weatherbit API endpoints and provided example code in JavaScript for each of them. With these examples, you should be able to start exploring more features of Weatherbit API and create your own weather-based applications.

Explore More

Best Weatherbit alternatives (2026)Best Weather APIs

Related APIs in Weather