接入教程
1. 访问Tenders Guru官网注册账号
2. 在开发者页面获取API密钥
3. 使用GET请求调用匈牙利招标接口
4. 解析返回的JSON数据格式
5. 根据需求处理招标信息数据
使用Python获取招标数据
python
import requests
url = 'https://tenders.guru/hu/api/tenders'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'application/json'
}
params = {
'page': 1,
'per_page': 20
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
data = response.json()
print(f'Fetched {len(data["items"])} tenders')
else:
print(f'Error: {response.status_code}')
print(response.text)
使用PHP查询招标信息
php
<?php
$url = 'https://tenders.guru/hu/api/tenders';
$apiKey = 'YOUR_API_KEY';
$options = [
'http' => [
'method' => 'GET',
'header' => "Authorization: Bearer $apiKey\r\n" .
"Accept: application/json\r\n"
]
];
$context = stream_context_create($options);
$response = file_get_contents($url . '?page=1&per_page=20', false, $context);
if ($response !== false) {
$data = json_decode($response, true);
echo 'Fetched ' . count($data['items']) . ' tenders';
} else {
echo 'Failed to fetch data';
}
?>
使用JavaScript获取实时招标数据
javascript
const url = 'https://tenders.guru/hu/api/tenders';
const apiKey = 'YOUR_API_KEY';
async function fetchTenders(page = 1, perPage = in20) {
try {
const response = await fetch(
`${url}?page=${page}&per_page=${perPage}`,
{
method: 'GET',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
}
}
);
if (response.ok) {
const data = await response.json();
console.log(`Fetched ${data.items.length} tenders`);
return data;
} else {
console.error(`Error: ${response.status}`);
return null;
}
} catch (error) {
console.error('Fetch error:', error);
return null;
}
}
// 使用示例
fetchTenders(1, 20);
常见问题
如何获取API密钥?
请访问 https://tenders.guru/hu/api 官网,注册账户后可在开发者控制台生成API密钥。免费套餐有一定调用限制,如需更高额度请升级套餐。
API调用频率有限制吗?
是的,免费套餐每分钟最多60次调用,每天1000次调用。付费套餐根据等级提供更高限制,具体请参考官网定价页面。
数据更新频率是多少?
招标数据实时更新,新的招标信息发布后会尽快同步至API,通常在发布后30分钟内可查询到。历史数据可通过日期参数筛选查询。
Aitishiku.com