Limits
Read 3 minutes
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.
All API users have a daily request limit. Information about the limit can be obtained from the response headers of the API request:
- X-RateLimit-Limit - daily limit
- X-RateLimit-Remaining - number of remaining requests that can be made before "X-RateLimit-Reset"
- X-RateLimit-Reset - the time when the daily limit will be reset (unix timestamp)
Example of method call:
<?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);
}
// Result:
{
.
.
.
"X-RateLimit-Limit": 1000
"X-RateLimit-Remaining": 992
"X-RateLimit-Reset": 1734987600
}
{
"status": "ok",
"error_code": 0
}