1. Home
  2. Docs
  3. Examples
  4. Get paginated downtimes

Get paginated downtimes

The example below returns a website with all its downtimes.

The default pagination size is 15 and the maximum is 50.

GraphQL query

query {
  website(id: 13) {
    domain
    up
    downtimes {
      data {
        id
        down_at
        up_at
        duration
      }
      paginatorInfo {
        currentPage
        lastPage
      }
    }
  }
}

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.mywebsiteisonline.com/graphql',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"query":"query {\\n  website(id: 13) {\\n    domain\\n    up\\n    downtimes {\\n      data {\\n        id\\n        down_at\\n        up_at\\n        duration\\n      }\\n      paginatorInfo {\\n        currentPage\\n        lastPage\\n      }\\n    }\\n  }\\n}","variables":{}}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer [API_KEY]',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response

{
    "data": {
        "website": {
            "domain": "santerref.net",
            "up": false,
            "downtimes": {
                "data": [
                    {
                        "id": "2",
                        "down_at": "2022-02-11 21:42:03",
                        "up_at": null,
                        "duration": null
                    },
                    {
                        "id": "1",
                        "down_at": "2022-02-11 21:38:28",
                        "up_at": "2022-02-11 21:38:28",
                        "duration": 1249
                    }
                ],
                "paginatorInfo": {
                    "currentPage": 1,
                    "lastPage": 1
                }
            }
        }
    }
}
Was this article helpful to you? No Yes

How can we help?