Limites

Lire 3 minutes

Tous les utilisateurs de l'API sont soumis à une limite quotidienne de requêtes. Les informations relatives à cette limite sont disponibles dans les en-têtes de la réponse à la requête API :

  • X-RateLimit-Limit : limite quotidienne
  • X-RateLimit-Remaining : nombre de requêtes restantes pouvant être effectuées avant « X-RateLimit-Reset »
  • X-RateLimit-Reset : heure à laquelle la limite quotidienne sera réinitialisée (horodatage Unix)

Exemple d'appel de la méthode :

<?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
}
IPweb

Rate the material:

Rating: 0 out of 5. Total ratings: 0.
Dernière modification

Je ne comprends rien ! Aidez-moi :-(