Skip to content

REST API

The browser app talks to the backend over a JSON REST API under /api. You can call it from scripts too. Like the Python API, it is not yet declared stable: before 1.0, a route or request field can change in a minor release, and the changelog marks such changes Breaking:.

Interactive docs

With the backend running, FastAPI serves the full list of routes, request bodies and responses at:

GET / returns the name, version and build of the running backend.

Which dataset a request acts on

Several datasets can be loaded at once, each in a named slot. Every route that touches data takes the slot as a query parameter, ?dataset=<slot>. Leaving it out means the slot named primary.

curl 'http://localhost:8000/api/schema?dataset=secondary'

GET /api/datasets lists the loaded slots. The app names slots primary, secondary, slot3, slot4 and so on, reusing a freed name. When you script against several datasets, name the slots yourself.

Two exceptions to remember

  • POST /api/load takes the slot in the body, not the query: {"file_path": "/path/to/data.h5ad", "slot": "secondary"}. A ?dataset= on this route is ignored, and the file loads into primary.
  • The slot string is used literally. Posting "slot": "auto" creates a slot called auto.

If you name no slot and primary is not loaded (for example because the first dataset was closed), the request fails with 503 and the message lists the slots that are loaded. Skopia does not fall back to another slot, so a request meant for one dataset never changes a different one.

Long-running jobs

Operations that take a while (CNV inference, GSEA, contouring, cell typing and others) run in the background. Their route answers 202 Accepted at once with a task id:

{"task_id": "…", "status": "running"}

Poll GET /api/tasks/{task_id} until status is completed, error or cancelled. The response carries result when it completed, error when it failed, and progress (0 to 1) and message while the job reports progress. POST /api/tasks/{task_id}/cancel asks a job to stop; it takes effect when the current computation step returns, not mid-calculation.

Arguments are checked before the job starts, so invalid input comes back as a 400 from the original request rather than as a failed task.

Errors

Status Meaning
400 Invalid input (a bad parameter, an unknown option). The detail field says what was wrong.
404 A named thing does not exist: a column, gene, figure, subset or task.
409 A conflict: a figure whose input result was deleted or re-made, or a name collision the app can offer to resolve.
422 The request body does not match the route's schema (FastAPI's own validation).
503 No dataset is loaded in the slot the request named. Through the frontend's development proxy, also "backend not reachable yet".

Error responses are JSON with a detail string. Values that cannot be computed come back as null, never NaN or Infinity.