# Helementa Docs > Build on the Helementa API: how to authenticate, read errors and page through lists, and the reference for every public route. # Helementa API Source: https://docs.helementa.com/ The Helementa API serves Helementa's data as JSON over HTTPS at `https://api.helementa.com`. Every request carries an [API key](/authentication), every list returns its items a [page](/pagination) at a time, and every error is a [problem document](/errors) with a stable `code`. ## Conventions - **Versions:** the version is part of the path, as in `/v1/sensor-types`. A public route changes only in ways existing clients keep working with: new optional fields and new routes, never a removed field or a new requirement. - **Fields:** every field name is `snake_case`. - **Language:** what the API returns is en-US and meant for programs, so branch on codes, never on text. ## Reference The [API reference](/reference) is built from the OpenAPI document the API itself writes, so it lists every public route with the parameters it accepts, the responses it returns and the credential it asks for. ## For agents Every page is also served as Markdown: add `.md` to its URL, as in [`/authentication.md`](/authentication.md). [`/llms.txt`](/llms.txt) indexes every page, and [`/llms-full.txt`](/llms-full.txt) holds them all in one file. --- # Authentication Source: https://docs.helementa.com/authentication The Helementa API authenticates every request with an API key, sent as a bearer token in the `Authorization` header: ```http Authorization: Bearer YOUR_API_KEY ``` :::note API keys are not issued yet. Until they are, every route that asks for a credential answers `401` with the code `unauthenticated`. ::: Keep the key on your server: read it from an environment variable, and never ship it in a web page or a mobile app. ## Make a first call List the sensor types, the kinds of reading a device reports, each with its unit: ```bash curl https://api.helementa.com/v1/sensor-types \ -H "Authorization: Bearer $HELEMENTA_API_KEY" ``` The route in full, from the [API reference](/reference): `GET /v1/sensor-types` **Responses** - `200` — Response for status 200 - `401` — Response for status 401 - `403` — Response for status 403 - `422` — Response for status 422 Response example, 200: ```json { "data": [ { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "tag": "string", "name": "string", "unit": "string", "description": "string" } ], "next_cursor": "string" } ``` ## When the API refuses the key - `401 unauthenticated`: the request carries no key, or one the API does not accept. - `403 forbidden`: the key is valid, but it lacks the permission the route needs. Both answers are [problem documents](/errors). The API checks the key before it validates the request, so a refused call learns nothing about the route's schema. --- # Errors Source: https://docs.helementa.com/errors When a request fails, the API answers with an HTTP status and a problem document ([RFC 9457](https://www.rfc-editor.org/rfc/rfc9457)), served as `application/problem+json`: ```json { "type": "unauthenticated", "code": "unauthenticated", "status": 401, "title": "Unauthorized" } ``` | Field | What it holds | | -------- | -------------------------------------------------------- | | `code` | The error, as a stable identifier. Branch on it. | | `type` | The problem type RFC 9457 asks for. | | `status` | The HTTP status of the response. | | `title` | A short summary of the status, for logs. | | `detail` | When present, what went wrong in this request, for logs. | `title` and `detail` are for people reading logs: their wording can change, so never branch on them. ## Codes | Status | Code | When | | ------ | ----------------------- | ------------------------------------------------------- | | 400 | `parse` | The request body is not valid JSON. | | 401 | `unauthenticated` | The request carries no API key, or one the API refuses. | | 403 | `forbidden` | The key lacks the permission the route needs. | | 404 | `not-found` | No route answers at this path. | | 409 | `conflict` | The request clashes with data that already exists. | | 422 | `validation` | A parameter or field breaks the route's schema. | | 422 | `invalid-cursor` | The cursor is not one the list returned. | | 500 | `internal-server-error` | The API failed. Retry later; the failure is reported. | Each route's page in the [API reference](/reference) lists the statuses it can answer. --- # Pagination Source: https://docs.helementa.com/pagination Every list takes two query parameters: - `limit`: how many items the page holds. Each list's page in the [API reference](/reference) shows its default and its maximum. - `cursor`: where the page starts. Leave it out for the first page. It answers with the page's items in `data`, and in `next_cursor` the cursor of the next page, `null` on the last one: ```json { "data": [], "next_cursor": null } ``` To read a whole list, pass each `next_cursor` back as `cursor` until it is `null`: ```js let cursor = null; do { const url = new URL("/v1/sensor-types", "https://api.helementa.com"); if (cursor) url.searchParams.set("cursor", cursor); const response = await fetch(url, { headers: { Authorization: `Bearer ${process.env.HELEMENTA_API_KEY}` }, }); const page = await response.json(); // Use page.data here. cursor = page.next_cursor; } while (cursor); ``` A cursor is opaque: pass it back as the list returned it. One the list did not return answers `422` with the code `invalid-cursor`. --- # Helementa public API Source: https://docs.helementa.com/reference Version 1 Base URL: `https://api.helementa.com` ## Sensor types - [`GET /v1/sensor-types`](/reference/sensor-types/list-sensor-types) — List sensor types. --- # List sensor types Source: https://docs.helementa.com/reference/sensor-types/list-sensor-types `GET /v1/sensor-types` **Responses** - `200` — Response for status 200 - `401` — Response for status 401 - `403` — Response for status 403 - `422` — Response for status 422 Response example, 200: ```json { "data": [ { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "tag": "string", "name": "string", "unit": "string", "description": "string" } ], "next_cursor": "string" } ```