diff --git a/src/app/api-docs/page.tsx b/src/app/api-docs/page.tsx new file mode 100644 index 0000000..b54a942 --- /dev/null +++ b/src/app/api-docs/page.tsx @@ -0,0 +1,439 @@ +import React from 'react'; + +export default function ApiDocsPage() { + return ( +
+ Note: This documentation may be out of date as the project is continuously improving. + For the most up-to-date information, please refer to the source code or contact the development team. +
+Retrieve chat messages from the mesh network.
+ +Note: Array parameters like privateKeys can be specified multiple times in the URL (e.g., ?privateKeys=key1&privateKeys=key2).
| Parameter | +Type | +Required | +Description | +
|---|---|---|---|
| limit | +number | +No | +Number of messages to return (default: 20) | +
| before | +string | +No | +Get messages before this timestamp | +
| after | +string | +No | +Get messages after this timestamp | +
| channel_id | +string | +No | +Filter by specific channel hash | +
| region | +string | +No | +Filter by geographic region | +
| decrypt | +boolean | +No | +Enable message decryption (any value present) | +
| privateKeys | +string[] | +No | +Array of private keys for decryption (can be specified multiple times) | +
+{`// Without decryption
+[
+ {
+ "ingest_timestamp": "2024-01-01T12:00:00Z",
+ "mesh_timestamp": "2024-01-01T12:00:00Z",
+ "channel_hash": "a1",
+ "mac": "b2c3",
+ "encrypted_message": "hex_encoded_data",
+ "message_count": 123,
+ "origin_key_path_array": [["origin", "pubkey", "path"]]
+ }
+]
+
+// With decryption (decrypt=true)
+[
+ {
+ "ingest_timestamp": "2024-01-01T12:00:00Z",
+ "mesh_timestamp": "2024-01-01T12:00:00Z",
+ "channel_hash": "a1",
+ "mac": "b2c3",
+ "encrypted_message": "hex_encoded_data",
+ "message_count": 123,
+ "origin_key_path_array": [["origin", "pubkey", "path"]],
+ "decrypted": {
+ "timestamp": 1704110400,
+ "msgType": 1,
+ "sender": "username",
+ "text": "Hello world!",
+ "rawText": "username: Hello world!"
+ }
+ }
+]`}
+
+ Retrieve node positions for map visualization.
+ +| Parameter | +Type | +Required | +Description | +
|---|---|---|---|
| minLat | +number | +No | +Minimum latitude for bounding box | +
| maxLat | +number | +No | +Maximum latitude for bounding box | +
| minLng | +number | +No | +Minimum longitude for bounding box | +
| maxLng | +number | +No | +Maximum longitude for bounding box | +
| nodeTypes | +string[] | +No | +Filter by node types (can be specified multiple times) | +
| lastSeen | +number | +No | +Filter by last seen time in seconds | +
+{`[
+ {
+ "node_id": "abc123...",
+ "name": "Node Name",
+ "short_name": "NODE",
+ "latitude": 40.7128,
+ "longitude": -74.0060,
+ "last_seen": "2024-01-01T12:00:00Z",
+ "first_seen": "2024-01-01T10:00:00Z",
+ "type": "meshcore"
+ }
+]`}
+
+ Get the total number of nodes in the network.
+ +| Parameter | +Type | +Required | +Description | +
|---|---|---|---|
| region | +string | +No | +Filter by geographic region | +
+{`{
+ "total_nodes": 1234
+}`}
+
+ Get cumulative node statistics over time with a 7-day rolling window.
+ +| Parameter | +Type | +Required | +Description | +
|---|---|---|---|
| region | +string | +No | +Filter by geographic region | +
+{`{
+ "data": [
+ {
+ "day": "2024-01-01",
+ "cumulative_unique_nodes": 100,
+ "nodes_with_location": 80,
+ "nodes_without_location": 20,
+ "repeaters": 15,
+ "room_servers": 5
+ }
+ ]
+}`}
+
+ Get the most popular channels by message count (top 10).
+ +| Parameter | +Type | +Required | +Description | +
|---|---|---|---|
| region | +string | +No | +Filter by geographic region | +
+{`{
+ "data": [
+ {
+ "channel_hash": "a1",
+ "message_count": 1234
+ }
+ ]
+}`}
+
+ Get repeater node statistics grouped by public key prefix (first 2 characters).
+ +| Parameter | +Type | +Required | +Description | +
|---|---|---|---|
| region | +string | +No | +Filter by geographic region | +
+{`{
+ "data": [
+ {
+ "prefix": "ab",
+ "node_count": 15,
+ "node_names": ["Node1", "Node2", "Node3"]
+ }
+ ]
+}`}
+
+ All API endpoints return appropriate HTTP status codes and error messages:
+
+{`{
+ "error": "Failed to fetch data"
+}`}
+
+
+{`GET /api/chat?decrypt=true&limit=10&privateKeys=key1&privateKeys=key2`}
+
+
+{`GET /api/map?minLat=40.0&maxLat=41.0&minLng=-74.0&maxLng=-73.0&nodeTypes=meshcore`}
+
+
+{`GET /api/stats/total-nodes?region=us-east`}
+
+