X bit API definition DOCUMENT - lm-xbit/monitor-platform GitHub Wiki

X-bit API definition DOCUMENT

Introduction

This doc is to define the RESTFul API of V1 x-bit

architecture

architecture

APIs

User Manager

  1. Register

    POST 
    https://hostname/rest/settings/register
    {
      "username": xxx,
      "password": xxx
    }
    

    ie:

    https://52.197.83.138/rest/settings/register
    {
        "username": "robin.deng",
        "password": "xxxxxxxxxx"
    }
    
  2. Login:

    POST
    https://hostname/rest/settings/login
    {
       "username": xxx,
       "password": xxx
    }
    

    Response:

    {
        "status": 200,
        "errmsg": "OK",
        "data": {
            "id": 1
        }
    }
    
  3. List user Info: (We can use session or basic authentication)

    GET 
    https://hostname/rest/settings/user/<id>
    {
        "status": 200,
        "data": 
        {
            "username": xxx,
            "userKeys":
            [
                "key1",
                "key2",
                ...
            ]
        }
    }
    
  4. Update User Info

    PUT 
    https://hostname/rest/settings/user/<id>
    {
        "password": xxx,
        "userKeys":
        [
            "key1",
            "key2",
            ...
        ]
    }
    
  5. Delete a user

    DELETE
    https://hostname/rest/settings/user/<id>
    {
        "status": 200
    }
    

Data API

  1. raw data

    GET
    https://hostname/rest/data/<key>
    {
        "status": 200,
        "message": "OK",
        "data":
        [
            {
                "timestamp": xxxx,
                "location": {
                    "latitude": xxx,
                    "longitude": xxx,
                    "altitude": xxx,
                    "accuracy":xxx
                }
            }
        ]
    }
    
    GET
    https://hostname/rest/data/<key>?from=1472719254000&to=1472719354000&aggs=3
    {
        "status": 200,
        "message": "OK",
        "data":
        [
            {
                "timestamp": xxxx,
                "location": {
                    "latitude": xxx,
                    "longitude": xxx,
                    "altitude": xxx,
                    "accuracy":xxx
                }
            }
        ]
    }
    

    from: it's the start timestamp you want to get the aggregation data to: the end timestamp you want to get the aggregation data aggs: the aggregation time in minute, ie. is aggs=3, then it means that all the data in 3 minutes will be aggregate to only one data

  2. upload data

    POST 
    https://hostname/rest/data/<key>
    [
        {
            "timestamp": xxxx,
            "metrics": [{
                 "name": "metric1", "value": 123
             }, 
             ...,  
             {
                 "name": "metricN", "value": 789
             }]
        }
    ]
    
    
  3. graph data

    GET
    https://hostname/rest/data/<key>
    {
        "status": 200,
        "message": "OK",
        "data":
        [
            {
                "timestamp": xxxx,
               "location": {
                    "latitude": xxx,
                    "longitude": xxx,
                    "altitude": xxx,
                    "accuracy":xxx
                }
            }
        ]
    }
    
    
⚠️ **GitHub.com Fallback** ⚠️