> For the complete documentation index, see [llms.txt](https://docs.net2grid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.net2grid.com/integration-guide/lan-api.md).

# LAN API

The LAN API is exposed locally by the NET2GRID device on the home network. It provides device information, meter readings, and Wi-Fi (WLAN) configuration for the SmartBridge, and is protected by the `N2G-LAN-USER` API key, except for a few endpoints (i.e., device info, WLAN status, and connectivity ping) that are available without authentication.

## Available Operations

Currently, the service supports the following operations:

* Retrieve general device information (unique ID, device type, firmware version, hardware version).
* Reboot the device.
* Retrieve the connected meter interface's status (electrical, gas, or both).
* Retrieve the most recent electrical meter readings (power, import, export).
* Retrieve historical electrical power data for the last hour or the last 24 hours.
* Retrieve per-phase power, voltage, and current attributes.
* Retrieve historical energy import totals for the last day, month, or year.
* Retrieve historical energy export totals for the last day, month, or year.
* Retrieve the current Wi-Fi (WLAN) connection status.
* Scan for available wireless access points.
* Join a wireless network using an SSID and key.
* Leave the current wireless network and return to access point mode.
* Run a connectivity (ping) test to check internet access.
* Enable WPS pairing mode for 2 minutes.

## Error Codes

The LAN API returns a small, fixed set of error codes, which are documented per-operation in the OpenAPI specification:

* **400 Bad Request** — the request body did not match the expected schema. This is currently only returned by `/wlan/join`, when the supplied `ssid`/`key` fields are invalid.
* **401 Unauthorized** — the `N2G-LAN-USER` API key was missing or invalid. This applies to every operation except the handful that don't require authentication (see Available Operations).
* **503 Service Unavailable** — the device could not fulfill the request, typically because the relevant hardware interface (meter or Wi-Fi) isn't ready or connected yet, or because insufficient historical data has been collected for the requested time range.

Unlike the cloud-hosted Device Management API, there is no API Gateway middleware in front of this API, so no `403`/`404` responses are returned for malformed requests — an unrecognized path or method is handled directly by the device.

## Getting Access

The LAN API is only reachable from the same local network as the SmartBridge — the client device must be connected to the same access point (either the SmartBridge's own AP if it hasn't joined a Wi-Fi network yet, or the home Wi-Fi network it has joined) to reach it at `http://{IP}`.

Authenticated operations require a `N2G-LAN-USER` token, passed in the `Authorization` header as `N2G-LAN-USER token="${USER_API_TOKEN}"`.

Both the device's local IP address and the user token are retrieved from the **Device Management API**, not from the  LAN API itself:

* Call `GET /gateways/{eui64}/info` (part of the Device Management API's Information group of calls) with the `eui64` of the desired device.
* The response contains a `lan` object with the device's local IP address and, nested under `token`, the `N2G-LAN-USER` token.

This call requires an API Key, which is provided by NET2GRID in a secure manner.

## OpenAPI Specification Interfaces

The LAN API is available in the [API Reference section](https://docs.net2grid.com/lan-api/).


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.net2grid.com/integration-guide/lan-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
