POST https://industrial.api.ubidots.com/api/devices/{DEVICE_LABEL}
curl -X POST 'https://industrial.ubidots.com/api/v1.6/devices/my-new-device'
-H "X-Auth-Token: BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB"
-H "Content-Type: application/json"
-d '{"temperature": 27}'
curl -X POST 'https://industrial.ubidots.com/api/v1.6/devices/my-new-device'
-H "X-Auth-Token: BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB"
-H "Content-Type: application/json"
-d '{"position": {"value" : 1, "timestamp": 1514808000000, "context":{"lat":-6.2, "lng":75.4}}}'
curl -X POST 'https://industrial.ubidots.com/api/v1.6/devices/my-new-device'
-H "X-Auth-Token: BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB"
-H "Content-Type: application/json"
-d '{"temperature": {"value": 27, "timestamp": 1514808000000}, "humidity": 55, "pressure": {"value": 78, "context":{"name" : "John"}}}'
Request
POST /api/v1.6/devices/{DEVICE_LABEL} HTTP/1.1<CR><LN>
Host: {Endpoint}<CR><LN>
User-Agent: {USER_AGENT}<CR><LN>
X-Auth-Token: {TOKEN}<CR><LN>
Content-Type: application/json<CR><LN>
Content-Length: {PAYLOAD_LENGTH}<CR><LN><CR><LN>
{PAYLOAD}
<CR><LN>
Response
HTTP/1.1 200 OK<CR><LN>
Server: nginx<CR><LN>
Date: Tue, 04 Sep 2018 22:35:06 GMT<CR><LN>
Content-Type: application/json<CR><LN>
Transfer-Encoding: chunked<CR><LN>
Vary: Cookie<CR><LN>
Allow: GET, POST, HEAD, OPTIONS<CR><LN><CR><LN>
{PAYLOAD_LENGTH_IN_HEXADECIMAL}<CR><LN>
{"{VARIABLE_LABEL}": [{"status_code": 201}]}<CR><LN>
0<CR><LN>
The easiest way to send values to Ubidots is by specifying your Device Label in the request path and making a POST
request to it.
Replace {DEVICE_LABEL}
with the unique label of the device you want to send data to. If the device does not yet exist in your Ubidots account, it will be automatically provisioned. Device labels may contain any alphanumerical character without blank spaces, i.e weather-station
, my-home
, esp8266
.
To set variable values, just create a JSON data payload as below:
{"variable-label": VALUE}
{
"variable-label-1":
{"value": VALUE, "timestamp": TIMESTAMP, "context": {"key": CONTEXT_VALUE}},
"variable-label-2":
{"value": VALUE, "timestamp": TIMESTAMP, "context": {"key": CONTEXT_VALUE}},
... ,
... ,
"variable-label-n":
{"value": VALUE, "timestamp": TIMESTAMP, "context": {"key": CONTEXT_VALUE}}
}
Examples
{"temperature": 27}
{"temperature": 27, "humidity": 55, ... ,"pressure": 78}
{"position": {"value" : 1, "timestamp": 1514808000000, "context":{"lat":-6.2, "lng":75.4, "name" : "John"}}}
{
"temperature":
{
"value": 27,
"timestamp": 1514808000000
},
"humidity": 55,
"pressure":
{
"value": 78,
"context":
{
"name" : "John"
}
}
}
timestamp
andcontext
Please Note: The
timestamp
andcontext
parameters are optional.
Timestamp Format
All timestamps must be in milliseconds. You can easily convert dates to timestamp values here.
Location Data
You have a lot of ways to include longitude and latitude when sending your dots to Ubidots. Please refer to this documentation.