<div class="docs-content" data-render>
# Reading service data
Live status and metrics for every background service are available over HTTP, admin-only, and refreshed every few seconds from the `service_state` table. See also the [Services overview](/docs/services-overview.html).
> Audience: administrators and maintainers. All endpoints here require an administrator; non-admins get redirected or a 403.
## All services at once
```
GET /admin/services/data
```
Returns `{ "services": [ ... ] }` where each entry is the service's full `describe()`:
| Field | Meaning |
|-------|---------|
| `name` | Internal service name (`openai`, `devii`, `news`, `bots`). |
| `title`, `description` | Human labels. |
| `enabled` | Whether the service is configured to run. |
| `status` | `running`, `stopped`, or `stalled` (heartbeat older than 15s). |
| `interval_seconds` | Current run interval. |
| `last_run`, `next_run`, `heartbeat` | ISO timestamps. |
| `uptime` | Time since the service started, when running. |
| `log_buffer` | The recent log lines. |
| `metrics` | The service-specific data (see below). This is where the live AI statistics live. |
| `fields`, `field_groups` | The configuration specs. |
This single call is the right source for the running statistics of all services. Each per-service `metrics` block holds the live AI statistics, already computed.
## One service
```
GET /admin/services/{name}/data
```
Returns `{ "service": { ... } }` with the same `describe()` shape for one service, for example `GET /admin/services/openai/data` for the AI gateway or `GET /admin/services/devii/data` for the assistant.
## What is in each metrics block
The gateway and the bots report rich metrics; Devii reports session and spend counters; news reports its AI usage cards (calls, tokens, cost, and averages) alongside the status and log tail.
**`openai` (AI gateway)** reports a runtime block (`requests`, `errors`, `in_flight`, `peak_in_flight`, `vision_calls`, `last_status`, `last_latency_ms`, `pool`, `circuit_open`) and a rolled-up 24h summary (`requests`, `success_pct`, `error_pct`, `cost_hour`, `cost_24h`, `tokens_24h`, `avg_latency_ms`, `avg_tps`, `peak_concurrency`, `top_model`, `top_caller`). Presented as a labelled stats list.
**`devii`** reports a stats list: active sessions, open connections, 24h spend, the user/guest/admin caps, whether guests are allowed, and the model name.
**`bots`** reports a stats list (bots running, fleet cost, cost rate, projected 24h cost, LLM calls, tokens in and out, posts, comments, votes) plus a per-bot table (bot, user, persona, status, posts, comments, votes, calls, cost).
**`news`** reports a `stats` block of AI usage cards (grading and formatting calls, tokens, cost, and per-call averages) rolled up from the `news_usage` table; its run health is still the status, last and next run, and the log tail.
## Deeper AI analytics (gateway)
The headline gateway numbers are summaries. The full analytics, the same data shown on the `/admin/ai-usage` page, come from:
```
GET /admin/ai-usage/data
```
This returns the `GatewayUsageOut` payload: per-hour buckets, token and latency percentiles, error breakdowns, cost projections, top models and callers, and behavior stats. For one user's AI usage:
```
GET /admin/users/{uid}/ai-usage
```
For platform-wide counts (members, active windows, signups, totals, top authors):
```
GET /admin/analytics
```
## How Devii should answer service-stats questions
For questions about running services or their AI statistics, the answer is `GET /admin/services/data`, not the in-session cost tracker. The `cost_stats` tool reports only the current Devii conversation's token usage, not the platform's service statistics. For gateway depth use `GET /admin/ai-usage/data`; for platform counts use `GET /admin/analytics`. Devii reaches all three through its `http` action because the platform enforces admin access, not the agent.
## Controlling a service
Each of these is an admin POST and is mirrored by the buttons on `/admin/services/{name}`:
```
POST /admin/services/{name}/start
POST /admin/services/{name}/stop
POST /admin/services/{name}/run run once now
POST /admin/services/{name}/clear-logs
POST /admin/services/{name}/config save configuration fields
```
</div>