Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status Gem Version Coverage Status Downloads

Ruby wrapper for the API. See the full API Documentation. For best results, be sure that you're using the latest version of the Lob API and the latest version of the ruby wrapper. This gem gives you an ActiveRecord-style syntax to use the API.

Supports Ruby 2.0.0 and greater.

Table of Contents

Getting Started

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

Please read through the official API Documentation to get a complete sense of what to expect from each endpoint.


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

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


Add this line to your application's Gemfile:

gem 'lob'

And then execute:

$ bundle

Or manually install it yourself:

$ gem install lob


The library uses an ActiveRecord-style interface. You'll feel right at home.

For optional parameters and other details, refer to the docs here.

Initialization and Configuration

# To initialize a Lob object
lob = "your-api-key")

# To initialize a Lob object with an older API version
lob = "your-api-key", api_version: "2014-12-18")

# To initialize a Lob object that needs to communicate via a proxy
lob = "your-api-key", proxy: "

Caution: Pass zero-prefixed zip codes as strings

When using zip codes with zero-prefixes, always quote them. For example when specifying 02125, pass it as a string "02125", instead of an integer.

The Ruby interpreter interprets a number with a leading zero as an octal (i.e., base-8) number and converts it to a base-10 number. Thus 01000 is converted to the base-10 value 512 (since 8*8*8=512). So not quoting might result in an entirely different zip-code than intended.

Accessing Response Headers

You can access response headers via a hidden headers method on the response hash.

addresses = lob.addresses.list

# => "application/json; charset=utf-8"

# => "60"

# => "1234"

You can also access headers from Lob::InvalidRequestErrors.

  lob.objects.create(name: "Test", file: "", bad_param: "bad_value")
rescue Lob::InvalidRequestError => e
  # => "application/json; charset=utf-8"


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

The full and comprehensive documentation of Lob's APIs is available here.


To contribute, please see the file.


Tests are written using MiniTest, a testing library that comes with Ruby stdlib.

Here's how you can run the tests:

bundle exec rake test

You can also configure, TravisCI for your fork of the repository and it'll run the tests for you, when you push.


Copyright © 2016

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