接入教程
1. 注册获取API密钥
2. 选择查询国家/地区代码
3. 通过日期或姓名参数调用API
4. 解析返回的JSON数据
5. 集成到您的应用程序中
按日期查询命名日
python
import requests
url = 'https://nameday.abalin.net/api/V1/getdate'
params = {
'country': 'us',
'month': 3,
'day': xx
}
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
response = requests.get(url, params=params, headers=headers)
data = response.json()
print(data)
按姓名查询命名日
php
<?php
$url = 'https://nameday.abalin.net/api/V1/getname';
$data = [
'country' => 'de',
'name' => 'John'
];
$options = [
'http' => [
'method' => 'GET',
'header' => "Authorization: Bearer YOUR_API_KEY\r\n"
]
];
$context = stream_context_create($options);
$response = file_get_contents($url . '?' . http_build_query($data), false, $context);
$result = json_decode($response, true);
print_r($result);
?>
获取今日命名日
javascript
fetch('https://nameday.abalin.net/api/V1/today', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
常见问题
API是否需要认证?
是的,该API需要认证。请使用您获得的API密钥,在请求头中添加Authorization: Bearer YOUR_API_KEY。
支持哪些国家或地区?
API支持全球多个国家和地区,如美国(us)、德国(de)、法国(fr)等。具体国家代码请参考官方文档。
请求频率是否有限制?
是的,该API有请求频率限制。免费计划通常限制为每分钟60次请求,具体限制请查阅您的API订阅计划。
Aitishiku.com