HTTP Inbound
In this guide, we’ll show you how to send device data using HTTP.
Getting Started
Login to myDevices Console and navigate to Integrations.
Select the Inbound integration: HTTP.
Provide a name for the integration and click Generate.
Once the integration is created, copy the URL, Client ID and API Key to send data.
The request body must have the following payload:
{
"eui": "UNIQUE_DEVICE_ID",
"format": "json", // hex or base64 is also allowed
"data": { // JSON object or string. Normalize the data with Device Template and Codec
"temp": 20
}
}
After successfully sending the data, you will need to create a device template. Follow this guide to create one.
Example CURL request
curl --request POST \
--url https://hub.m2c.io/v3/ingress/CLIENT_ID?apiKey=API_KEY \
--header "Content-Type: application/json" \
--data '{
"eui": "sim-5241-6e82-ac46",
"format": "json",
"ignore_codec": true,
"data": [{"channel":4,"type":"temp","unit":"c","value":23.62},{"channel":5,"type":"batt","unit":"v","value":99}]
}'
Example Python request
import requests
url = "https://hub.m2c.io/v3/ingress/CLIENT_ID?apiKey=API_KEY"
headers = {
"Content-Type": "application/json"
}
data = {
"eui": "sim-5241-6e82-ac46",
"format": "json",
"ignore_codec": True,
"data": [
{"channel": 4, "type": "temp", "unit": "c", "value": 23.62},
{"channel": 5, "type": "batt", "unit": "v", "value": 99}
]
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())
Example Javascript request
const url = "https://hub.m2c.io/v3/ingress/CLIENT_ID?apiKey=API_KEY";
const headers = {
"Content-Type": "application/json"
};
const data = {
eui: "sim-5241-6e82-ac46",
format: "json",
ignore_codec: true,
data: [
{ channel: 4, type: "temp", unit: "c", value: 23.62 },
{ channel: 5, type: "batt", unit: "v", value: 99 }
]
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Custom JSON Payload
{
"eui": "UNIQUE_DEVICE_ID",
"format": "json",
"data": {
"temp": 20
}
}
JSON body Example Using Cayenne LPP
{
"eui": "UNIQUE_DEVICE_ID",
"format": "hex",
"data": "0367014a046882"
}
Example JSON Using MQTT API Payload
{
"eui": "UNIQUE_DEVICE_ID",
"format": "json",
"data": [
{
"channel": 1,
"value": 16.4,
"type": "temp",
"unit": "c"
},
{
"channel": 2,
"value": 75,
"type": "rel_hum",
"unit": "p"
},
{
"channel": 5,
"value": 75,
"type": "batt",
"unit": "v"
},
{
"channel": 10,
"value": 1,
"type": "digital_sensor",
"unit": "d"
},
{...}
]
}
The data property must be a JSON array of objects, each element having channel
, value
, type
and unit
porperties. Refer to the list of our
supported data types) for the type
and unit
properties.
Image Upload API (Preview)
The following endpoint consumes image stream and sensor data to be processed on myDevices platform.
Method
Method | URI | Name | Summary |
---|---|---|---|
POST | https://hub.m2c.io/v3/networks/iotinabox/data | Image Uplink | Sends image and telemetry data |
Headers
Header | Value |
---|---|
Content-Type | multipart/form-data |
x-subscription-key | API Key |
One of the part of the body should be set to image
with the filename and additional parts can be sent with sensor data. The key would be the channel number ch_x
and value would follow our MQTT channel based payload: type,unit=value
. Supported list of data types
Body
Key | Value |
---|---|
eui | fc0f860000000001f3 - Device ID |
snapshot | route65.jpg |
ch_1024 | file,image |
ch_x | type,unit=value |
... | ... |
Example Curl Command
curl --request POST \
--url https://hub.m2c.io/v1/networks/iotinabox/data \
--header 'x-subscription-key: API-KEY' \
--header 'content-type: multipart/form-data' \
--form snapshot=@file.jpeg \
--form 'ch_1024=file,image=snapshot' \
--form 'ch_171=temp,f=75' \
--form 'ch_6=temp,f=75' \
--form 'ch_4=rel_hum,p=80' \
--form 'eui=fc0f860000000001f3'