Geckoboard offers this documentation to connect to their datasets API, which you can see the implementation below.
var API_KEY = 'API_KEY';
var gb = require('geckoboard')(
API_KEY
);
gb.datasets.findOrCreate(
{
id: 'sales.by_day',
fields: {
quantity: {
type: 'number',
name: 'Number of sales'
},
gross: {
type: 'money',
name: 'Gross value of sales',
currency_code: "USD"
},
date: {
type: 'date',
name: 'Date'
}
}
},
function (err, dataset) {
if (err) {
console.error(err);
return;
}
dataset.put(
[
{ date: '2016-01-01', quantity: 819, gross: 2457000 },
{ date: '2016-01-02', quantity: 409, gross: 1227000 },
{ date: '2016-01-03', quantity: 164, gross: 492000 }
],
function (err) {
if (err) {
console.error(err);
return;
}
console.log('Dataset created and data added');
}
);
}
);
I'd like to see if there is a way to post this additional data via python (not using node.js). Would something like this be possible or must I use mode?
[
{ date: '2017-01-01', quantity: 1213, gross: 23423 },
{ date: '2017-01-02', quantity: 111, gross: 1313123 },
{ date: '2017-01-03', quantity: 333, gross: 21314 }
]
Update: Geckoboard now has their own official Python client library for their Datasets API https://github.com/geckoboard/geckoboard-python
It's definitely possible to use Python with Geckoboard's Datasets API. You can use any language or platform that can perform HTTPS requests with JSON - though Geckoboard has only released official library's for Ruby and Node so far.
Edit: I made a quick example below, but later found this: https://github.com/helium/geckoboard-python/
In short you just need to:
PUT
with the aschema
object tohttps://api.geckoboard.com/datasets
to create a datasetPUT
with the adata
array tohttps://api.geckoboard.com/datasets/:id
to replace all data in a datasetPOST
with the adata
array tohttps://api.geckoboard.com/datasets/:id
to append to the data in a datasetDELETE
tohttps://api.geckoboard.com/datasets/:id
to delete a datasetThese requests are outlined at -- https://developer.geckoboard.com/api-reference/curl/
I haven't written much Python, so this may not be very Pythonic, but here's a way you could create a
Geckoboard
library in Python to do this for you, using therequests
library underneath: