Node.js module for Push method widgets

Learn about Gekoq, a Node.js module that simplifies sending data to your Geckoboard Push method Custom Widgets.

Updated over a week ago

Gekoq (npm | Github) is a Node.js module that simplifies sending data to your Geckoboard Push method Custom Widgets. It relies only on the core Node.js module https, which makes it both minimalist and lightweight.

It has two methods: gekoq.key and gekoq.push. The gekoq.key method must be called (just once in the current scope) with your Geckoboard API key before gekoq.push, as the push method builds the final payload using this key, as required by Geckoboard’s API. For example:

{ “api_key”: “xxxxx”, “data”: { … }}

gekoq.push accepts an Object with the required properties key and data. The key property is a String that is the widget’s key, as you can find in the widget’s configuration:

Widget key in config

The data property should match the format for the widget type as outlined in our Custom Widgets documentation.

Here though, before the gekoq.push POSTs the data to your widget, it will evaluate any expressions/statements and pass it through JSON.stringify. This means that you can use plain/full JavaScript in the widget data, such as including functions and variables, as long as they evaluate to valid JSON (e.g. a function that returns another function will be undefined).

Here is a full example (mostly in ES6) using Geckoboard’s Number & Secondary Stat widget.

import { push, key } from ‘gekoq’;key(‘your secret api key’);let randomNumber = () => Math.floor(Math.random() * 100);push({
  key: ‘168760-44cd73a4-19aa-465c-872a-e0f4d101c7be’, 
  data: { 
    item: [{ 
      value: randomNumber(), 
      text: ‘A random number between 0 and 100’

Here we import the gekoq methods push and key, then set our Geckoboard API key. We then define a function randomNumber that returns a number between 0 and 100. We then push to our widget using the widget’s key and data, which contains the evaluated randomNumber function.

The gekoq module outputs to the console the API response from Geckoboard matching the widget’s key. If everything went well, you should then see somrthing like this output in your terminal.

168760-033d0321-19bd-4c58-bc74-b774d394bcb7 => {"success":true}

As well as the widget updated on your dashboard:

Number Custom Widget

And that's it. This small module makes it easy to push to your Geckoboard Custom Widgets.

Did this answer your question?