# Your traffic as a series

`GET /traffic`

Requires the `businesses` scope.

Requests and errors under your key as a dense series: the last 24 hours by the hour, or the last 7 or 30 days by the day (Israel time), with the period's totals and server-side latency over the part of it the request log holds.

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `period` | string |  |  One of: `24h`, `7d`, `30d`. Default `7d`. |

## Response

`200`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `period` | string | **required** |  One of: `24h`, `7d`, `30d`. |
| `unit` | string | **required** |  One of: `hour`, `day`. |
| `buckets` | array of object | **required** |  |
| `totals` | object | **required** |  |
| `totals.requests` | integer |  |  |
| `totals.errors` | integer |  |  |
| `latency` | object |  |  |
| `latency.count` | integer |  |  |
| `latency.p50` | integer |  | Median, ms. |
| `latency.p95` | integer |  | 95th percentile, ms. |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X GET "$BASE/traffic?period=" \
  -H "X-Api-Key: $KEY"
```
### Node

```node
const res = await fetch(`${BASE}/traffic`, {
  method: 'GET',
  headers: {
    'X-Api-Key': KEY,
  },
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.get(
    f"{BASE}/traffic",
    headers={"X-Api-Key": KEY},
)
data = res.json()
```