> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Things API

> Use browser JavaScript to traverse concentrators and read sensors through the Agent API

The Agent Things extension uses the existing Agent API transport to communicate with things; it does not add a new top-level HTTP endpoint family.

## Load the browser libraries

```html theme={null}
<script src="/Agent.js"></script>
<script src="/Agent.Things.js"></script>
<script src="/Events.js"></script>
```

`Events.js` is required for immediate asynchronous readout events. Without it, use Agent API polling.

When the page is hosted on a different origin, identify the Neuron used for events and set the Agent API host:

```html theme={null}
<meta name="NEURON" content="neuron.example.com" />
<script>
  AgentAPI.IO.SetHost("neuron.example.com", true);
</script>
```

Configure CORS and cookies/tokens deliberately; do not expose an Agent API secret in browser code.

## Concentrator operations

The extension can:

* get capabilities;
* list all/root/child data sources;
* test for and retrieve a node;
* list root and child nodes.

All calls address the remote device by JID and accept optional device, service, and user tokens. Node calls add source ID, node ID, and optional partition.

## Sensor operations

Synchronous methods wait for the readout result:

```javascript theme={null}
const result = await AgentAPI.Things.Sensor.ReadStandaloneDevice(
  jid,
  language,
  true,  // momentary
  false, // peak
  true,  // status
  false, // computed
  false, // identity
  false, // historical
  ["Temperature"],
  null, null, null
);
```

Use the `StartReadout...` variants for asynchronous or fragmented reads. Supply a stable request ID and handle events until completion.

## Concentrator-node read

Add the extended address:

```javascript theme={null}
const result = await AgentAPI.Things.Sensor.ReadConcentratorNode(
  jid, language,
  true, false, true, false, false, false,
  ["Temperature"],
  null, null, null,
  nodeId, sourceId, partition
);
```

Exact optional-argument ordering follows the library shipped by the target Neuron. Pin or feature-detect the client version and test against that server build.

## Robust event handling

* correlate on request ID;
* accept fragmented field batches;
* retain timestamps, units, quality flags, and node identity;
* stop only on completion/error;
* cancel abandoned readouts;
* ignore duplicates after reconnect;
* render device-provided names as untrusted text.
