天气查询

百度天气查询,支持1-7天天气查询,并返回6小时内降雨预报

请求信息

http://api.tinise.cn/api/tianqi
总调用次数
21 次
添加时间
2025-10-02

请求参数

参数名 类型 必填 说明
region string 查询的地区,为空自动获调用者的位置进行查询
type string 返回格式,支持text或json
days string 指定查询未来天数,范围1-7,如 days=3 ,默认(不写该参数)返回1天天气。

返回示例

JSON
暂无返回示例

调用示例

PHP
<?php
$url = 'http://api.tinise.cn/api/tianqi';
$params = [
    'region' => 'YOUR_VALUE',
    'type' => 'YOUR_VALUE',
    'days' => '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;
?>
Python
import requests

url = "http://api.tinise.cn/api/tianqi"
params = {
    'region': 'YOUR_VALUE',
    'type': 'YOUR_VALUE',
    'days': 'YOUR_VALUE',
}
response = requests.get(url, params=params)
print(response.text)
JavaScript
const url = new URL('http://api.tinise.cn/api/tianqi');
const params = {
    'region': 'YOUR_VALUE',
    'type': 'YOUR_VALUE',
    'days': '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));