> For the complete documentation index, see [llms.txt](https://docs.akenza.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akenza.io/reference/reference.md).

# Overview

The APIs, scripting runtime, and notations for working with akenza programmatically.

This section is the technical detail behind the rest of the documentation: the interfaces for reaching akenza from your own code, the runtime your scripts execute in, and the notations used in the interface.

## Reaching akenza from your own code

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-code">:code:</i></td><td><strong>REST API</strong></td><td>Programmatic access to the platform, with example projects in Python, JavaScript, and Java.</td><td><a href="/reference/api-documentation.md">REST API</a></td></tr><tr><td><i class="fa-bolt">:bolt:</i></td><td><strong>WebSocket API</strong></td><td>Subscribe to a live sensor data feed instead of polling for new data.</td><td><a href="/reference/websocket-api.md">WebSocket API</a></td></tr></tbody></table>

The two answer different questions. The **REST API** is for asking what the state is, or for changing it: reading device data over a period, creating devices, managing a fleet from your own system. The **WebSocket API** is for being told when something arrives, so a client reacts to an uplink rather than checking for one.

Both are scoped to an organization and authenticated with credentials issued there.

{% content-ref url="/pages/rsPlVY9mNp2Ei3bWr8We" %}
[API keys](/device-management/managing-an-organization/api-keys.md)
{% endcontent-ref %}

## Writing scripts

[Scripting](/reference/scripting.md) covers the JavaScript runtime that akenza executes as part of a data flow, in three places:

* An **uplink decoder** turns a raw device payload into structured, readable data.
* A **downlink encoder** turns a readable command back into the format a device expects.
* A **custom logic block** evaluates logic in the [rule engine](/device-management/rule-engine.md) to decide whether an action should fire.

All three implement the same `consume(event)` entry point and emit their result, so the shape of a script is the same wherever it runs.

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-file-code">:file-code:</i></td><td><strong>Scripting</strong></td><td>The runtime, the script structure, the emit function, and what is restricted.</td><td><a href="/reference/scripting.md">Scripting</a></td></tr><tr><td><i class="fa-database">:database:</i></td><td><strong>Stateful Operations</strong></td><td>Carrying state between executions, which a script does not keep on its own.</td><td><a href="/reference/scripting/stateful-operations.md">Stateful Operations</a></td></tr><tr><td><i class="fa-toolbox">:toolbox:</i></td><td><strong>Utility Functions</strong></td><td>The helpers available inside a script.</td><td><a href="/reference/scripting/utility-functions.md">Utility Functions</a></td></tr></tbody></table>

{% hint style="info" %}
Each execution loads the script fresh, so variables do not survive from one run to the next. Anything that has to persist between uplinks belongs in [stateful operations](/reference/scripting/stateful-operations.md).
{% endhint %}

## Notations

<table><thead><tr><th width="250">Page</th><th>What it covers</th></tr></thead><tbody><tr><td><a href="/reference/message-templating.md">Payload Templating</a></td><td>The <code>{{ }}</code> syntax for inserting sample data and metadata into output connector payloads and rule actions, such as putting a measured value into an email subject.</td></tr><tr><td><a href="/reference/time-range-selector.md">Time Range Selector</a></td><td>The DateMath notation behind absolute, relative, and predefined time ranges.</td></tr></tbody></table>

## Working with stored data

Several reference pages concern the data akenza has stored rather than the devices that sent it:

<table><thead><tr><th width="250">Page</th><th>What it covers</th></tr></thead><tbody><tr><td><a href="/reference/api-documentation/querying-device-data.md">Querying Device Data</a></td><td>Reading measurements back, including the aggregations used for occupancy.</td></tr><tr><td><a href="/reference/api-documentation/filtering.md">Filtering</a></td><td>Narrowing what an API call returns.</td></tr><tr><td><a href="/reference/api-documentation/schema-inference.md">Schema inference</a></td><td>How akenza derives the structure and measurement types of incoming data.</td></tr><tr><td><a href="/reference/api-documentation/authentication.md">Authentication</a></td><td>Obtaining and using a token for API requests.</td></tr></tbody></table>

{% hint style="warning" %}
All of this reads what has been stored. A [data flow](/device-management/your-data-flow.md) that forwards uplinks elsewhere without also using the [akenza DB](/device-management/your-data-flow/connectors/databases/akenza-db.md) output connector leaves nothing for these APIs to return, and no inserts for the WebSocket API to announce.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.akenza.io/reference/reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
