# Meshview API Documentation

This page describes all REST endpoints provided by Meshview.

## /api/nodes

GET /api/nodes

Returns a list of mesh nodes.

### Query Parameters

Parameter | Description
--- | ---
role | Filter by node role
channel | Filter by channel
hw_model | Hardware model filter
days_active | Only nodes seen within X days

Example:
`/api/nodes?days_active=3`

## /api/packets

GET /api/packets

Fetch packets with many filters. Returns decoded packet data.

### Query Parameters

Parameter | Description
--- | ---
packet_id | Return exactly one packet
limit | Max number of results (1–100)
since | Only packets newer than import_time_us
from_node_id | Filter by sender node
to_node_id | Filter by destination node
node_id | Legacy: match either from or to
portnum | Filter by port number
contains | Substring filter for payload

Example:
`/api/packets?from_node_id=123&limit=100`

## /api/packets_seen/{packet_id}

GET /api/packets_seen/<packet_id>

Returns list of gateways that heard the packet (RSSI/SNR/hops).

Example:
`/api/packets_seen/3314808102`

## /api/stats

GET /api/stats

Returns aggregated packet statistics for a node or globally.

### Query Parameters

Parameter | Description
--- | ---
period_type | "hour" or "day"
length | How many hours/days
node | Node ID for combined sent+seen stats
from_node | Filter by sender
to_node | Filter by receiver
portnum | Filter by port
channel | Filter by channel

Example:
`/api/stats?node=1128180332&period_type=day&length=1`

## /api/stats/count

GET /api/stats/count

Returns total packets and total packet_seen entries. When no filters are provided, it returns global totals. When filters are specified, they narrow the time, channel, direction, or specific packet.

### Query Parameters

Parameter | Description
--- | ---
period_type | "hour" or "day"
length | Number of hours or days (depends on period_type)
channel | Filter by channel
from_node | Only packets sent by this node
to_node | Only packets received by this node
packet_id | Filter seen counts for specific packet_id

Example:
`/api/stats/count?from_node=1128180332&period_type=day&length=1`

## /api/edges

GET /api/edges

Returns traceroute and/or neighbor edges for graph rendering.

### Query Parameters

Parameter | Description
--- | ---
type | "traceroute", "neighbor", or omitted for both

Example:
`/api/edges?type=neighbor`

## /api/config

GET /api/config

Returns Meshview configuration (site, MQTT, cleanup, etc.).

`/api/config`

## /api/lang

GET /api/lang

Returns translated text for the UI.

### Parameters

lang | Language code (e.g. "en")
section | Optional UI section (firehose, map, top...)

`/api/lang?lang=en§ion=firehose`

## /health

GET /health

Returns API + database status.

## /version

GET /version

Returns Meshview version and Git revision.

Meshview API — generated documentation