Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
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/
ContextIO-node is installed using npm (http://npmjs.org/)
$ npm install contextio
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', 'http://api.context.io', {
key: "YOUR CONTEXT.IO CONSUMER KEY",
secret: "YOUR CONTEXT.IO CONSUMER SECRET"
});
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)
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.
Your callback function gets 3 arguments:
Error
if something went wrongObject
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 responseObject
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 requestIt has been tested on Node.js 0.6, it will be tested to support Node.js 0.4 very soon.
We still need to post a good set of examples but in the meantime, you can refer to the test files for an example of every single call.
FAQs
Official Node.js client library for the Context.IO Email API
The npm package contextio receives a total of 0 weekly downloads. As such, contextio popularity was classified as not popular.
We found that contextio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.