npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

treverpr-contextio

v0.4.9

Published

Official Node.js client library for the Context.IO Email API

Downloads

36

Readme

Context.IO - Mailboxes know a lot. Use them.

Context.IO is the missing email API that makes it easy and fast to integrate your user's email data in your application. ContextIO-node is the officiel Node.js client library.

Usage of this library requires you to register for a Context.IO API key. You can get one free here: http://context.io/

Installation

ContextIO-node is installed using npm (http://npmjs.org/)

  $ npm install contextio

Getting started

Once you install the contextio package, using it in your code is fairly simple:

  var ContextIO = require('contextio');
  var ctxioClient = new ContextIO.Client({
    key: "YOUR CONTEXT.IO CONSUMER KEY",
    secret: "YOUR CONTEXT.IO CONSUMER SECRET"
  });

The Client constructor simply requires your OAuth consumer key and secret. You can also specify the version and endpoint. By default, the client will use the latest stable version of the API (currently 2.0) and http://api.context.io respectively.

Instantiating the client while specifying the API version:

  var ContextIO = require('contextio');
  var ctxioClient = new ContextIO.Client('2.0', {
    key: "YOUR CONTEXT.IO CONSUMER KEY",
    secret: "YOUR CONTEXT.IO CONSUMER SECRET"
  });

Instantiating the client while specifying the API version and endpoint:

  var ContextIO = require('contextio');
  var ctxioClient = new ContextIO.Client('2.0', 'https://api.context.io', {
    key: "YOUR CONTEXT.IO CONSUMER KEY",
    secret: "YOUR CONTEXT.IO CONSUMER SECRET"
  });

Doing calls to the Context.IO API

Complete documentation is available on http://context.io/docs/latest and you can also play around with the API using the Context.IO Explorer (https://console.context.io/#explore, developer account required).

The design of this library follows the URI structure very closely. For example, to call:

GET /2.0/accounts?limit=15

you would do:

ctxioClient.accounts().get({limit:15}, function (err, response) {
	if (err) throw err;
	console.log(response.body);
});

Making it more general, the equivalent of this generic URI:

METHOD /2.0/RESOURCE/INSTANCE_ID/SUB_RESOURCE?PARAMS

would be:

ctxioClient.RESOURCE(INSTANCE_ID).SUB_RESOURCE().METHOD(PARAMS, CALLBACK_FN)

Note that if the resource name contains an underscore character (eg. connect_tokens), you can use both connect_tokens() or connectTokens() with this library.

Parameters

Call parameters are passed as an Object with properties matching parameter name. Parameters for POST or GET work the same: an Object passed as the first argument of the method call.

Callback function

Your callback function gets 3 arguments:

  1. err Either null or an Error if something went wrong
  2. response An Object representing the HTTP response. It has three properties: * body: Object, Array or String - If Content-Type is application/json, the response body is parsed automatically * statusCode: Number - The HTTP status code of the response * headers: Object - HTTP headers of the response
  3. request An Object mainly useful for debugging purposes * host: String - Host part of the URL being called * path: String - Path portion of the URL being called * method: String - HTTP method of the call * headers: Object - HTTP headers of the request

Node.js version

It has been tested on Node.js 0.6.

Examples

Please refer to the test files for an example of every single call.