الحدود
يقرأ 3 دقائق
General rules of interaction with API
- You should try to minimize the number of unnecessary API requests, especially for the campaign/info and campaign/stat methods.
- There is no need to constantly request the information that you can store on your side.
- There is no need to constantly request information on inactive campaigns — there is simply no point in it, the answers will always be the same.
- A reasonable number of API requests for 1 campaign is 1-2-3, up to a maximum of 10-20 per day. The reasonable number of requests for the campaign/stat method is no more than 1 per hour. Thus, a reasonable number of requests for an account (token) is hundreds, up to a maximum of 1000 per day. If you plan to make a significantly larger number of requests — we are 99% sure that you are using an algorithm that can be significantly optimized. If you are absolutely certain that you need more requests, first coordinate this with the Helpdesk.
- If you received a response with error_code=37 and error=Temporary unavailable, try again later, you should repeat the same request no earlier than 5 minutes later.
- In case of systematic violation of these rules, access to the API may be restricted.
يخضع جميع مستخدمي واجهة برمجة التطبيقات (API) لحد أقصى يومي لعدد الطلبات. يمكن الحصول على معلومات حول هذا الحد من رؤوس استجابة طلبات واجهة برمجة التطبيقات (API):
- X-RateLimit-Limit - الحد اليومي
- X-RateLimit-Remaining - عدد الطلبات المتبقية التي يمكن إجراؤها حتى "X-RateLimit-Reset"
- X-RateLimit-Reset - الوقت الذي سيتم فيه إعادة تعيين الحد اليومي (طابع زمني يونيكس)
مثال على استدعاء الطريقة:
<?php
$post = array(
'token' => $token,
'id' => 9999
);
if ($curl = curl_init()) {
curl_setopt($curl, CURLOPT_URL, 'https://www.ipweb.ru/api/v2/category/delete');
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($curl);
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$headers_string = substr($response, 0, $header_size);
$headers_string = preg_replace('~\s+\Z~', '', $headers_string);
$headers_array = explode(PHP_EOL, $headers_string);
$headers = [];
if (is_array($headers_array)) {
foreach ($headers_array as $value) {
if (empty($value)) {
continue;
}
list($tmp_key, $tmp_value) = explode(':', $value, 2);
if ($tmp_value) {
$headers[trim($tmp_key)] = trim($tmp_value);
} else {
$headers[] = trim($tmp_key);
}
}
}
curl_close($curl);
$out = substr($response, $header_size);
print_r($headers_groups);
print_r($out);
}
// Результат:
{
.
.
.
"X-RateLimit-Limit": 1000
"X-RateLimit-Remaining": 992
"X-RateLimit-Reset": 1734987600
}
{
"status": "ok",
"error_code": 0
}