API Usage Documentation

This API allows you to query time-series data of temperature and humidity sensors stored in a database. Below are the details for using the available API endpoints.

Base URL

The base URL for accessing the API is:

https://api.nasathome.top/data/logger

Query Parameters

The following query parameters are used in the API requests:

If no sensors parameter is provided, the response will include both temperature_status and humidity_status data for all times.

Examples

Here are some examples of how to query the API:

1. Default Behavior (No Parameters)

Returns status data for the entire database:

https://api.nasathome.top/data/logger

2. Query with Start and End Times

Returns temperature data from 2024/11/01 to 2024/11/21/13:30:

https://api.nasathome.top/data/logger?start=2024/11/01&end=2024/11/21/13:30&sensors=temp

3. Query with Only End Time

Returns temperature data up to 2024/11/21/12:00:

https://api.nasathome.top/data/logger?end=2024/11/21/12:00&sensors=temp

4. Query for Both Sensors

Returns both temperature and humidity data for the entire database:

https://api.nasathome.top/data/logger?sensors=temp?humidity

5. Query with Missing Parameters

If no start or end parameters are provided, the API will return data starting from the beginning or up to the latest available data. For example:

https://api.nasathome.top/data/logger?sensors=humidity

Returns humidity data for the entire database.

Response Format

The API will return a JSON response with the following structure:

[
    {
        "time": "2024-11-01 00:00",
        "temperature_status": 1,
        "humidity_status": 1,
        "temperature": 22.5,
        "humidity": 60
    },
    {
        "time": "2024-11-01 01:00",
        "temperature_status": 1,
        "humidity_status": 0,
        "temperature": 23.0,
        "humidity": 55
    },
    ...
]
        

The JSON object contains the following fields:

Error Responses

If the request is invalid, the API will return an error response. Example:

{
    "error": "Invalid datetime format. Must be yyyy/mm/dd[/hh[:mm]]."
}
        

Make sure to check the format of the start and end times, as well as the validity of the sensors parameter.