# Runs in flight

**GET** `/api/stats`

The runs of your workspace that haven’t finished yet, by state. It takes no parameters.

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

## Response

`runs` counts the runs that haven’t finished: `pending` (queued), `running` and `paused`. Every key is always there, zero included.

`waiting` is the pending runs that wait in line for a free slot. They are counted in `pending` too, so don’t add `waiting` to the others.

The answer also holds `queue` and `keel`, always `{"available": false}`. They are leaving: don’t read them. The installation’s queue depths are on the [Health page](https://docs.gorunner.io/self-host/health#queues) of the Platform console, for its admins.

For figures by day, or under the Runs page’s filters, use [Count runs by state](https://docs.gorunner.io/api/stats/count-runs).

Request

**curl**

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

curl "$GORUNNER/api/stats" \
  -H "Authorization: Bearer $GORUNNER_TOKEN"
```

**JavaScript**

```js
const res = await fetch(`${GORUNNER}/api/stats`, {
  headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json(); // data.runs
```

**Python**

```python
res = requests.get(
    f"{GORUNNER}/api/stats",
    headers={"Authorization": f"Bearer {TOKEN}"},
)
runs = res.json()["data"]["runs"]
```

Response · 200 OK

```json
{
  "data": {
    "runs": {
      "pending": 0,
      "running": 0,
      "paused": 0,
      "waiting": 0
    }
  }
}
```

## Responses

- 200 OK

  The workspace’s runs in flight.

- 403 `FORBIDDEN`

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

- 500 `INTERNAL_ERROR`

  The counts 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) · [`429 RATE_LIMITED`](https://docs.gorunner.io/errors#RATE_LIMITED) · [`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).

**Every field**

It takes no body.

### Response · 200 OK

- `data` · object: The caller’s workspace’s in-flight run counts.
  - `runs` · object: Non-terminal runs in the caller’s workspace. All four keys are always present.
    - `pending` · integer: Not finished and not paused: waiting in line or executing (includes `waiting`).
    - `waiting` · integer: Of `pending`, the runs waiting in line for a free slot (a runs-at-once limit or a free worker).
    - `running` · integer: Currently executing.
    - `paused` · integer: Suspended on a durable wait.
  - `queue` · object: Always `{"available": false}`. Kept for one release for dashboards loaded before it; it will be removed.
    - `available` · boolean
  - `keel` · object: Always `{"available": false}`. Kept for one release for dashboards loaded before it; it will be removed.
    - `available` · boolean

Related: [Count runs by state](https://docs.gorunner.io/api/stats/count-runs) · [List runs](https://docs.gorunner.io/api/runs/list-runs) · [Errors](https://docs.gorunner.io/api/errors)

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