1.0.15 • Published 6 years ago

jibble-sdk v1.0.15

Weekly downloads
15
License
MIT
Repository
-
Last release
6 years ago

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

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago