diff --git a/repeater/web/api_endpoints.py b/repeater/web/api_endpoints.py index f55f17a..d58413a 100644 --- a/repeater/web/api_endpoints.py +++ b/repeater/web/api_endpoints.py @@ -2499,11 +2499,164 @@ class APIEndpoints: - pyMC Repeater API Documentation - + pyMC Repeater API + + @@ -2512,7 +2665,7 @@ class APIEndpoints: diff --git a/repeater/web/openapi.yaml b/repeater/web/openapi.yaml index ff1de1e..eef60f9 100644 --- a/repeater/web/openapi.yaml +++ b/repeater/web/openapi.yaml @@ -119,6 +119,27 @@ paths: mode: monitor responses: '200': + description: Mode changed + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessResponse' + examples: + success: + value: + success: true + data: "Mode set to forward" + '400': + description: Invalid mode + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + + /packet_stats: + get: + tags: [Packets] + summary: Get packet statistics description: Returns packet counts, types, and routing statistics parameters: - name: hours @@ -154,9 +175,7 @@ paths: by_type: type: object by_route: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' + type: object /set_duty_cycle: post: @@ -185,25 +204,39 @@ paths: responses: '200': description: Duty cycle setting updated + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessResponse' - /packet_stats: + /packet_history: get: tags: [Packets] - summary: Get packet statistics + summary: Get packet history + description: Retrieve recent packet history parameters: - - name: hours + - name: limit in: query schema: type: integer - default: 24 - description: Time range in hours + default: 100 + minimum: 1 + maximum: 1000 + description: Maximum number of packets to return responses: '200': - description: Packet statistics + description: Packet history content: application/json: schema: type: object + properties: + success: + type: boolean + data: + type: array + items: + type: object /packet_by_hash: get: @@ -326,6 +359,8 @@ paths: type: string data: type: array + items: + type: number /metrics_graph_data: get: @@ -397,17 +432,42 @@ paths: type: string data: type: array + items: + type: number /noise_floor_history: get: tags: [Noise Floor] summary: Get noise floor history + description: Retrieve historical noise floor measurements parameters: - name: hours in: query schema: type: integer default: 24 + minimum: 1 + maximum: 168 + description: Time range in hours + responses: + '200': + description: Noise floor history + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + type: array + items: + type: object + + /cad_calibration_start: + post: + tags: [CAD Calibration] + summary: Start CAD calibration description: Begin Channel Activity Detection calibration process requestBody: required: true @@ -446,6 +506,23 @@ paths: application/json: schema: $ref: '#/components/schemas/SuccessResponse' + + /cad_calibration_stop: + post: + tags: [CAD Calibration] + summary: Stop CAD calibration + responses: + '200': + description: Calibration stopped + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessResponse' + + /create_identity: + post: + tags: [Identities] + summary: Create new identity description: Create a new repeater or room server identity requestBody: required: true @@ -545,16 +622,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' - '200': - description: Calibration started - - /cad_calibration_stop: - post: - tags: [CAD Calibration] - summary: Stop CAD calibration - responses: - '200': - description: Calibration stopped /identities: get: @@ -575,7 +642,14 @@ paths: properties: identities: type: array - | + items: + $ref: '#/components/schemas/Identity' + + /room_messages: + get: + tags: [Room Server] + summary: Get room messages + description: | Retrieve messages from a room with pagination. **Max Messages Per Room**: 32 (hard limit) @@ -676,6 +750,28 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' + + /room_post_message: + post: + tags: [Room Server] + summary: Post message to room + description: | + Add a new message to a room server. Message will be distributed to all synced clients. + + **Special author values:** + - `"server"` or `"system"` - System message, goes to ALL clients (API only) + - Any hex string - Normal message, NOT sent to that client + + **Security:** + - Radio messages cannot use server key (blocked) + - API messages can use server key (for announcements) + + **Rate Limits:** + - 10 messages/minute per author_pubkey + - 160 bytes max message length + - Global 1.1s gap between transmissions + requestBody: + required: true content: application/json: schema: @@ -799,129 +895,6 @@ paths: value: success: false error: "message is required" - description: ACL statistics - - /room_messages: - get: - tags: [Room Server] - summary: Get room messages - description: Retrieve messages from a room with pagination - parameters: - - name: room_name - in: query - schema: - type: string - example: General - - name: room_hash - in: query - schema: - type: string - example: "0x42" - - name: limit - in: query - schema: - type: integer - default: 50 - - name: offset - in: query - schema: - type: integer - default: 0 - - name: since_timestamp - in: query - schema: - type: number - format: float - responses: - '200': - description: Messages retrieved - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - data: - type: object - properties: - room_name: - type: string - room_hash: - type: string - messages: - type: array - items: - $ref: '#/components/schemas/RoomMessage' - count: - type: integer - total: - type: integer - limit: - type: integer - offset: - type: integer - - /room_post_message: - post: - tags: [Room Server] - summary: Post message to room - description: | - Add a new message to a room server. Message will be distributed to all synced clients. - - **Special author values:** - - `"server"` or `"system"` - System message, goes to ALL clients - - Any hex string - Normal message, NOT sent to that client - requestBody: - required: true - content: - application/json: - schema: - type: object - required: [message, author_pubkey] - properties: - room_name: - type: string - example: General - room_hash: - type: string - example: "0x42" - message: - type: string - maxLength: 160 - example: "Hello from API" - author_pubkey: - type: string - example: "abc123def456..." - description: "Hex string or 'server' for system messages" - txt_type: - type: integer - default: 0 - responses: - '200': - description: Message posted - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - data: - type: object - properties: - message_id: - type: integer - room_name: - type: string - room_hash: - type: string - queued_for_distribution: - type: boolean - is_server_message: - type: boolean - author_filter_note: - type: string /room_stats: get: @@ -1101,14 +1074,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' - type: string - - name: room_hash - in: query - schema: - type: string - responses: - '200': - description: Client list /room_message: delete: @@ -1149,6 +1114,18 @@ paths: responses: '200': description: Messages cleared + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + type: object + properties: + deleted_count: + type: integer components: schemas: @@ -1157,8 +1134,10 @@ components: properties: success: type: boolean + example: true data: type: object + description: Response data (varies by endpoint) ErrorResponse: type: object @@ -1168,19 +1147,7 @@ components: example: false error: type: string - - Identity: - type: object - properties: - name: - type: string - type: - type: string - enum: [repeater, room_server] - hash: - type: string - public_key: - type: string + description: Error message RoomMessage: type: object