Lob API wrapper
Here's a general overview of the Lob services available, click through to read more.
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.
lob-node can be installed through the npm:
$ npm install lob
To build and install from the latest source:
$ git clone email@example.com:lob/lob-node.git$ npm install
var Lob = require'lob''YOUR API KEY';// change api versionvar Lob = require'lob''YOUR API KEY' apiVersion: 'API-VERSION' ;// change internal defaults (e.g. host)var options = /* see options below */;var Lob = require'lob''YOUR API KEY' options;// you can also just pass optionsvar options = apiKey: 'foo' host: 'bar' ;var Lob = require'lob'options;// callback patternLobsettingslist type: 1if err return callbackerr;return callbacknull bodydata;;
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';Lobsettingslist type: 1thenconsole.logresdata;catchconsole.loge;;
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.
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:
You can access response headers via a hidden
Lobaddresseslistthenres_responseheaders'content-type';// => "application/json; charset=utf-8";
You can also access headers from errors.
Lobaddressesretrieve'adr_bad_id'catcherr_responseheaders'content-type';// => "application/json; charset=utf-8";
To contribute, please see the CONTRIBUTING.md file.
To run the tests with coverage:
To run the tests without coverage:
npm run test-no-cover
Copyright © 2013 Lob.com
Released under the MIT License, which can be found in the repository in