Free Weather API JSON: How to Build a Weather Forecasting App

by | May 19, 2024

An increasing number of developers are interested in creating a weather forecasting app. The first thing they should do is obtain help from a free weather API JSON, like the one offered by weatherstack. With this API,  developers can acquire accurate weather data to integrate into their apps. These APIs will also provide real-time information, which is essential in making weather predictions. People search these forecasts to plan for outdoor activities, prepare for severe weather alerts, and understand climate patterns. These APIs pull data from reliable sources like weather stations, satellites, and meteorological organizations. This ensures the information’s accuracy and timeliness. With weatherstack’s API, integrating this data into your app has become a rather easy task. This guide will explore the process of using weatherstack’s API to create a fully functional weather forecasting app. 

How to Find a Good Weather API?

free weather api json for accurate weather forecasts & historical data

Developing a reliable weather forecasting app requires integrating good-quality weather APIs that source data from reputable meteorological providers. Begin by considering APIs like Weatherstack, which aggregates data from trusted sources. These APIs provide real-time weather information, air quality indexes, and UV indexes, which are important for delivering accurate forecasts. Apps like Carrot Weather utilize these APIs effectively to offer detailed meteorological data and smart forecasting features.

Make sure that the API supports both Android and iOS devices. This will allow you to reach a much broader audience than if you were focused only on one OS. Additionally, check if the API offers a free app tier or premium subscription for more advanced features. Only a few APIs offer premium features such as lightning detection, live radar, and historical weather data. Therefore by selecting a reliable API, you can improve your app’s accuracy and user experience, making it one of the best weather apps available.

Is It Reliable to Use APIs for Building a Weather Data App?

Using APIs for building a weather data app is highly reliable and advantageous. APIs provide a standardized way to access and retrieve data from external sources, such as weather data providers.

Here are some reasons why using APIs for building a weather data app is reliable:

  • Weather APIs, like weatherstack API, connect you to rather reputable weather data providers like Weather Underground and NOAA weather radar. 
  • Weather conditions can change rapidly, and APIs make sure that your app reflects the latest weather updates. Therefore you can obtain real-time values for temperature, humidity, wind speed, and more.
  • APIs provide a consistent format and structure for weather data. This makes it easier for developers to parse and display the information in their app.
  • Reputable weather APIs often provide detailed documentation, including guides, tutorials, and support channels.

How to Use Weatherstack?

Weatherstack is a very good option when making a weather forecasting app

First, you must sign up for a weatherstack account. If you are a new user, you can select the free option. This option allows you to obtain real-time weather information and up to 250 calls per month. Afterward, you have to generate an API key to make requests. 

Weatherstack Endpoints

Depending on your subscription, you can call different weatherstack endpoints to obtain different types of valuable data. Some of the more popular endpoints are given below.

Current Weather Data Or Real-Time Weather Data:
? access_key = YOUR_ACCESS_KEY
& query = New York

Historical Weather:
? access_key = YOUR_ACCESS_KEY
& query = New York
& historical_date = 2015-01-21
& hourly = 1

Historical Time-Series:
? access_key = YOUR_ACCESS_KEY
& query = New York
& historical_date_start = 2015-01-21
& historical_date_end = 2015-01-25

Weather Forecast:
? access_key = YOUR_ACCESS_KEY
& query = New York
& forecast_days = 1
& hourly = 1

Location Lookup for Multiple Locations:
? access_key = YOUR_ACCESS_KEY
& query = london

Step-by-Step Guide to Building a Weather App?

A guide to make the best weather channel app

Let’s start building our weather forecast data app through the weatherstack API.

Styling The App

We aim to create a simple app with background changes according to the weather conditions. First of all, we create an index.html file with the following template:

<!DOCTYPE html>
<html lang="en">
	<meta charset="UTF-8">    
	<meta name="viewport" content="width=device-width, initial-scale=1.0">    	<meta http-equiv="X-UA-Compatible" content="ie=edge">    
	<title>Weather app</title>    
	<link rel="stylesheet" href="styles.css" />    
	<!-- Google Fonts -->    
	<link rel="preconnect" href="">    
href=",wght@0,700;1,600&display=swap" rel="stylesheet">
	<div class="container">        
		<img src="" alt="" srcset="" id="weather-icon">        
		<div id="location">Unable to Fetch Weather</div>        
		<div class="desc">No Information Available.</div>        
		<div class="weather">            
			<div class="c">Error</div>            
			<div class="circle"></div>            
			<div class="f">Error</div>        
		<div class="info">            
			<h4>Sunrise: <span class="sunrise">No Information Available</span></h4>            
			<h4>Sunset: <span class="sunset">No Information Available</span></h4>        
	<script src="scripts.js"></script>

We can connect this file to the styles.css file and the js file. Let’s start styling it as under:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
body {
  font-family: 'Lora', serif;

.container {
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgb(251, 242, 133);
  background: radial-gradient(
    rgba(251, 242, 133, 0.6334908963585435) 0%,
    rgba(224, 196, 91, 0.8407738095238095) 35%,
    rgba(230, 224, 113, 1) 100%

.weather {
  display: flex; 
  align-items: center;
  margin: 15px 0;
  font-size: 1.5rem;

#location {
  font-size: 3rem;
  font-weight: 800;
  font-style: italic;
.desc {
  font-size: 1.25rem;
  text-transform: capitalize;

.circle {
  background-color: black;
  border-radius: 50px;
  height: 15px;
  width: 15px;
  margin: 0 15px;

After the styling part, we move to the API to get the weather data.

Getting Weather Data From a Weather API

First, you must subscribe to a weather API like weatherstack and generate an API key. Once you get the API key, you can return to your coding process.

Coding the JavaScript

Create a scripts.js file and add a variable “API” that will help us fetch the API key. We will use the following endpoint in our weather forecasting app.
    ? access_key = YOUR_ACCESS_KEY
    & query = New York
    & forecast_days = 1
    & hourly = 1

The code inside the JS file should look like this:

// Weatherstack API. Do not share it publicly.
const api = '66869939e0b182ac2d6************'; //Replace with your API

const iconImg = document.getElementById('weather-icon');
const loc = document.querySelector('#location');
const tempC = document.querySelector('.c');
const tempF = document.querySelector('.f');
const desc = document.querySelector('.desc');
const sunriseDOM = document.querySelector('.sunrise');
const sunsetDOM = document.querySelector('.sunset');

window.addEventListener('load', () => {
  let long;
  let lat;
  // Accessing Geolocation of User
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition((position) => {
      // Storing Longitude and Latitude in variables
      long = position.coords.longitude;
      lat = position.coords.latitude;
      const base = `
    ? access_key = YOUR_ACCESS_KEY
    & query = New York
    & forecast_days = 1
    & hourly = 1`;

      // Using fetch to get data
        .then((response) => {
          return response.json();
        .then((data) => {
          const { temp } = data.main;
          const place =;
          const { description, icon } =[0];
          const { sunrise, sunset } = data.sys;

          const iconUrl = `${icon}@2x.png`;
          const fahrenheit = (temp * 9) / 5 + 32;

          // Converting Epoch(Unix) time to GMT
          const sunriseGMT = new Date(sunrise * 1000);
          const sunsetGMT = new Date(sunset * 1000);

          // Interacting with DOM to show data
          iconImg.src = iconUrl;
          loc.textContent = `${place}`;
          desc.textContent = `${description}`;
          tempC.textContent = `${temp.toFixed(2)} °C`;
          tempF.textContent = `${fahrenheit.toFixed(2)} °F`;
          sunriseDOM.textContent = `${sunriseGMT.toLocaleDateString()}, ${sunriseGMT.toLocaleTimeString()}`;
          sunsetDOM.textContent = `${sunsetGMT.toLocaleDateString()}, ${sunsetGMT.toLocaleTimeString()}`;

Why is Weatherstack Better Than Other Options?

Weatherstack stands out among weather data providers due to its many features and smooth integration process. It is also easier to use than other options and this makes it ideal for any weather forecasting app. Unlike other weather APIs, weatherstack offers different types of weather data which are all accessible via a user-friendly API. Its compatibility with both Android and iOS devices allows it to compete with other top services. Weatherstack provides meteorological data, including wind patterns, cloud coverage, and UV index. This information is required when making smart forecasts and planning outdoor activities. Its API also supports live radar maps, air quality indexes, and lightning detection. This improves its utility for weather stations and other apps. With both free app options and premium subscription tiers, weatherstack offers flexibility and superior weather information. The reasons above make weatherstack a favorite weather app choice for developers and users alike.


Using the weatherstack API to create a weather forecasting app gives developers a trustworthy and flexible way to get accurate and current weather information. Whether you prefer iOS or Android, weatherstack will be helpful to you in both cases. Weatherstack’s features like hourly and daily forecasts and live radar maps guarantee detailed weather information. The API supports smart forecasts with detailed meteorological data, including wind patterns, cloud coverage, and UV indexes. This makes weatherstack suitable for various applications, from basic weather apps to advanced weather stations. Its smooth integration process, combined with free app options and premium subscription tiers, offers a flexible tool for developers. With weatherstack, you can develop an exceptional weather application that keeps people informed about the weather. The information provided allows people to engage in outdoor activities, prepare for bad weather, and monitor climate change. Therefore go to weatherstack’s website and get your very own subscription right now!


Is there any free API for weather?

Yes, Weatherstack offers a free tier for accessing weather data.

Which is the best free weather API?

Weatherstack is considered one of the best free weather APIs due to its multiple features and reliability.

Which weather data API is free for Python?

Weatherstack provides a free API that can be easily integrated with Python applications.

What is the free weather API with no key?

Open-Meteo is an example of a free weather API that does not require an API key.