Omnibus Docs

Docs › Reference

REST API

The web app, the iPhone and Android apps and the MCP server all talk to Omnibus through one REST API under /api/. You can use it too, for a script, a dashboard or a client of your own, with the same permissions your account has in the app.

The OpenAPI contract

The API is described by openapi/openapi.json, an OpenAPI 3.1 document in the repository. The server's code generates it, so it can't drift from what the server does. It lists every route with its parameters, request and response bodies, the errors particular to it, and the permission it needs.

The copy on main describes the newest code. The copy at a release tag describes that release, so to match your server, find its version in /api/_health and open the file at that tag:

https://github.com/omnibus-library/omnibus/blob/v<version>/openapi/openapi.json

The contract covers /api/*. A few surfaces whose format is fixed by the device or tool on the other end sit outside it: Kobo sync, KOReader, the OPDS catalog, Prometheus metrics and the MCP endpoint.

Browsing the reference

The server doesn't serve the document itself. To read it as a browsable reference, open the file in any OpenAPI viewer, or from a checkout of the repository run:

python3 scripts/openapi-view.py

It serves the committed openapi/openapi.json on a free local port and opens it in your browser. With the project's development tools installed, just openapi regenerates the file from the code first, then does the same.

Signing in

Every route needs a signed-in session unless the reference says otherwise. Requests carry it in one of three ways.

API tokens, for scripts

An API token is the easiest way to call the API from a script. Create one under Settings › Sign-in & security, in API tokens: name it after the script or tool that will use it, choose Create token (Create first token when you have none), and copy the secret, which starts with omni_. It's shown only once: Omnibus keeps only a hash of it, so a lost secret can't be recovered. Sessions and API tokens has the details.

Send it on every request:

Authorization: Bearer omni_…

An API token acts as you, with your permissions, and never expires. Revoke it in the same place when you no longer need it.

Signing in for a session token

POST /api/auth/login with client_kind set to bearer returns a session token in the response body, which you send the same way. Add device_name and the session appears under that name in your list of sessions. A session token stops working after a week without use, or 90 days after sign-in, whichever comes first, and POST /api/auth/logout ends it. The apps sign in this way.

Sign in without client_kind and the server sets a session cookie instead, which is what the web app uses. A cookie session lasts up to 30 days, and also ends after a week without use. A request that changes something with a cookie must come from a page at an allowed address: the one in the request's Host header or one listed in OMNIBUS_PUBLIC_ORIGIN. Otherwise it's refused with 403. Requests with a bearer token aren't checked this way.

Media links

Some routes serve files that an <img> or <audio> element loads directly, such as covers, audio parts and book files. An element can't send a header, so those routes also accept the token as a token query parameter. The reference marks them with the media_token scheme.

Permissions

A route that needs admin rights, or the upload, edit or download permission, says so in its description and answers 403 when your account lacks it. People and permissions explains what each permission allows.

Examples

These use https://books.example.com for your server and an API token in $TOKEN:

OMNIBUS=https://books.example.com
TOKEN=omni_your_token

Check the server is up

This one needs no sign-in:

curl "$OMNIBUS/api/_health"

See who you're signed in as

curl -H "Authorization: Bearer $TOKEN" "$OMNIBUS/api/auth/me"

Page through the library

curl -i -H "Authorization: Bearer $TOKEN" \
  "$OMNIBUS/api/ebooks?sort=title&dir=asc&limit=20"

Ebooks and audiobooks come back together. -i shows the headers: X-Total-Count is how many books match and X-Next-Cursor is where the next page starts. Ask for the next page with the same sort and dir:

curl -i -G -H "Authorization: Bearer $TOKEN" "$OMNIBUS/api/ebooks" \
  -d sort=title -d dir=asc -d limit=20 \
  --data-urlencode "cursor=the X-Next-Cursor value"

The last page has no X-Next-Cursor.

curl -G -H "Authorization: Bearer $TOKEN" "$OMNIBUS/api/search" \
  --data-urlencode "q=frankenstein"

Books whose title, author or series matches, best match first.

Sign in with a username and password

curl -H "Content-Type: application/json" "$OMNIBUS/api/auth/login" \
  -d '{"username": "ada", "password": "your password", "client_kind": "bearer", "device_name": "my script"}'

The answer holds token and the signed-in user. A password typed on the command line ends up in your shell history, so prefer an API token for anything you run more than once.

Errors and limits

A request that fails answers with a 4xx or 5xx status and a short plain-text body, such as book not found. Each route lists the statuses particular to it. Any route can also answer:

401
No valid session: a missing, expired or revoked token.
403
Your account lacks a permission the route needs, or a cookie request came from an address that isn't allowed.
408
The request took longer than 30 seconds. Book uploads are exempt.
413
The body is too large: over 1 MiB of JSON, 11 MiB for an image, or over the server's limit for a book upload, if one is set.
429
Too many requests from one address. See below.
500
Something failed on the server. The Health page and logs say what.

Rate limits

Some routes limit how many requests one IP address can make. Past the limit they answer 429 until the window has passed.

RoutesLimit per IP address
Signing in, registering, signing out and changing a password, together10 a minute
Search30 every 10 seconds
Image uploads: covers, journal images, avatars, author photos10 a minute
Book and audiobook uploads10 a minute

Separately, five wrong passwords lock an account for 15 minutes. While it's locked, POST /api/auth/login answers 429 with a Retry-After header giving the seconds left. Behind a reverse proxy, every request can seem to come from the proxy's address; HTTPS and reverse proxies explains how to fix that.

Paging and caching

  • GET /api/ebooks without paging parameters returns the whole library, up to 50,000 books. With sort, dir, limit or cursor it pages, as in the example above. A cursor only works with the sort and dir that produced it.
  • Routes that serve files send an ETag. Send it back in If-None-Match and an unchanged file answers 304 Not Modified with no body.
  • Book and audio files answer Range requests, so a download can resume and a player can seek.

Generating a client

Rather than writing requests by hand, point a code generator that reads OpenAPI 3.1 at the contract. For example, TypeScript types with openapi-typescript:

npx openapi-typescript openapi.json -o omnibus-api.d.ts

Every operation has an operationId, such as get_ebooks or create_api_token, which generators turn into function names. Generate from the copy at the tag of the release your server runs, and regenerate when you update the server. The web app builds its own API client from this same file.