# Inventory the API Endpoints of a Go Service

Yes. An agent reads your Go service's ServeMux registrations across its REST, Fever and Google Reader APIs and writes a table of every endpoint and its auth.

[Run this on Rush](https://cloud.getrush.ai/run/api-endpoint-inventory/go/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the service into its own cloud sandbox and starts where the requests enter. In a Go service like miniflux/v2, `go.mod` declares `module miniflux.app/v2` on `go 1.26.0`, and `internal/http/server/routes.go` builds the tree with the method-and-path patterns of the standard `http.ServeMux`: an `appMux` with `GET /healthcheck`, the Fever API mounted at `/fever/` behind `fever.Middleware`, the Google Reader API as `POST /accounts/ClientLogin` plus everything under `/reader/api/0/`, the REST API at `/v1/` only when `config.Opts.HasAPI()` is true, `GET /metrics` only when `HasMetricsCollector()` is true, and the web UI as the catch-all `/`. A `rootMux` adds `/liveness`, `/healthz`, `/readiness` and `/readyz` and mounts the app under the configured base path with `http.StripPrefix`. Those two conditionals go into the inventory as a column, because an endpoint that exists in code but is off by configuration is a common source of confusion.

The REST API is one file. `internal/api/api.go` registers every `/v1` route on a mux with `HandleFunc("GET /v1/feeds", handler.getFeedsHandler)` and so on, grouped by resource: users (`POST /v1/users`, `GET /v1/users/{identifier}`, `PUT /v1/users/{userID}/mark-all-as-read`, `GET /v1/me`), categories, `POST /v1/discover`, feeds (`PUT /v1/feeds/refresh`, `GET /v1/feeds/counters`, `GET /v1/feeds/{feedID}/icon`), `GET /v1/export` and `POST /v1/import`, entries (`GET /v1/entries/ids`, `PUT /v1/entries` for bulk status, `PUT /v1/entries/{entryID}/bookmark` and `/star` both wired to `toggleStarredHandler`, `POST /v1/entries/{entryID}/save`, `GET /v1/entries/{entryID}/fetch-content`), `flush-history` on both `PUT` and `DELETE`, icons, enclosures, `GET /v1/integrations/status`, `GET /v1/version` and the `api-keys` routes. `internal/api/middleware.go` sets the auth rule for all of them: `validateAPIKeyAuth` reads the `X-Auth-Token` header and looks it up with `UserByAPIKey`, answering `401` for an unknown key and setting the user id, timezone and admin flag on the request context, and `validateBasicAuth` falls back to HTTP Basic with `WWW-Authenticate: Basic realm="Restricted"` when no token authenticated the request; `withCORSHeaders` allows `X-Auth-Token, Authorization, Content-Type, Accept`.

The compatibility APIs need a different reading. The Google Reader handler in `internal/googlereader/handler.go` registers `POST /accounts/ClientLogin` without auth and then `token`, `edit-tag`, `rename-tag`, `disable-tag`, `tag/list`, `user-info`, `subscription/list`, `subscription/edit`, `subscription/quickadd`, `stream/items/ids`, `stream/items/contents`, `mark-all-as-read` and a `fallbackHandler` on `GET` and `POST /reader/api/0/`, each wrapped in `withApiKeyAuth`. The Fever API in `internal/fever/handler.go` is a single handler that dispatches on form values rather than paths, `mark=item`, `mark=feed` and `mark=group` with `as=read`, `unread`, `saved` or `unsaved`, so its rows in the inventory are operations keyed by parameter, not by URL. The web UI in `internal/ui/ui.go` registers ninety-seven routes, from static assets under `/stylesheets/{checksum}/{filename}` to `GET` and `POST /subscribe`; they are listed in their own section because they are session routes, not an API.

The last columns are evidence the code already holds. `client/client.go` is the official Go client with a method per operation, so a `/v1` route with no client method stands out, and `internal/api/api_integration_test.go` holds the integration tests that `make integration-test` runs against a live server started with `RUN_MIGRATIONS=1`, `CREATE_ADMIN=1` and `ADMIN_PASSWORD=test123` on the Postgres CI provides, with `TEST_MINIFLUX_BASE_URL` pointing at it, so each route gets a `tested` column from the test names. The agent writes `endpoints.md` from these files alone; it builds nothing and starts no server, and it notes the published reference at `miniflux.app/docs/api.html` as the document to diff the table against.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Write an inventory of every HTTP endpoint in this Go service as endpoints.md. Start from internal/http/server/routes.go: list the root mux and app mux routes, the base path handling, and which mounts depend on config.Opts.HasAPI() or HasMetricsCollector(). Then read internal/api/api.go and middleware.go, internal/googlereader/handler.go, internal/fever/handler.go and internal/ui/ui.go. For every registration write a row with method, path pattern, handler function and package, auth rule (none, X-Auth-Token or HTTP Basic, Google Reader token, Fever api_key, or UI session), path parameters from the pattern, the config flag that enables it if any, whether client/client.go has a method for it, and whether internal/api/api_integration_test.go has a test that names it. List the Fever operations by their mark and as form values since that handler dispatches on parameters. Put the REST API first, then Google Reader, Fever, health and metrics, and the UI routes in their own section. Treat two patterns that map to the same handler, such as bookmark and star, as one row with both paths. Do not build or run the service and do not change any file.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is one file, `endpoints.md`, as an artifact on the session, with a download link that works for an hour and is refreshed on every read of the session. Its first part is the mount map from `routes.go`: the probes on the root mux, the base path, and the two mounts that depend on configuration flags. Then come the tables: the `/v1` REST routes with method, path, handler, auth rule, parameters, client method and integration test; the Google Reader routes with their shared `withApiKeyAuth`; the Fever operations by form value; and the UI routes in a section of their own.

The session read at `GET /o/{org}/sessions/{id}` lists the artifact with its `name`, `mime_type` and `url`, and the transcript at `GET /o/{org}/sessions/{id}/messages` keeps every file the agent opened, so a row can be traced to the registration line it came from. The run changes nothing in the repository.

A reader checks the rows against the published API reference and against the client: a route in code with no client method and no integration test is either new or forgotten, and a client method with no route is a leftover, and both are the kind of finding the table makes visible in one pass.

## Run it on every pull request that touches a routes file

Add an automation to the Project with this prompt and a `github` trigger on `pull_request.opened` and `pull_request.synchronize` with `branch_patterns` set to `main`. A trigger filters on branch, labels and authors, not on paths, so the prompt tells the agent to end with a one-line result when the diff touches none of `internal/http/server/routes.go`, `internal/api`, `internal/googlereader`, `internal/fever` or `internal/ui/ui.go`. The trigger adds the pull request event after the prompt and fills in nothing; pull requests from forks never fire it.

For a standing inventory instead, a `schedule` trigger with `cron` set to the first of the month regenerates it, or a release script sends `POST /o/{org}/sessions` with this body and a `request_id` that is a UUID v5 of the tag, so a rerun returns the same run. Give the key a `webhook_url` and Rush POSTs `run.completed` with `data.session_url` to read for the artifact.

## Why run it on Rush?

An inventory like this is a reading job across five packages, two of which register routes in ways a grep for a path pattern misses: a handler that dispatches on form values and a catch-all with nearly a hundred UI routes. Doing it by hand produces a table that is right the day it is written. The agent reads the registrations as they are on the branch, in its own sandbox, and writes the table from them, with the client and test files as cross-checks.

The artifact comes with its trail: every file opened is in the transcript, and each row names the handler so a reader can jump to it. Several branches or releases can be inventoried at once in separate sandboxes, and a follow-up on the parked session can turn the table into an OpenAPI document or diff it against the published reference without a second clone.

## Frequently asked questions

### Does it need to build or run the server?

No. Every route is a `HandleFunc` or `Handle` registration in source, the auth rule is in the middleware files, and the enabling flags are read from `routes.go`. The prompt forbids building and running, so the inventory is a reading of the branch with no Postgres needed.

### How does it handle the Fever API, which has no paths?

It lists operations by the form values the handler switches on: `mark` set to `item`, `feed` or `group`, with `as` set to `read`, `unread`, `saved` or `unsaved`, and the read endpoints the same way, each pointing at the function in `internal/fever/handler.go` that serves it, under the one mount at `/fever/`.

### Does it include the web UI routes?

Yes, in their own section, because `internal/ui/ui.go` registers them on the same app mux as the catch-all and a reader asking what the server answers needs them. They are marked as session routes rather than API routes, and the static asset routes with a checksum in the path are grouped together.

### Can it diff the table against the published API docs?

Not in this run, which reads the repository only. The report names `miniflux.app/docs/api.html` as the reference, and a follow-up on the same session with the browser can fetch that page and mark each row as documented or not.

### Can it produce an OpenAPI document instead?

The table holds the method, path, parameters and auth for each route, which is most of an OpenAPI path item, but the request and response bodies live in the handlers and `internal/model`. Ask for OpenAPI as a follow-up on the parked session and the agent reads those as well; the inventory is the cheaper first pass.

## More Go jobs

- [Explain the Architecture of a Go Codebase](https://getrush.ai/run/architecture-overview/go/)
- [Find Dead Code in a Go Project](https://getrush.ai/run/find-dead-code/go/)
- [Fix a Go Service Bug From a Datadog Monitor Alert](https://getrush.ai/run/fix-datadog-alerts/go/)

## The same job on other stacks

- [List Every API Endpoint in a Phoenix App](https://getrush.ai/run/api-endpoint-inventory/phoenix/)
- [List Every API Endpoint in a Rails App](https://getrush.ai/run/api-endpoint-inventory/rails/)
- [List Every API Endpoint in an ASP.NET Core App](https://getrush.ai/run/api-endpoint-inventory/aspnet-core/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
