Skip to content

X bit API definition DOCUMENT

bstsnail edited this page Aug 2, 2016 · 11 revisions

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,
                "metrics": [{
                     "name": "metric1", "value": 123
                 }, ...,  {
                     "name": "metricN", "value": 789
                 }]
            }
        ]
    }
    
  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,
                "metrics": [{
                     "name": "metric1", "value": 123
                 }, ...,  {
                     "name": "metricN", "value": 789
                 }]
            }
        ]
    }
    

Clone this wiki locally