一个datapoint是由key和value组成的键值对.
对该URL的一个HTTP POST请求会为指定的传感器创建一个新的数据点, 使用此API来为传感器存储历史数据.
http://api.yeelink.net/v1.0/device/<device_id>/sensor/<sensor_id>/datapoints
Note: 目前限定相邻数据上传间隔须大于等于10s, 过于频繁的请求会收到406 Response.
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
device_id | true | int | 设备ID |
sensor_id | true | int | 传感器ID |
JSON
一个datapoint是由key和value组成的键值对.
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
key | true | timestamp | 键 |
value | true | binary | 值 |
key为timestamp, value为数值
key为timestamp, value为JSON格式, 由经度、纬度、速度等GPS信息组成; 同时可以指定是否修正地图上显示的偏移.
key为用户自定义字符串, 大小限定为128个字符; value为JSON格式,由用户自定义具体内容, 大小限定为1024个字符.
key为timestamp, value为图像二进制信息;
不支持
Note: key为唯一索引; timestamp为ISO 8601标准时间格式(默认时区为中国标准时间CST), 例如:2012-03-15T16:13:14.
{ "timestamp":"2012-03-15T16:13:14", "value":294.34 }
{ "timestamp":"2012-03-15T16:13:14", "value":{"lat":35.4567,"lng":46.1234,"speed":98.2} }
{ "timestamp":"2012-03-15T16:13:14", "value":{"lat":35.4567,"lng":46.1234,"speed":98.2,"offset":"yes"} }
{ "key":"e10adc3949ba59abbe56e037f20f884e", "value":{...} }
[ {"timestamp": "2012-06-15T14:00:00", "value":315.01}, {"timestamp": "2012-06-15T14:00:10", "value":316.23}, {"timestamp": "2012-06-15T14:00:20", "value":317.26}, {"timestamp": "2012-06-15T14:00:30", "value":318}, {"timestamp": "2012-06-15T14:00:40", "value":317} ]
POST
HTTP Headers only
需要在HTTP Header中增加API Key来授权写入操作, 具体请参照API Key.
curl --request POST --data-binary @datafile.txt --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.yeelink.net/v1.0/device/12/sensor/3/datapoints
Note:需要在HTTP Header中增加API Key来授权写入操作, 具体请参照API Key. 支持一次传送一个数据或者批量上传.
根据设备ID编辑已经接入的数据点.
http://api.yeelink.net/v1.0/device/<device_id>/sensor/<sensor_id>/datapoint/<key>
Note: 对该URL
的一个HTTP PUT
请求将更新指定数据,其中<device_id>为所要更新的数据所属设备的id,<sensor_id>为所要更新的数据所属的传感器的id.若您的客户端不支持PUT请求, 请使用url方式模拟, 具体参照模拟PUT, DELETE请求.
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
device_id | true | string | 设备ID |
sensor_id | true | string | 传感器ID |
key | true | string | 为所要更新数据的时间戳(ISO 8601格式) |
PUT
HTTP Headers only
JSON
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
value | true | float | 值 |
{ "value": 39.4 }
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
value | true | json | {"lat":35.4321,"lng":46.3451,"speed":98.2} |
{ "value": {"lat":35.4321,"lng":46.3451,"speed":98.2} }
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
value | true | json | json |
{ "value": {...} }
数值型传感器和gps型传感器, <key>为所要更新数据的时间戳(ISO 8601格式).
curl --request PUT --data-binary @datafile.txt --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.yeelink.net/v1.0/device/12/sensor/3/datapoint/2012-03-15T16:13:14
泛型传感器, <key>为用户自定义的字符串, 在请求的URL中需要做urlencode.
curl --request PUT --data-binary @datafile.txt --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.yeelink.net/v1.0/device/12/sensor/3/datapoint/2012-03-15T16:13:14
微博抓取器不支持;
Note:只需将要修改的数据值放到datafile.txt中,需要在HTTP Header中增加API Key来授权写入操作, 具体请参照API Key.
对该URL的请求返回指定key的datapoint, 若未指定key, 则返回该sensor的最新数据.
http://api.yeelink.net/v1.0/device/<device_id>/sensor/<sensor_id>/datapoint/<key>
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
device_id | true | string | 设备ID |
sensor_id | true | string | 传感器ID |
key | true | string | 数值和GPS型为数据的时间戳,泛型为自定义字符串 |
GET
请求的传感器信息
JSON
添加Key
{ "value": 39.4 }
{ "value": {"lat":35.4321,"lng":46.3451,"speed":98.2} }
{ "value": {...} }
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
status_cnt | true | int | 未读微博数 | follower_cnt | true | int | 新增好友数 | msg_cnt | true | int | 新消息数 |
{ "status_cnt":0,"follower_cnt":0,"msg_cnt":0 }
未添加Key
{ "timestamp":"2012-03-15T16:13:14", "value": 39.2 }
{ "timestamp":"2012-03-15T16:13:14", "value": {"lat":35.4321,"lng":46.3451,"speed":98.2} }
{ "key":"e10adc3949ba59abbe56e037f20f884e", "value": {...} }
需要在HTTP Header中增加API Key来授权GET操作, 具体请参照API Key.
Note:对于数值型传感器和gps型传感器, <key>为所要查看数据的时间戳(ISO 8601格式).
curl --request GET --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.yeelink.net/v1.0/device/12/sensor/3/datapoint/2012-03-15T16:13:14
Note:对于泛型传感器,
curl --request GET --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.yeelink.net/v1.0/device/12/sensor/3/datapoint/e10adc3949ba59abbe56e037f20f884e
Note:微博抓取器 不支持参数key;
http://api.yeelink.net/v1.0/device/<device_id>/sensor/<sensor_id>/datapoint/<key>
Note:对该URL
的一个HTTP DELETE
请求将删除指定<key>的数据, 其中<sensor_id>为所要删除的数据所属传感器的id,<device_id>为所要删除的数据所属设备的id. 若您的客户端不支持DELETE请求, 请使用url方式模拟, 具体参照模拟PUT, DELETE请求.
DELETE
HTTP Headers only
JSON
参数名 | 必需 | 类型 | 说明 |
---|---|---|---|
device_id | true | string | 设备ID |
sensor_id | true | string | 传感器ID |
key | true | string | 数值和GPS型为数据的时间戳,泛型为自定义字符串 |
需要在HTTP Header中增加API Key来授权DELETE操作, 具体请参照API Key.
curl --request DELETE --header "U-ApiKey: YOUR_API_KEY_HERE" --http://api.yeelink.net/v1.0/device/12/sensor/3/datapoint/2012-03-15T16:13:14
Note:对于数值型传感器和gps型传感器, <key>为所要更新数据的时间戳(ISO 8601格式).
curl --request DELETE --header "U-ApiKey: YOUR_API_KEY_HERE" --http://api.yeelink.net/v1.0/device/12/sensor/3/datapoint/e10adc3949ba59abbe56e037f20f884e
Note:对于泛型传感器, <key>为用户自定义的字符串, 在请求的URL中需要做urlencode.