API interaction guide
For schemas, request models, and endpoint lists, see the API reference overview. For the internal design, see API structure.
The public API is versioned under /v1. Keep the API origin separate from the versioned path in
your client configuration and build requests such as https://api.cml-relab.org/v1/products.
When to use the API directly
Section titled “When to use the API directly”- scripted or batch access to structured research data
- connecting Relab records to notebooks or external tooling
- automating repetitive reference-data lookups
- building custom integrations on top of the platform
Authentication
Section titled “Authentication”- Browsers use cookies (
POST /v1/auth/session/login) - Apps and scripts use bearer tokens (
POST /v1/auth/bearer/login) - Refresh-token handling depends on the Redis-backed auth path (see Authentication)
Suggested first steps
Section titled “Suggested first steps”- Open the API reference overview and choose the surface you need.
- Check whether the endpoint is public or requires authentication.
- Start with a read-only request.
- Inspect response models, especially linked entities and media.
- Automate writes only once you understand how the product hierarchy is represented.
Interactive tooling and admin tasks
Section titled “Interactive tooling and admin tasks”Point a client at the API and authenticate with a bearer token from POST /v1/auth/bearer/login.
The same path covers superuser tasks like POST /v1/admin/cache/clear/{namespace}.
- Postman, Bruno, Insomnia: import the OpenAPI schema (
app/src/types/openapi.json) for the full endpoint collection, then set auth to Bearer. - VS Code REST Client / JetBrains HTTP Client: use
scripts/admin.httpfrom a repo checkout. Sendloginonce; the token flows into the calls below it.
Exporting products
Section titled “Exporting products”To analyse a set of products in a spreadsheet or in Python, export them instead of paging through the list:
GET /v1/products/export?format=csv|jsontakes the same filters, search, and sorting asGET /v1/products, and returns every base product that matches, not only one page.GET /v1/products/{id}/export?format=csv|jsonexports one base product.
Each base product comes with all its components, at every depth.
- CSV has one row per product or component. The
parent_idcolumn links a component to the record it was taken out of. Column names follow the records table of the dataset release, andimage_urlslists the photo URLs separated by spaces. - JSON is a list of products in the same shape as the product read API, with
componentsnested at every level.
The app offers the same exports: Export on a product page, and Export results under the product list filters.
An export shows the owner the way the product page does: the username when the owner’s profile is public, empty when it is hidden. Exports are public and have a stricter rate limit than ordinary reads.
Integration advice
Section titled “Integration advice”- Build against the generated OpenAPI schema, not copied examples, which drift.
- For product circularity notes, use
circularity_propertiesas eithernullor an object with optionalrecyclability,disassemblability, andremanufacturabilitystrings. Empty objects and empty note strings are normalized tonull. - If you need a stable exported dataset rather than live application access, check the dataset page first.