Prompt
weather api current and forecast data
Latest observation
Oct 8, 2026
OpenAI APIWeb search: off
Here’s a simple way to get current weather and forecast weather data from a weather API.
Common approach
Most weather APIs provide endpoints like:
- Current weather: current temperature, conditions, humidity, wind
- Forecast: hourly or daily predictions
Example using OpenWeather
1) Current weather endpoint
GET https://api.openweathermap.org/data/2.5/weather?q=London&appid=YOUR_API_KEY&units=metric
2) Forecast endpoint
GET https://api.openweathermap.org/data/2.5/forecast?q=London&appid=YOUR_API_KEY&units=metric
Example response fields
Current weather
main.temp→ temperatureweather[0].description→ condition textmain.humidity→ humiditywind.speed→ wind speed
Forecast
list[]→ forecast entriesdt_txt→ date/timemain.temp→ forecast temperatureweather[0].description→ forecast condition
Example in JavaScript
const API_KEY = "YOUR_API_KEY";
const city = "London";
async function getWeather() {
const currentRes = await fetch(
`https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${API_KEY}&units=metric`
);
const currentData = await currentRes.json();
const forecastRes = await fetch(
`https://api.openweathermap.org/data/2.5/forecast?q=${city}&appid=${API_KEY}&units=metric`
);
const forecastData = await forecastRes.json();
console.log("Current:", currentData);
console.log("Forecast:", forecastData);
}
getWeather();
Example in Python
import requests
API_KEY = "YOUR_API_KEY"
city = "London"
current_url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&units=metric"
forecast_url = f"https://api.openweathermap.org/data/2.5/forecast?q={city}&appid={API_KEY}&units=metric"
current_data = requests.get(current_url).json()
forecast_data = requests.get(forecast_url).json()
print("Current:", current_data)
print("Forecast:", forecast_data)
Alternatives
Other popular weather APIs:
- WeatherAPI.com
- Tomorrow.io
- Meteomatics
- Open-Meteo (free, no API key for many uses)
If you want, I can also provide:
- a full React example,
- a Node.js backend example, or
- a free weather API option without an API key.