openapi: 3.0.3 info: title: Air Quality Monitoring API description: | API for the Air Quality Monitoring and Prediction System. Handles sensor data collection, storage, and analysis. version: 1.0.0 contact: name: Air Quality Monitoring Team servers: - url: https://api.url.com/v1 description: Production server tags: - name: "Sensor Data Upload" description: "Endpoints for uploading sensor data from IoT devices" components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: X-API-Key schemas: SensorReading: type: object description: "Data structure containing readings from environmental sensors" required: - measurements - units - metadata properties: measurements: type: object description: Sensor measurements grouped by sensor type required: - temperature - humidity - voltage - current - power properties: temperature: type: number format: float description: Temperature in degrees Celsius example: 23.5 humidity: type: number format: float description: Relative humidity percentage example: 45.2 voltage: type: object description: Voltage measurements from different sources in Volts properties: battery: type: number format: float example: 3.72 solar: type: number format: float example: 4.8 current: type: object description: Current measurements from different sources in milliamps properties: battery: type: number format: float example: 0.2 solar: type: number format: float example: 0.1 power: type: object description: Power calculations from different sources in milliwatts properties: battery: type: number format: float example: 0.4 solar: type: number format: float example: 0.5 units: type: object description: Units for each measurement type example: temperature: "C" humidity: "1/100" voltage: "V" current: "mA" power: "mW" metadata: type: object description: Additional metadata about the reading required: - device_id - timestamp - location - version additionalProperties: true properties: device_id: type: string description: Unique identifier for the sensor device example: "esp32-001" timestamp: type: integer format: int64 description: Unix timestamp when readings were taken example: 1679580000 location: type: string description: Firmware version example: "living_room" version: type: string description: Firmware version example: "v1.2.3" ErrorResponse: type: object description: "Standardized error response format for API errors" required: - error - message - details properties: error: type: string description: Error code or identifier message: type: string description: Human-readable error description details: type: object description: Additional error details additionalProperties: true paths: /readings: post: operationId: uploadSensorReading tags: ["Sensor Data Upload"] summary: Submit new sensor readings description: Endpoint for ESP32 devices to submit their sensor data security: - ApiKeyAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SensorReading' responses: '201': description: Reading successfully recorded content: application/json: schema: type: object properties: id: type: string description: ID of the recorded reading success: type: boolean example: true '400': description: Invalid request format content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '401': description: Authentication failed content: application/json: schema: $ref: '#/components/schemas/ErrorResponse'