Skip to main content

Official Python client for the Geckoboard Datasets API

Project description

A Python client library for Geckoboard datasets API.

Note: This library is still in Beta and the API has potential to change before the release of V1.

Installation

Install the package with pip

pip install geckoboard.py

Usage

The latest documentation and user guide can be found on the Geckoboard developer docs


Getting started

Install the python client from PIP

pip install geckoboard.py

Import the Geckoboard package and create an instance of the client using your API key:

import geckoboard

client = geckoboard.client(API_KEY)

Note: You can find your API key by logging into the Geckoboard application and visiting the Account section.

Authentication

Verify that your API key is valid and that you can reach the Geckoboard API with the ping method.

client.ping()

Example:

client('good-api-key').ping() # => true
client('bad-api-key').ping() # => raises Exception

Finding or creating a dataset

Find and verify an existing dataset or create a new dataset with the find_or_create method. unique_by is an optional list of one or more field names whose values will be unique across all your records.

client.datasets.find_or_create(dataset_id, fields, unique_by)

Params:

  • dataset_id [required] <str>

  • fields [required] <dict>
  • unique_by <list>

Example:

dataset = client.datasets.find_or_create('sales.by_night', {
  'amount': { 'type': 'number', 'name': 'Amount', 'optional': False },
  'timestamp': { 'type': 'datetime', 'name': 'Time' }
}, ['timestamp'])

The full list of available field types is described at the top of this page.

Replacing all data in a dataset

Replace all data in the dataset by calling the put method.

dataset.put(items)

Params:

  • items [required] <list>

Example:

dataset.put([
  { 'timestamp': '2016-01-01T12:00:00Z', 'amount': 819 },
  { 'timestamp': '2016-01-02T12:00:00Z', 'amount': 409 },
  { 'timestamp': '2016-01-03T12:00:00Z', 'amount': 164 }
])

Appending data to a dataset

Append records to a dataset by calling the post method.

Should the number of records in your dataset exceed the limit following a post old records will be discarded.

dataset.post(items, delete_by)

Params:

  • items [required] <list>

  • delete_by <str>

Example:

dataset.post([
  { 'timestamp': '2016-01-03T12:00:00Z', 'amount': 312 },
  { 'timestamp': '2016-01-04T12:00:00Z', 'amount': 665 },
  { 'timestamp': '2016-01-05T12:00:00Z', 'amount': 453 }
], 'timestamp')

Deleting a dataset

Delete the dataset and all data with the given id.

client.datasets.delete(dataset_id)

Params:

  • dataset_id [required] <str>

Example:

client.datasets.delete('sales.gross') # => true

You can also delete a dataset by calling the delete method on a dataset.

dataset = client.datasets.find_or_create(...)
dataset.delete() # => true

Development

Clone this repo

git clone https://github.com/geckoboard/geckoboard-python && cd geckoboard-python

Install package dependencies

python setup.py develop

Run tests

nosetests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geckoboard.py-1.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geckoboard.py-1.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file geckoboard.py-1.1.0.tar.gz.

File metadata

  • Download URL: geckoboard.py-1.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for geckoboard.py-1.1.0.tar.gz
Algorithm Hash digest
SHA256 77558ed9e171d27dc7c85f6ddebcea29e03851ab89bca0882c3cd84a167d8d84
MD5 17fec3599ca3b7e267e56ab4dc3c2af4
BLAKE2b-256 9c297ec2f5264c6dbc963a26e9840de21fb5bf4dd156b96860bd1360715ac202

See more details on using hashes here.

File details

Details for the file geckoboard.py-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: geckoboard.py-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for geckoboard.py-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2224c94104e2464f111e55bcefb1c3cd29d8f90916c12d3ec9772daf295119e6
MD5 f19bf848d4c4d00513d3dd9665ed4d53
BLAKE2b-256 d5bb1fdc1feb81d5570e09fe56939026a62766d5efbe5a27f94234a6300d8f9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page