Set Up a RECAP Server
RECAP can run behind a local or remote server. In both cases, the server owns the database and clients connect with RecapClient.from_url(). Authenticated REST query endpoints serve reads and counts; REST command endpoints handle creates, updates, and copies.
This guide documents the currently runnable single-user API-key deployment. Multi-user authorization configuration is described separately as an implementation gap because its server startup wiring is not complete.
Install the server
Install the server extra on the host that owns the RECAP database:
pip install "pyrecap[server]"The server extra includes Uvicorn, FastAPI integration, PostgreSQL support, and server configuration dependencies.
Configure a single-user server
Create a configuration file on the server. Keep the API key in a secret manager or provision the file with restricted permissions; do not commit the key to source control.
server:
db_path: /data/recap/recap.db
host: 127.0.0.1
port: 8000
authentication_mode: single-user
api_key: replace-with-secretExactly one of db_path and database_uri is required. Use database_uri for a non-file database such as PostgreSQL. Single-user mode requires a non-empty api_key.
For a local server, start directly against SQLite:
pip install "pyrecap[server]"
recap-server --db /path/to/recap.db --port 8000The direct --db form uses server configuration defaults. Configure its API key through the supported server configuration or environment settings rather than placing credentials in command arguments.
For a configured deployment, start with:
recap-server --config /etc/recap/recap-server.yamlRun a remote server
For a remote deployment, install the server extra on the host that owns the database and run recap-server under your chosen hosting platform. A typical provider-neutral boundary is:
Client -> HTTPS endpoint or reverse proxy -> recap-server -> database
The deployment platform is intentionally outside RECAP’s scope. Configure its process manager, network access, TLS termination, backups, and secrets using your organization’s standards.
[Deployment-specific: add reverse-proxy and TLS configuration.]
[Deployment-specific: add process-manager configuration and restart policy.]
[Deployment-specific: add database backup and restore procedure.]
[Deployment-specific: add secret provisioning and rotation procedure.]
Connect a remote client
Connect to the reachable base URL from Python:
from recap.client import RecapClient
client = RecapClient.from_url(
"http://localhost:8000",
api_key="your-api-key",
)
namespace = client.namespace("beamline/amx")Once connected, follow Quick Start: Create and Store Data Locally. Use RecapClient.from_url() in place of RecapClient.from_sqlite(); the namespace, builders, queries, and provenance workflow are the same.
Remote clients use authenticated POST /api/v1/query for reads and POST /api/v1/query/count for counts. Creates, updates, and resource copies use REST command endpoints. Applications do not need direct access to the server’s database filesystem. Query payloads and results are ordinary JSON envelopes; local and remote QueryDSL behavior remains aligned.
Verify and troubleshoot
Send an authenticated REST query after starting the server:
curl https://recap.example.org/api/v1/query \
-H 'Authorization: Apikey your-api-key' \
-H 'Content-Type: application/json' \
--data '{"entity":"namespace","projection":"full","namespace_path":"beamline/amx","spec":{}}'Use responses as follows:
200: request authenticated and query completed.401: credential is missing, malformed, or invalid.403: request is rejected by an authorization policy in a future multi-user deployment.404: requested resource or namespace does not exist; a future multi-user policy may also conceal it.503: authorization snapshot is unavailable in a future multi-user deployment.
Use the X-Request-ID response header when reporting server-side failures.
For client credential details, see Authenticate a Remote Client.