JSPM

  • Created
  • Published
  • Downloads 13444
  • Score
    100M100P100Q161720F

Lob API wrapper

Package Exports

  • lob

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lob) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lob-node

NPM version Downloads Build Status Dependency Status Coverage Status

Node.js wrapper for the Lob.com API. See full Lob.com documentation here.

Table of Contents

Getting Started

Here's a general overview of the Lob services available, click through to read more.

Registration

First, you will need to first create an account at Lob.com and obtain your Test and Live API Keys.

Once you have created an account, you can access your API Keys from the Settings Panel.

Installation

lob-node can be installed through the npm:

$ npm install lob

To build and install from the latest source:

$ git clone git@github.com:lob/lob-node.git
$ npm install

Usage

var Lob = require('lob')('YOUR API KEY');

// change api version
var Lob = require('lob')('YOUR API KEY');

// change internal defaults (e.g. host)
var options = {/* see options below */};
var Lob = require('lob')('YOUR API KEY', options);

// you can also just pass options
var options = { apiKey: 'foo', host: 'bar' };
var Lob = require('lob')(options);

// callback pattern
Lob.settings.list({ type: 1 }, function (err, body) {
  if (err) return callback(err);
  return callback(null, body.data);
});

Additionally, every resource method returns a promise, so you don't have to use the regular callback. E.g.

var Lob = require('lob')('YOUR API KEY');

Lob.settings.list({ type: 1 })
.then(function (res) {
  console.log(res.data);
})
.catch(function (e) {
  console.log(e);
});

Options

The Lob constructor accepts an options object which may contain one or more of the following options:

  • apiVersion - Optionally set the version of the Lob API to use. Defaults to latest.
  • host - Override the default host API calls are issued to.
  • userAgent - Override the default userAgent.
  • headers - Edit the headers sent in all API calls.

Examples

We've provided various examples for you to try out here.

There are simple scripts to demonstrate how to create all the core Lob objects (checks, letters, postcards. etc.) as well as more complex examples that utilize other libraries and external files:

API Documentation

Contributing

To contribute, please see the CONTRIBUTING.md file.

Testing

To run the tests with coverage:

gulp testCI

To run the tests without coverage:

gulp test

=======================

Copyright © 2013 Lob.com

Released under the MIT License, which can be found in the repository in LICENSE.txt.