Bulk-Write CSV Data
Write many entries to channel in CSV 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 JSON format, see Bulk-Write JSON 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.csv
URL Parameters
Name | Description |
---|---|
| (Required) Channel ID for the channel of interest. |
URL
example:https://api.thingspeak.com/channels/999990/bulk_update.csv
Content-Type
application/x-www-form-urlencoded
Body Parameters
Name | Description | Value Type |
---|---|---|
write_api_key | (Required) Specify Write API Key for this specific channel. The Write API Key is on the API Keys tab of the channel view. | string |
time_format | (Required) Specify absolute time of the event with
| string |
updates | Bulk data to post to channel. Separate successive
entries with a pipe character ( | See Update Parameters. |
The update contains the data to post to your channel. The parameters appear sequentially in each update in the order shown in the table. Only one of the time specifications appears in each update.
Name | Description | Value-Type |
---|---|---|
timestamp | (Required) If | datetime or integer |
field<X> data | (Required) Field X data, where X is the field ID | any |
latitude | (Required) Latitude in degrees, specified as a value
between | decimal |
longitude | (Required) Longitude in degrees, specified as a value
between | decimal |
elevation | (Required) Elevation in meters | integer |
status | (Required) Message for status field entry | string |
Body Format
Each CSV bulk write contains a Write API key and a time format specification. Each
bulk write can contain multiple updates. Separate successive entries with a pipe
character (|
). Provide data or a blank entry for each sequential
parameter up to the last parameter with valid data.
write_api_key=WRITE_API_KEY&time_format=TIME_FORMAT&updates=TIMESTAMP,FIELD1_VALUE,FIELD2_VALUE,FIELD3_VALUE,FIELD4_VALUE,FIELD5_VALUE,FIELD6_VALUE,FIELD7_VALUE,FIELD8_VALUE,LATITUDE,LONGITUDE,ELEVATION,STATUS | DATETIME_STAMP_OR_SECONDS_FROM_LAST_ENTRY,FIELD1_VALUE,FIELD2_VALUE,FIELD3_VALUE,FIELD4_VALUE,FIELD5_VALUE,FIELD6_VALUE,FIELD7_VALUE,FIELD8_VALUE,LATITUDE,LONGITUDE,ELEVATION,STATUS
write_api_key=XXXXXXXXXXXXXXXX&time_format=absolute&updates=2018-06-14T12:12:22-0500,1,,3,0.4,1.5,1.6,,1.8,40.0,5.4,0,wet|2018-01-30T10:26:23-0500,1.2,2.3,3,4,5,6,7,8,42.0,0.5,50,falling
write_api_key=XXXXXXXXXXXXXXXX&time_format=relative&updates=4,1.1,2,0.3,,,6,7.7,0.8,41.2,19.5,100,ok|3,1,2,3,4,5,6,7,8,41.2,25.1,110,rising
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 must be 15 seconds or more.
MQTT subscriptions do not report updates to the channel from bulk-write operations.
All updates 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.