天气预报

可查询今日以及未来几日的天气

接口状态:正常
总调用:55
添加时间:2025-08-02
更新时间:2025-08-21

请求信息

请求地址:
https://cyapi.top/API/weather.php
示例地址:
https://cyapi.top/API/weather.php?city=贵阳&n=1&type=text

请求参数

参数名 类型 必填 说明
city string 城市名
n string 不传则返回城市列表,传入序号选择对应城市
type string 支持json和text

状态码说明

状态码 说明
200 请求成功,服务器已成功处理了请求。
403 服务器拒绝请求。这可能是由于缺少必要的认证凭据(如API密钥)或权限不足。
404 请求的资源未找到。请检查您的请求地址是否正确。
429 请求过于频繁。您已超出速率限制,请稍后再试。
500 服务器内部错误。服务器在执行请求时遇到了问题。

在线测试

此处将显示接口返回结果...

调用示例

<?php
$url = 'https://cyapi.top/API/weather.php';
$params = ['city' => 'YOUR_VALUE', 'n' => 'YOUR_VALUE', 'type' => 'YOUR_VALUE', ];
$url .= '?' . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import requests

url = "https://cyapi.top/API/weather.php"
params = {
    'city': 'YOUR_VALUE',
    'n': 'YOUR_VALUE',
    'type': 'YOUR_VALUE',
}
response = requests.get(url, params=params)
print(response.text)
const url = new URL('https://cyapi.top/API/weather.php');
const params = {
    'city': 'YOUR_VALUE',
    'n': 'YOUR_VALUE',
    'type': 'YOUR_VALUE',
};
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));

fetch(url)
    .then(response => response.text())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));