Build a Small Weather App with a Free API (No API Key Required)
A public API is useful only when you can get from “I found it” to a working request quickly. Here is a tiny example using Open-Meteo, a free weather API that does not require an API key for non-commercial use.
A public API is useful only when you can get from “I found it” to a working request quickly. Here is a tiny example using Open-Meteo, a free weather API that does not require an API key for non-commercial use.
1. Make the request
Open-Meteo accepts latitude and longitude. This example fetches current temperature and wind speed for Istanbul:
const url = new URL("https://api.open-meteo.com/v1/forecast");
url.search = new URLSearchParams({
latitude: "41.0082",
longitude: "28.9784",
current: "temperature_2m,wind_speed_10m",
timezone: "Europe/Istanbul",
});
const response = await fetch(url);
if (!response.ok) throw new Error(`Weather request failed: ${response.status}`);
const weather = await response.json();
console.log(weather.current);
The response includes the requested measurements and a timestamp. Show units and the timestamp in your UI; a number like 18.4 is ambiguous by itself.
2. Keep failure states visible
A request that worked once can still fail in your app. Keep loading, error, and success states distinct, and set a timeout for production use.
Also check the provider's current usage terms. “No API key” does not mean unlimited or unrestricted commercial use.
3. Explore before wiring up a project
I maintain FreeAPI, a directory and live workbench for discovering public REST APIs. The Open-Meteo page lets you inspect and try the endpoint; the Explorer filters APIs by authentication and other details.
A catalog is useful when it helps you check fit before building around a provider. The provider's own docs remain the source of truth for terms and limits.
Disclosure: FreeAPI is my project. This post was prepared with AI assistance.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.