# Runs over time

**GET** `/api/stats/timeseries`

Runs by status in hourly or daily buckets over a window, with every bucket filled.

Needs [an API token](https://docs.gorunner.io/api/authentication#scopes) with the **Read** permission for runs (`run:read`).

## Parameters

### Query

- `window` · Optional · string: `24h`, `7d` (the default) or `30d`, ending now. Anything else reads as 7d.
- `environment` · Optional · string: `production` (the default), `test` or `all`.
- `bucket` · Optional · string: `hour` or `day`. Left out: hours for 24h, days otherwise. Anything else is refused.

## Buckets

Each point’s `t` is the bucket’s start, in UTC. `cancelled` is counted apart, never as worked or failed.

## Responses

- 200 OK

  One point per bucket: 24 for 24h, and 7 or 30 for 7d and 30d with the default buckets. Hourly on 7d is 168. The last is partly filled. Empty buckets are zeros.

- 400 `VALIDATION_ERROR`

  `bucket` isn’t `hour` or `day`.

- 403 `FORBIDDEN`

  The token lacks the **Read** permission for runs.

- 500 `INTERNAL_ERROR`

  The series couldn’t be read. Try again.

Any call can also answer: [`401 UNAUTHORIZED`](https://docs.gorunner.io/errors#UNAUTHORIZED) · [`401 TOKEN_ENDED`](https://docs.gorunner.io/errors#TOKEN_ENDED) · [`403 TOKEN_SURFACE_OFF`](https://docs.gorunner.io/errors#TOKEN_SURFACE_OFF) · [`403 FEATURE_OFF`](https://docs.gorunner.io/errors#FEATURE_OFF) · [`403 EMBED_NOT_ALLOWED`](https://docs.gorunner.io/errors#EMBED_NOT_ALLOWED) · [`403 EMBED_NOT_AVAILABLE`](https://docs.gorunner.io/errors#EMBED_NOT_AVAILABLE) · [`403 ACCOUNT_SUSPENDED`](https://docs.gorunner.io/errors#ACCOUNT_SUSPENDED) · [`429 RATE_LIMITED`](https://docs.gorunner.io/errors#RATE_LIMITED) · [`503 BUSY`](https://docs.gorunner.io/errors#BUSY) · [`503 PAUSED`](https://docs.gorunner.io/errors#PAUSED) · [`503 SERVICE_UNAVAILABLE`](https://docs.gorunner.io/errors#SERVICE_UNAVAILABLE). See [Errors](https://docs.gorunner.io/api/errors#by-status).

Request

**curl**

```bash
GORUNNER="https://api.gorunner.io"
GORUNNER_TOKEN="grt_…"  # needs Read for runs

curl "$GORUNNER/api/stats/timeseries?window=24h" \
  -H "Authorization: Bearer $GORUNNER_TOKEN"
```

**JavaScript**

```js
const GORUNNER = "https://api.gorunner.io";
const TOKEN = process.env.GORUNNER_TOKEN;

const res = await fetch(
  `${GORUNNER}/api/stats/timeseries?window=24h`,
  {
    headers: { Authorization: `Bearer ${TOKEN}` },
  },
);
const { data } = await res.json();
```

**Python**

```python
import os, requests

GORUNNER = "https://api.gorunner.io"
TOKEN = os.environ["GORUNNER_TOKEN"]

res = requests.get(
    f"{GORUNNER}/api/stats/timeseries",
    params={"window": "24h"},
    headers={"Authorization": f"Bearer {TOKEN}"},
)
data = res.json()["data"]
```

Response · 200 OK, shortened

```json
{
  "data": {
    "bucket": "hour",
    "points": [
      {
        "t": "2026-10-25T08:00:00Z",
        "total": 6,
        "completed": 5,
        "failed": 1,
        "cancelled": 0
      },
      "…"
    ]
  }
}
```

**Every field**

It takes no body.

### Response · 200 OK

- `data` · object
  - `window` · string: One of `24h`, `7d`, `30d`.
  - `bucket` · string: One of `hour`, `day`.
  - `points` · array of objects: A FIXED number of bucket-aligned points, the window divided by the bucket (by default 24 hourly for `24h`, 7 daily for `7d`, 30 daily for `30d`; `bucket=hour` on `7d` gives 168, `bucket=day` on `24h` one), the last one partial, gap-filled with zeros. Always `[]`, never null.
    - `t` · time: The bucket’s start, UTC.
    - `completed` · integer
    - `failed` · integer
    - `cancelled` · integer: Runs someone stopped in the bucket: their own segment of a chart, never counted as worked or failed.
    - `total` · integer

Related: [Run summary with trend](https://docs.gorunner.io/api/stats/get-stats-summary) · [Count runs by state](https://docs.gorunner.io/api/stats/count-runs)

Source: https://docs.gorunner.io/api/stats/get-stats-timeseries
