You can use our API to add, update or remove data from Zenobase via a script. In this post, we’ll show sample code for uploading multiple events from a file to a bucket.

First, we need to obtain a special token that has to be included in all requests in order to prove that we are authorized to access our data. This token can be obtained using a simple command-line client like wget or curl, as described here.

Note that a token obtained using this method expires after 31 days. To create a token that does not expire, we’d have to use the “implicit grant” method, which is a bit more involved.

As in our previous post, where we showed how to convert a csv file into json, we’ll again use Node.js, plus a module for parsing command line arguments, which can be added by running npm install yargs.

Finally, here’s the script that will read data from a json file (sample file), and upload it to the specified bucket:

Need any help adapting this script to your use case? Get in touch!