Bulk-Write JSON Data
Write many entries to channel in JSON format with single HTTP POST
Description
To conserve device power or group channel updates, you can use the bulk-update API.
When using the bulk-update API, you collect data over time, and then upload the data to
ThingSpeak™. To write data in CSV format, see Bulk-Write CSV
Data
. To write a single entry, see Write Data
.
Note
If you set the React app with the Test Frequency set to On Data Insertion, your React is triggered only once per bulk-write request when the Condition Type matches the Condition, even if the Condition is matched more than once.
Request
HTTP Method
POST
URL
https://api.thingspeak.com/channels/
<channel_id>
/bulk_update.json
URL Parameters
Name | Description |
---|---|
| (Required) Channel ID for the channel of interest. |
URL example:
https://api.thingspeak.com/channels/999990/bulk_update.json
Body Parameters and Object Members
The body of the bulk JSON write operation is a JSON object with the members and arrays listed in these tables.
Name | Description | Value Type |
---|---|---|
write_api_key | (Required for private channels) Specify the Write API Key for this specific channel. You can find the Write API Key on the API Keys tab of the channel view. | string |
updates | (Required) Specify the array of updates to your channel. | array of JSON objects with the members shown in Updates |
An update is a JSON array of JSON objects, that each have the following key-value pairs.
Name | Description | Value Type |
---|---|---|
created_at | (Required unless | string |
delta_t | (Required unless | string |
field | (Optional) Field X data, where X is the field ID | any |
latitude | (Optional) Latitude in degrees, specified as a value
between | number |
longitude | (Optional) Longitude in degrees, specified as a value
between | number |
elevation | (Optional) Elevation in meters | string |
status | (Optional) Message for status field entry | <string> |
Content-Type
application/json
Body Format
{ "write_api_key": "WRITE_API_KEY", "updates": [{ "created_at": "DATETIME_STAMP", "field1": FIELD1_VALUE, "field2": FIELD2_VALUE, "field3": FIELD3_VALUE, "field4": FIELD4_VALUE, "field5": FIELD5_VALUE, "field6": FIELD6_VALUE, "field7": FIELD7_VALUE, "field8": FIELD8_VALUE, "Latitude": LATITUDE_VALUE, "Longitude": LONGITUDE_VALUE, "Elevation": ELEVATION_VALUE, "Status": "STATUS_STRING" }, { "created_at": "DATETIME_STAMP", "field1": "FIELD1_VALUE", Etc... } ] }
created_at
{ "write_api_key": "WRITE_API_KEY", "updates": [{ "created_at": "2018-01-30 10:26:2 -0500", "field1": "1.0", "field2": "2.0" }, { "created_at": "2018-02-02 11:27:27 -0500", "field1": "1.1", "field2": "2.2", "status": "well done" } ] }
delta_t
{ "write_api_key": "WRITE_API_KEY", "updates": [{ "delta_t": 4, "field1": 1.0, "field2": "2.0" }, { "delta_t": 2, "field1": 1.1, "field2": 2.2, "elevation": 6, "status": "Good" } ] }
Response
Success
200 OK
The response is a JSON object indicating success:
{ "success": true }
Error
For the full list, see Error Codes.
Limitations
The number of messages in a single bulk-update is limited to 960 messages for users of free accounts and 14,400 messages for users of paid accounts. The time interval between sequential bulk-update calls should be 15 seconds or more.
MQTT subscriptions do not report updates to the channel from bulk-write operations.
All objects in the updates array must use same time format.
All timestamps must be unique. If you submit duplicate timestamps, all of your updates are rejected, otherwise only updates with timestamps already in channel are rejected.