Sensecap Opanapi Document en
Sensecap Opanapi Document en
HTTP API
HTTP API Quickstart
HTTP API Access Guide
SenseCAP SDK
Java SDK
Appendix
List of Sensor Types
List of Measurement IDs
List of Device Status IDs
page 1
PDF last generated:2021/3/30
SenseCAP API is for users to manage IoT devices and data. It combines three types of API methods: HTTP protocol, MQTT protocol,
and Websocket protocol.
With HTTP API, users can manage LoRa and NB-IoT devices, to get RAW data or historical data.
With MQTT API, users can subscribe to the sensor’s real-time measurement data through the MQTT protocol.
With Websocket API, users can get real-time measurement data of sensors through Websocket protocol.
page 2
PDF last generated:2021/3/30
Prerequisite
If you do not have an account, please register for the SenseCAP Portal.
China Stationhttps://sensecap.seeed.cn
Global Stationhttps://sensecap.seeed.cc
4. Click “API ID”, and get the “API ID” and “Access API keys” after entering the password.
page 3
PDF last generated:2021/3/30
username = API ID
You should replace and with the one you got before. The command will output like the following
{
"code": "0",
"data": [
{
"group_name": "Default",
"group_uuid": ""
},
{
"group_name": "test group",
"group_uuid": "80523B280630E611"
},
{
"group_name": "demo",
"group_uuid": "EBAD5387C4FC8711"
}
]
}
page 4
PDF last generated:2021/3/30
HTTP HOST
China Station: https://sensecap.seeed.cn/openapi
HTTP HEADER
Request
key description
Response
key description
you can create access keys via SenseCAP Portal. Please refer to quickstart to see how to get an access key.
API Response
All response key follow the lowercase and underscore convention.
{
"code":"0",
"data":"
// string
"
}
{
"code":"0",
"data":{
// object
}
}
{
"code":"0",
"data":[
// Array
]
}
Error Response
{
"code":"1001",
"msg":"error message"
}
page 6
PDF last generated:2021/3/30
Response
Name Description
org_id organization id
Example request
{
"code": "0",
"data": {
"org_id": "919136109886",
}
}
page 7
PDF last generated:2021/3/30
Request
Body Parameters
Response
Name Description
Example request
{
"code": "0",
"data": {
"group_name": "test group",
"group_uuid": "478ED9E2A290F401"
}
}
History version
version description
Request
Body Parameters
page 8
PDF last generated:2021/3/30
Example request
{
"code": "0",
"data": {}
}
Request
Query Parameters
Example request
{
"code": "0",
"data": {}
}
Response
Name Description
Example request
page 9
PDF last generated:2021/3/30
{
"code": "0",
"data": [
{
"group_name": "Default",
"group_uuid": ""
},
{
"group_name": "test group",
"group_uuid": "80523B280630E611"
},
{
"group_name": "demo",
"group_uuid": "EBAD5387C4FC8711"
}
]
}
History version
version description
Request
Path Parameters
Body Parameters
device
devices (required) array EUI
Example request
{
"code": "0",
"data": {}
}
page 10
PDF last generated:2021/3/30
Device list
GET {host}/list_devices
get the list of devices
Request
Query Parameters
device type:1-gateway, 2-
device_type string node(default)
group unique
group_uuid string identification
Response
Name Description
Example request
{
"code": "0",
"data": [
{
"device_eui": "2CF7F12010700088",
"device_name": "device2CF7F12010700088"
},
{
"device_eui": "2CF7F1201070001C",
"device_name": "device2CF7F1201070001C"
},
{
"device_eui": "2CF7F12104700010",
"device_name": "US915-2CF7F12104700010"
}
]
}
History version
version description
page 11
PDF last generated:2021/3/30
Request
Body Parameters
device type:1-gateway, 2-
device_type string node(default)
Response
Name Description
position_source GPS position source, 0- manually set position, 1- position reported by the device
iccid ICCID
msisdn MSISDN
status Status, 0- unknown, 1- normal, 2- single stop, 3- stop, 4- pre-sale number, 5- sale number, 6- transfer, 7-
sleep, 8- to be activated
Example request
page 12
PDF last generated:2021/3/30
{
"code": "0",
"data": [
{
"frequency": "470",
"device_eui": "2CF7F15000100122",
"device_name": "设备2CF7F15000100122",
"device_network": 2,
"position": {
"latitude": 113.931225,
"longitude": 22.569792
},
"position_source": 0,
"hardware_version": "",
"software_version": "23.0",
"sim": {
"iccid": "89860446091891237424",
"msisdn": "1440467057424",
"activateTime": "2019-12-03T00:00:00.000Z",
"expiryDate": "2020-11-30T00:00:00.000Z",
"status": 1,
"flow": 0,
"residueFlow": 1024
}
}
]
}
History version
version description
POST {host}/list_device_channels
Request
Body Parameters
Response
Name Description
page 13
PDF last generated:2021/3/30
Name Description
channel_type Channel type,1: 485 Sensor; 2: Seeed Sensor; 3:485 Output; 4: Seeed Output
Example request
{
"code": "0",
"data": [
{
"device_eui": "2CF7F15000100147",
"channels": [
{
"channel_index": 1,
"sensor_id": "2CF7F13011900006",
"sensor_status": 1,
"channel_type": 2,
"sensor_type": "1005",
"channel_name": "",
"measurement_ids": [
"4101"
]
}
]
},
{
"device_eui": "2CF7F16221200060",
"channels": [
{
"channel_index": 11,
"sensor_id": "0111006221200060",
"sensor_status": 1,
"channel_type": 1,
"sensor_type": "2001",
"channel_name": "",
"measurement_ids": [
"4097",
"4105"
]
}
]
}
]
}
POST {host}/view_device_running_status
page 14
PDF last generated:2021/3/30
Request
Body Parameters
Response
Name Description
report_frequency If the device reports frequency per minute and returns -1, the device fails to report this information
Example request
{
"code": "0",
"data": [
{
"device_eui": "2CF7F16221200060",
"latest_message_time": "2020-04-20T07:06:32.944Z",
"online_status": 0,
"battery_status": 1,
"report_frequency": 0
},
{
"device_eui": "2CF7F1101300001C",
"latest_message_time": "",
"online_status": 0,
"battery_status": 1,
"report_frequency": -1
}
]
}
GET https://sensecap-statics.seeed.cn/refer/def/sensor.json
Get a list of the physical measurements of all the sensors. The reference list of sensor measurements is stored in the cloud as a file
that you can access directly
Response
Name Description
en English description
page 15
PDF last generated:2021/3/30
Name Description
measurementId Measurement id, which records the name and unit of each measurement
Example
{
"zh-cn": {
"sensorType": {
"1001": "空⽓温湿度传感器",
"1003": "光照强度传感器",
...
},
"measurementId": {
"4097": ["空⽓温度", "℃"],
"4098": ["空⽓湿度", "%RH"],
...
}
},
"en": {
"sensorType": {
"1001": "Air Temperature and Humidity Sensor",
"1003": "Light Intensity Sensor",
...
},
"measurementId": {
"4097": ["Air Temperature", "℃"],
"4098": ["Air Humidity", "%RH"],
...
}
},
"sm": {
"1001": ["4098", "4097"],
"1003": ["4099"],
...
},
"rg": {
"4097": "-40~90",
"4098": "0~100",
...
}
}
History version
version description
Bind device
POST {host}/device/bind
bind device to account
Request
Body Parameters
page 16
PDF last generated:2021/3/30
device positon,
longitude string longitude
device
latitude string postion,latitude
Example request
{
"code": "0",
"data": {}
}
History version
version description
Unbind device
POST {host}/delete_devices
remove the binding relationship of this node and the organization of API caller, but user can bind it back with SenseCAP App.
Request
Body Parameters
Example request
page 17
PDF last generated:2021/3/30
{
"code": "0",
"data": {}
}
page 18
PDF last generated:2021/3/30
Request
Query Parameters
sensor measurement
measurement_id string ID
Response
Name Description
Example request
{
"code": "0",
"data": [
{
"channel_index": 32,
"points": [
{
"measurement_value": 185,
"measurement_id": "4104",
"time": "2020-03-26T07:28:28.575Z"
}
]
}
]
}
History version
version description
page 19
PDF last generated:2021/3/30
version description
To obtain the historical data of the specified sensor node device, the data returned for a maximum of one month can only be queried
for the last three months
Request
Query Parameters
sensor measurement
measurement_id string ID
Response
Returns the representation of the format sampled column data
Name Description
list[1] Measured value,contains the measured value and the measured time
Example request
page 20
PDF last generated:2021/3/30
{
"code": "0",
"data": {
"list": [
[[1, "4097"], [1, "4098"], [2, "4097"]],
[
[ [22, "2020-03-06T23:48:00Z"], [23, "2020-03-06T23:48:00Z"], [24, "2020-03-06T23:48:00
Z"]]
[ [22, "2020-03-06T23:48:00Z"], [23, "2020-03-06T23:48:00Z"] ]
[ [22, "2020-03-06T23:48:00Z"], [23, "2020-03-06T23:48:00Z"] ]
]
]
}
}
list[0][0]:Represents the channel and the measured value id.In this example, the channel is 1 and the measured value id is
4097
list[1][0][0]:In this example, the first measurement result corresponding to the measurement value id of channel 1 is 4097, the
measurement value is 22, and the measurement time is 2020-03-06 t23:48:00Z
History version
version description
GET {host}/aggregate_chart_points
Divide the large data segment into small data segments, then output the average value of each segment. The return data is up to one
year and 250 points each measurement at most.If more than 250 points, it will automatically re-divide the time period to return 250
points.
Request
Query Parameters
sensor measurement
channel_index string ID
page 21
PDF last generated:2021/3/30
timestamp, unit
millisecond,
time_end number Default current time
Response
Returns the representation of the format sampled column data
Name Description
Example request
{
"code": "0",
"data": [
{
"channel": 1,
"lists": [
{
"average_value": 7.27,
"measurement_id": "4106",
"time": "2019-05-25T23:42:00.000Z"
},
{
"average_value": 6.85,
"measurement_id": "4106",
"time": "2019-05-27T10:45:00.000Z"
}
]
}
]
}
History version
version description
page 22
PDF last generated:2021/3/30
Setup
Install or download Mosquitto.
Credentials
Browse SenseCAP Portal, navigate to “Security/Access API keys”, click the “Create Access Key”, and you can get the “Access API
keys”, set down it as <Password>, and also “Organization ID” as <OrgID>.
page 23
PDF last generated:2021/3/30
OrgID = Organization ID
mosquitto_sub \
-h sensecap-openstream.seeed.cn \
-t '/device_sensor_data/<OrgID>/+/+/+/+' \
-u 'org-<OrgID>' \
-P '<Password>' \
-I 'org-<OrgID>-quickstart' \
-v
Please replace the Organization ID and Access API Key you just obtained with the <OrgID> and <Password> above.
2.Power up devices, while devices keep sending messages, you should receive the data like:
/device_sensor_data/1234/2CF7F12000000001/1/vs/4105 {"value":2,"timestamp":1544151824139}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4097 {"value":23,"timestamp":1544151900992}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4101 {"value":101629,"timestamp":1544151901112}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4098 {"value":71,"timestamp":1544151900992}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4099 {"value":69.12,"timestamp":1544151902224}
/device_sensor_data/xxxx/2CF7F12XXXXXXXXX/1/vs/4100 {"value":437,"timestamp":1544151922137}
page 24
PDF last generated:2021/3/30
Example:
Subscribe to the temperature value collected by the Air Temperature and Humidity Sensor (DeviceEUI: 2CF7F12210400083;Channel:
1;).The temperature measurement ID is 4097.
Replace <OrgID> as Organization ID, <Password> as Access API Key, execute the command:
mosquitto_sub \
-h sensecap-openstream.seeed.cn \
-t '/device_sensor_data/<OrgID>/2CF7F12210400083/1/vs/4097' \
-u 'org-<OrgID>' \
-P '<Password>' \
-I 'org-<OrgID>-quickstart' \
-v
/device_sensor_data/521853156991/2CF7F12210400083/1/vs/4097 {"value":28,"timestamp":1561373812474}
Congratulations! Now you know how to monitor and receive messages via MQTT. Go build something awesome!
page 25
PDF last generated:2021/3/30
ClientID: org-<Organization ID>-<Random ID>, replace <Orgnization ID> with you got from SenseCAP Portal, and replace
<Random ID> with you randomly generated Numbers and lowercase letters.
Username: org-<Organization ID>, replace <Organization ID> with you got from dashboard (refer to the quickstart).
Password: Get Access API keys on your SenseCAP Portal “security /API Access Key” (refer to the quickstart).
You can “subscribe” to receive messages. “subscribe” is the most common way to continuously monitor the telemetry data from
devices.
Message Topic
Field Description
OrgID Your “Organization ID”, you can find this on SenseCAP Portal. You own a unique Organization ID, and all the
topics will need it.
Reserved Reserved
Note: “+” means that there is no filtering condition for this field, matching all possible configurations. So, “/+/+/+/+” means
to listen for all “<DeviceEUI>”, “<Channel>”, “<SensorEUI>”, “<MeasurementID>”
Topic can specify filtering conditions to implement listening on specified devices, channels and measurement types. For example,
you can only listen for Device whose device ID is “2F000000000000”, then you can replace the <DeviceEUI> field with
2F000000000000.
The “2F000000000000” in this example must be a device that you have already bound to your account. And you should always
remember to replace <OrgID> with your own “Organization ID”.
Message Body
{
"value": 437,
"timestamp": "1544151922137"
}
This is a sensor measurement data uploaded by a device, which conforms to the JSON format and can be parsed by JSON parser. In
general, for most functional requirements, a body needs to be used in conjunction with some fields in the topic.
page 26
PDF last generated:2021/3/30
Field Description
Field Description
OrgID Your “Organization ID”, you can find this on SenseCAP Portal. You own a unique Organization ID, and all the topics
will need it.
Reserved Reserved
Subscribe to the required StatusID according to the list of device state IDs to avoid subscribing to unexpected IDs
Message Body
{
"value": "437",
"timestamp": "1544151922137"
}
Field Description
page 27
PDF last generated:2021/3/30
Overview
Prerequisite
If you do not have an account, please register for the SenseCAP Portal.
China Stationhttps://sensecap.seeed.cn
Global Stationhttps://sensecap.seeed.cc
4. Click “API ID”, and get the “API ID” and “Access API keys” after entering the password.
page 28
PDF last generated:2021/3/30
Maven coordinates
<dependency>
<groupId>cc.seeed.sensecap-sdk</groupId>
<artifactId>sensecap-java-sdk</artifactId>
<version>1.0-RELEASE</version>
</dependency>
SenseCAPClient initialization
//client Configure
{
String accessId = " ";
String accessKey = "";
int region = RegionType.SENSECAP_CC.getRegion();
//SenseCAPClient senseCAPClient = new SenseCAPClientBuilder().buildConfig(accessId, accessKey, region)
;
OpenApiConfig openApiConfig = new OpenApiConfig(accessId, accessKey, region);
SenseCAPClient senseCAPClient = new SenseCAPClientBuilder().buildConfig(openApiConfig);
}
Organization
Get organizationId
Request parameters
None
page 29
PDF last generated:2021/3/30
Return values
Type Description
long organizationId
Request Example
Group
Create Group
Request parameters
Return values
Type Description
Request Example
Rename group
Request parameters
page 30
PDF last generated:2021/3/30
Return values
None
Request Example
Remove group
Request parameters
Return values
None
Request Example
Request parameters
None
Return values
Type Description
Request Example
page 31
PDF last generated:2021/3/30
Device
Move device
Request parameters
Return values
None
Request Example
Request parameters
Return values
Type Description
page 32
PDF last generated:2021/3/30
Request Example
Request parameters
Return values
Type Description
Request Example
Request parameters
page 33
PDF last generated:2021/3/30
Return values
Type Description
Request Example
Request parameters
Return values
Type Description
Request Example
page 34
PDF last generated:2021/3/30
Bind device
public boolean bindDevice(String eui, String code, String deviceName, String groupUUID, String longitude
, String latitude) throws BaseException;
Request parameters
Return values
None
Request Example
Delete device
Request parameters
Return values
Type Description
Request Example
page 35
PDF last generated:2021/3/30
Request Example
Telemetry data
Request parameters
Return values
Type Description
Request Example
Request parameters
page 36
PDF last generated:2021/3/30
Parameter description
[startTime>0,endTime>0] Get the historical data of the specified time range [-30d,now]
(startTime=0,endTime>0] Get the default one day old to endTime historical data [-1d,endTime]
[startTime>0,endTime=0) Get the historical data of the start time and subscribe to the latest news [startTime,–]
Return values
Type Description
Request Example
page 37
PDF last generated:2021/3/30
Explain
Divide the large data segment into small data segments, then output the average value of each segment.
The return data is up to one year and 250 points each measurement at most.If more than 250 points, it will automatically re-
divide the time period to return 250 points.
Request parameters
Return values
Type Description
Request Example
Explain
Return all data points within one day (inclusive)
If the time is greater than one day, the average value of data points in the interval range is returned
interval should not be less than the minimum interval of data reporting
Request parameters
page 38
PDF last generated:2021/3/30
Return values
Type Description
Request Example
page 39
PDF last generated:2021/3/30
2007 Soil Temperature and VWC Sensor 4110, Soil Volumetric Water Content,
4102 Soil Temperature
page 40
PDF last generated:2021/3/30
2019 Multilayer Soil Moisture and Temperature Sensor 4144, Soil Temperature-30cm,
4138, Soil Moisture-10cm,
4139, Soil Moisture-20cm,
4140, Soil Moisture-30cm,
4141, Soil Moisture-40cm,
4142, Soil Temperature-10cm,
4143, Soil Temperature-20cm,
4145 Soil Temperature-40cm
page 41
PDF last generated:2021/3/30
4106 pH 0~14 PH
page 42
PDF last generated:2021/3/30
page 43
PDF last generated:2021/3/30
设备状态ID表
.
SensorHub
3000 battery
LoraPP Node
LoraWan Node
page 44
PDF last generated:2021/3/30
10000 Framework analysis error An unknown error has occurred in the system
page 45