Dokumentacija
Seznam incidentov
GET /api/v1/incidents
Incidenti vaše ekipe, najnovejši najprej. Vrnjeni so samo potrjeni incidenti: neuspelo preverjanje, ki ga druga lokacija ni potrdila, je sum in ne izpad, zato se tu nikoli ne pojavi (glejte kako zaznamo izpade).
Parametri
Vsi parametri so neobvezni in gredo v poizvedbeni niz (query string).
| Parameter | Pomen |
|---|---|
from, to |
Obdobje. Incident je vključen, če se z obdobjem prekriva, zato je izpad, ki se je začel zadnji večer prejšnjega meseca in končal po polnoči, v poročilu tega meseca. Brez from tako daleč nazaj, kot dovoli vaš paket; brez to do zdaj. |
monitor |
Samo incidenti enega monitorja (njegov ID iz seznama monitorjev). |
client |
Samo incidenti na monitorjih ene stranke (njen ID, client.id monitorja). |
status |
open ali resolved. |
severity |
critical, warning ali info. |
per_page |
od 1 do 100, privzeto 50. |
cursor |
Naslednja stran: next_cursor iz prejšnjega odgovora. |
Primer
Vsi incidenti ene stranke v septembru, v časovnem pasu stranke:
cURL
curl -G http://pulsekeeper.io/api/v1/incidents \
-H "Authorization: Bearer $PULSEKEEPER_TOKEN" \
--data-urlencode "client=c4e0b9a17d2f6385" \
--data-urlencode "from=2026-09-01T00:00:00+02:00" \
--data-urlencode "to=2026-10-01T00:00:00+02:00"
PHP
<?php
// composer require guzzlehttp/guzzle
$client = new GuzzleHttp\Client([
'base_uri' => 'http://pulsekeeper.io/api/v1/',
'headers' => ['Authorization' => 'Bearer '.getenv('PULSEKEEPER_TOKEN')],
]);
$query = [
'client' => 'c4e0b9a17d2f6385',
'from' => '2026-09-01T00:00:00+02:00',
'to' => '2026-10-01T00:00:00+02:00',
];
$incidents = [];
do {
$page = json_decode($client->get('incidents', ['query' => $query])->getBody(), true);
$incidents = array_merge($incidents, $page['data']);
$query['cursor'] = $page['next_cursor'];
} while ($page['next_cursor'] !== null);
JavaScript
const query = new URLSearchParams({
client: 'c4e0b9a17d2f6385',
from: '2026-09-01T00:00:00+02:00',
to: '2026-10-01T00:00:00+02:00',
});
const incidents = [];
do {
const response = await fetch(`http://pulsekeeper.io/api/v1/incidents?${query}`, {
headers: { Authorization: `Bearer ${process.env.PULSEKEEPER_TOKEN}` },
});
const page = await response.json();
incidents.push(...page.data);
query.set('cursor', page.next_cursor ?? '');
} while (query.get('cursor'));
Go
query := url.Values{}
query.Set("client", "c4e0b9a17d2f6385")
query.Set("from", "2026-09-01T00:00:00+02:00")
query.Set("to", "2026-10-01T00:00:00+02:00")
var incidents []map[string]any
for {
req, _ := http.NewRequest("GET", "http://pulsekeeper.io/api/v1/incidents?"+query.Encode(), nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("PULSEKEEPER_TOKEN"))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
var page struct {
Data []map[string]any `json:"data"`
NextCursor *string `json:"next_cursor"`
}
json.NewDecoder(res.Body).Decode(&page)
res.Body.Close()
incidents = append(incidents, page.Data...)
if page.NextCursor == nil {
break
}
query.Set("cursor", *page.NextCursor)
}
Odgovor
{
"data": [
{
"id": "3f9a1c0e7b2d4a58",
"type": "downtime",
"title": "Site unreachable",
"severity": "critical",
"state": "resolved",
"monitor": { "id": "a81c27e05f3d9b64", "type": "http", "name": "HTTP", "target": "shop.example.com" },
"client": { "id": "c4e0b9a17d2f6385", "name": "Example Shop" },
"started_at": "2026-09-30T21:14:05Z",
"confirmed_at": "2026-09-30T21:14:41Z",
"acknowledged_at": null,
"resolved_at": "2026-09-30T21:42:10Z",
"duration_seconds": 1685,
"excluded_from_sla": false,
"affected_locations": ["fra", "lon"],
"error": { "code": "http_5xx", "detail": "HTTP 502" },
"cause": { "text": "Outage at the hosting provider", "in_report": true }
}
],
"next_cursor": "eyJzdGFydGVkX2F0Ijo…"
}
next_cursor je na zadnji strani null. Polja incidenta so opisana pod Posamezen incident.