Get current weather data
curl --request GET \
--url 'https://api.openweathermap.org/data/2.5/weather?appid='import requests
url = "https://api.openweathermap.org/data/2.5/weather?appid="
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.openweathermap.org/data/2.5/weather?appid=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openweathermap.org/data/2.5/weather?appid=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.openweathermap.org/data/2.5/weather?appid="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.openweathermap.org/data/2.5/weather?appid=")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openweathermap.org/data/2.5/weather?appid=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"coord": {
"lon": 2.3488,
"lat": 48.8534
},
"weather": [
{
"id": 803,
"main": "Clouds",
"description": "broken clouds",
"icon": "04d"
}
],
"base": "stations",
"main": {
"temp": 289.28,
"feels_like": 288.7,
"temp_min": 288.21,
"temp_max": 291.69,
"pressure": 1022,
"humidity": 67
},
"visibility": 10000,
"wind": {
"speed": 2.57,
"deg": 40
},
"clouds": {
"all": 75
},
"dt": 1717406455,
"sys": {
"type": 2,
"id": 2041230,
"country": "FR",
"sunrise": 1717386622,
"sunset": 1717444055
},
"timezone": 7200,
"id": 2988507,
"name": "Paris",
"cod": 200
}{
"cod": 400,
"message": "Nothing to geocode"
}{
"cod": 401,
"message": "Invalid API key. Please see https://openweathermap.org/faq#error401 for more info."
}{
"cod": 123,
"message": "<string>"
}API Reference
Current Weather Data API
Reference for the Current Weather Data API endpoint.
GET
/
weather
Get current weather data
curl --request GET \
--url 'https://api.openweathermap.org/data/2.5/weather?appid='import requests
url = "https://api.openweathermap.org/data/2.5/weather?appid="
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.openweathermap.org/data/2.5/weather?appid=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openweathermap.org/data/2.5/weather?appid=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.openweathermap.org/data/2.5/weather?appid="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.openweathermap.org/data/2.5/weather?appid=")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openweathermap.org/data/2.5/weather?appid=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"coord": {
"lon": 2.3488,
"lat": 48.8534
},
"weather": [
{
"id": 803,
"main": "Clouds",
"description": "broken clouds",
"icon": "04d"
}
],
"base": "stations",
"main": {
"temp": 289.28,
"feels_like": 288.7,
"temp_min": 288.21,
"temp_max": 291.69,
"pressure": 1022,
"humidity": 67
},
"visibility": 10000,
"wind": {
"speed": 2.57,
"deg": 40
},
"clouds": {
"all": 75
},
"dt": 1717406455,
"sys": {
"type": 2,
"id": 2041230,
"country": "FR",
"sunrise": 1717386622,
"sunset": 1717444055
},
"timezone": 7200,
"id": 2988507,
"name": "Paris",
"cod": 200
}{
"cod": 400,
"message": "Nothing to geocode"
}{
"cod": 401,
"message": "Invalid API key. Please see https://openweathermap.org/faq#error401 for more info."
}{
"cod": 123,
"message": "<string>"
}Use this endpoint to fetch current weather conditions for a given location.
Query Parameters
Units of measurement:
standard: Kelvin for temperature, meters per second for wind speed and wind gustmetric: Celsius for temperature, meters per second for wind speed and wind gustimperial: Fahrenheit for temperature, miles per hour for wind speed and wind gust
Default is standard if you don't use the units parameter.
Available options:
standard, metric, imperial Output language for weather description (weather.description) and city name (name) fields in the API response.
Available options:
sq: Albanianaf: Afrikaansar: Arabicaz: Azerbaijanieu: Basquebe: Belarusianbg: Bulgarianca: Catalanzh_cn: Chinese Simplifiedzh_tw: Chinese Traditionalhr: Croatiancz: Czechda: Danishnl: Dutchen: Englishfi: Finnishfr: Frenchgl: Galiciande: Germanel: Greekhe: Hebrewhi: Hindihu: Hungarianis: Icelandicid: Indonesianit: Italianja: Japanesekr: Koreanku: Kurmanji (Kurdish)la: Latvianlt: Lithuanianmk: Macedonianno: Norwegianfa: Persian (Farsi)pl: Polishpt: Portuguesept_br: Português Brasilro: Romanianru: Russiansr: Serbiansk: Slovaksl: Sloveniansp,es: Spanishsv,se: Swedishth: Thaitr: Turkishua,uk: Ukrainianvi: Vietnamesezu: Zulu
Default is English if you don't use the lang parameter.
Response
Successful response - Current weather data