Bulk upload with nodeJs | ThingSpeak API | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.

Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Bulk upload with nodeJs
No permission to create posts
August 8, 2019
9:37 am
New Member
Forum Posts: 2
Member Since:
August 8, 2019
sp_UserOfflineSmall Offline

Hi there
I need to do a bulk upload to Thingspeak of a CSV file.
Unfortunately, I can only find code examples that use Python.
But under no circumstances will I use Python.
On my Raspberry Pi, I primarily use nodejs. I have not been able to find code examples for this.
I know you need an httpXMLrequest (POST). But how?
Best regards Poul C

December 3, 2019
2:29 pm
New Member
Forum Posts: 2
Member Since:
May 2, 2019
sp_UserOfflineSmall Offline

This works for me:

async function bulkUpdate(url, bulkJson) {
const response = await fetch(url, {
method: 'post',
body: JSON.stringify(bulkJson),
headers: {
'Content-Type': 'application/json'

This function can be called like this:

url = 'https://api.thingspeak.com/channels/' + channel + '/bulk_update.json';
bulkUpdate(url, bulkJson);

In the above, 'channel' is your ThingSpeak channel number. 'bulkJson' is the object that contains the bulk update information:

let bulkJson = {
write_api_key: ''...your write key goes here..."
updates: []

Each entry in the bulkJson.updates array is something like this:

created_at: timestamp,
field1: value

I hope this helps. I was struggling with this for a while until I included

headers: {
'Content-Type': 'application/json'

as described above.

April 29, 2020
4:42 am
New Member
Forum Posts: 2
Member Since:
August 8, 2019
sp_UserOfflineSmall Offline

I was a little late to discover your answer, sorry.
But now: it also works for me.
Thank you.
Sincerely Poul Christoffersen

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
30 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormier

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457