快速接入示例
cURL
curl -X GET "https://api.openweathermap.org/data/2.5/weather" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"JavaScript / Node.js
const response = await fetch('https://api.openweathermap.org/data/2.5/weather', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
});
const data = await response.json();
console.log(data);Python
import requests
url = "https://api.openweathermap.org/data/2.5/weather"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
data = response.json()
print(data)