Multiprotocol Access Product Introduction QuickStart User Guide Development Guide
EDP TCP transparent transmission MQTT Modbus HTTP
FAQ

Query historical device data

Request format: GET

URL: http://api.onenet.hk.chinamobile.com/devices/device_id/datapoints

device_id: to be replaced with device ID

URL Parameters

Name Format Required or not Description
datastream_id string No Data stream ID. Multiple IDs are separated by commas. By default, the query is looking for all data streams.
start string No Start time for extracting data points, measured in seconds, e.g.: 2015-01-10T08:00:35
end string No End time for extracting data points, measured in seconds, e.g.: 2015-01-10T08:00:35
duration int No Query time interval, in seconds
limit int No Limit the maximum number of data points returned by this request, 100 by default. Range: (0, 6000]
cursor string No Specify continuous data extraction from cursor position for this request
sort enum No Sort by time. DESC: in descending order, ASC: in ascending order. By default, sort by ASC.

Return Parameters

Name Format Description
errno int Call error code, where 0 means success.
error string Error description. “succ” means the call is successful.
data json Device-related information returned after interface is successfully called. See the Data Description Table.
Data Description Table
Name Format Description
count string Number of data points returned by this request
cursor string If all data points cannot be returned by this request, the cursor parameter will be returned, and the user can once again request access to the remaining data points along with the cursor parameter.
datastreams array- json Device data stream information in json array. See the Datastreams Description Table.
Datastreams Description Table
Name Format Description
id string Data stream name
datapoints array- json Data point information in json array. See the Datapoints Description Table.
Datapoints Description Table
Name Format Description
at string Data recorded time
value string/int/json... Data point value

Request Example 1

Request the 1st to 100th points of data stream ds of Device 8029377 since 2017-01-01T00:00:00

GET http://api.onenet.hk.chinamobile.com/devices/8029377/datapoints?datastream_id=ds&start=2017-01-01T00:00:00&limit=100 HTTP/1.1

Return Example 1

{
    "errno": 0,
    "data": {
        "cursor": "83900_8029377_1498708525203",
        "count": 100,
        "datastreams": [{
            "datapoints": [{
                "at": "2017-06-23 11:09:46.281",
                "value": "112312"
            }, {
                "at": "2017-06-23 11:09:58.799",
                "value": "112312"
            }, {
                "at": "2017-06-23 11:09:58.802",
                "value": "1213"
            }, {
                "at": "2017-06-23 11:10:17.962",
                "value": "1"
            }, 
            ...
            {
                "at": "2017-06-29 11:55:20.198",
                "value": "hello"
            }],
            "id": "ds"
        }]
    },
    "error": "succ"
}
In this example, only the first 100 data points since 2017-01-01T00:00:00 are returned. In order to continue to receive subsequent data points, you should request to

Request Example 2

Get the 101st to 1100th data points since 2017-01-01T00:00:00

GET http://api.onenet.hk.chinamobile.com/devices/8029377/datapoints?datastream_id=ds&start=2017-01-01T00:00:00&limit=1000&cursor=83900_8029377_1498708525203 HTTP/1.1

Return Example 2

{
    "errno": 0,
    "data": {
        "count": 1000,
        "datastreams": [{
            "datapoints": [{
                "at": "2017-06-23 11:10:41.475",
                "value": "awefa"
            }, {
                "at": "2017-06-23 11:11:12.839",
                "value": "ad3"
            }, 
            ...
            {
                "at": "2017-06-25 11:13:54.249",
                "value": "RA414124124124"
            }, {
                "at": "2017-06-25 21:07:43.024",
                "value": "13dfadfafzfadf#123affad"
            }],
            "id": "ds"
        }]
    },
    "error": "succ"
}

个搜索结果,搜索内容 “

    0 个搜索结果,搜索内容 “