接入教程
访问Weatherstack官方网站,注册账号获取API密钥,然后按照文档调用API。
Python 示例
python
import requests
response = requests.get('http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=New York')
print(response.json())
PHP 示例
php
<?php
$response = file_get_contents('http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=New York');
echo $response;
?>
JavaScript 示例
javascript
fetch('http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=New York')
.then(response => response.json())
.then(data => console.log(data));
常见问题
如何获取API密钥?
访问Weatherstack官方网站,注册账号后即可获取API密钥。
免费版的限制是什么?
免费版每天有1000次请求的限制,每分钟最多60次请求。
Aitishiku.com