Jibble Node SDK
Clone or download
Chris Witko
Chris Witko Merged in feature/public-api (pull request #5)
Feature/public api
Latest commit 8a35f01 Jun 25, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
examples
lib
test
.eslintrc.js
.gitignore
.npmignore
.travis.yml
LICENSE.md
README.md
bitbucket-pipelines.yml
deploy-docs.sh
package.json

README.md

Jibble for Node.js

An asynchronous client library for the Jibble REST API.

const Jibble = require('jibble');

const client = new Jibble({
  consumer_key: '',
  consumer_secret: '',
  access_token_key: '',
  access_token_secret: ''
});

const params = {};
client.get('activities', params)
  .then(function(activities) {
    console.log(activities);
  })
  .catch(function (error) {
    throw error;
  })

Installation

npm install jibble

Quick Start

You will need valid Jibble App developer credentials in the form of a client_id and client_secret. You can get one here.

const Jibble = require('jibble');

For User based authentication:

const client = new Jibble({
  client_id: '',
  client_secret: '',
  username: '',
  password: '',
  scope: ''
});

Add your credentials accordingly. I would use environment variables to keep your private info safe. So something like:

const client = new Jibble({
  client_id: process.env.JIBBLE_CLIENT_ID,
  client_secret: process.env.JIBBLE_CLIENT_SECRET,
  username: process.env.JIBBLE_USERNAME,
  password: process.env.JIBBLE_PASSWORD,
  scope: process.env.JIBBLE_SCOPE
});

Getting token

const token = await client.auth();
console.log(token.access_token);

You will get a JSON reponse:

{
  "access_token": '',
  "expires_in": 0,
  "scope": '',
  "refresh_token": '',
  "token_type": ''
}

For Application Only based authentication:

You will need to fetch a bearer token from Jibble as described above, once you have it you can use it as follows.

const client = new Jibble({
  bearer_token: ''
});

Add your credentials accordingly. I would use environment variables to keep your private info safe. So something like:

const client = new Jibble({
  bearer_token: process.env.JIBBLE_BEARER_TOKEN
});

Requests

You now have the ability to make GET and POST requests against the API via the convenience methods.

client.auth();
client.get(path);
client.post(path, params);
client.put(path, params);
client.delete(path, params);

REST API

You simply need to pass the endpoint and parameters to one of convenience methods. Take a look at the examples site to reference available endpoints.

Example, lets get a list of activities:

client.get('activites')
  .then(function(activities) {
    console.log(activities);
  })
  .catch(function (error) {
    throw error;
  });

How about an example that passes parameters? Let's create something

client.post('activities', {name: 'Activity 1'})
  .then(function (activity) {
    console.log(activity);
  })
  .catch(function (error) {
    throw error;
  });

Promises

The REST API methods returns Promises.

Examples

Contributors

Currently maintained by @chriswitko

You can get full documentation here