Skip to main content
The Weather App fetches data from the OpenWeatherMap API. You need a personal API key to make requests.
The free tier allows up to 60 calls per minute and 1,000,000 calls per month — more than enough for personal or demo use.
1

Create a free account

Go to openweathermap.org and click Sign in > Create an Account. Fill in your details and confirm your email address.
2

Navigate to API Keys

After logging in, click your username in the top-right corner and select My API keys from the dropdown menu.
3

Generate a new key

In the Create key section, enter a name for your key (for example, weather-app) and click Generate. The new key will appear in the table below.
4

Wait for the key to activate

New API keys on the free tier can take up to 2 hours to become active. If you get a 401 Unauthorized response right after generating a key, wait a while and try again.
5

Add the key to script.js

Open script.js and replace the appid value in the URL string with your key:
const link = "https://api.openweathermap.org/data/2.5/weather?q={city}&appid={YOUR_API_KEY}";
For example, to show weather for London:
const link = "https://api.openweathermap.org/data/2.5/weather?q=london&appid=YOUR_API_KEY";
Keep your API key private. Do not commit it to a public repository. Anyone with access to your key can make requests on your behalf, which could exhaust your quota or trigger account issues.
For a production deployment, avoid storing the API key directly in client-side JavaScript. Instead, use a backend proxy (a small server-side function that makes the OpenWeatherMap request and returns the data) or a platform-level environment variable with a serverless function. This keeps the key out of your public source code.

Build docs developers (and LLMs) love