Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

EasyPost Shipping API Client Library for Python

Project description

EasyPost Python Client Library

Build Status PyPI version

EasyPost is the simple shipping API. You can sign up for an account at


  • Python 2.7 or 3.3+ (or corresponding PyPy versions). Note that we only test on Python 2.7 and 3.5+; we strongly recommend against using 3.3.x or 3.4.x as they are no longer supported by many libraries.
  • requests (if not on Google App Engine)
  • six

Looking for a client library for another language? Check out


You can install easypost via pip with:

pip install easypost

Alternatively, you can clone the EasyPost python client repository:

git clone


python install

Import the EasyPost client:

import easypost


import easypost
easypost.api_key = '<YOUR API KEY FROM>'

# create and verify addresses
to_address = easypost.Address.create(
    name = "Dr. Steve Brule",
    street1 = "179 N Harbor Dr",
    street2 = "",
    city = "Redondo Beach",
    state = "CA",
    zip = "90277",
    country = "US",
    phone = "310-808-5243"
from_address = easypost.Address.create(
    name = "EasyPost",
    street1 = "118 2nd Street",
    street2 = "4th Floor",
    city = "San Francisco",
    state = "CA",
    zip = "94105",
    country = "US",
    phone = "415-456-7890"

# create parcel
    parcel = easypost.Parcel.create(
        predefined_package = "Parcel",
        weight = 21.2
except easypost.Error as e:
    if e.param is not None:
        print('Specifically an invalid param: %r' % e.param)

parcel = easypost.Parcel.create(
    length = 10.2,
    width = 7.8,
    height = 4.3,
    weight = 21.2

# create customs_info form for intl shipping
customs_item = easypost.CustomsItem.create(
    description = "EasyPost t-shirts",
    hs_tariff_number = 123456,
    origin_country = "US",
    quantity = 2,
    value = 96.27,
    weight = 21.1
customs_info = easypost.CustomsInfo.create(
    customs_certify = 1,
    customs_signer = "Hector Hammerfall",
    contents_type = "gift",
    contents_explanation = "",
    eel_pfc = "NOEEI 30.37(a)",
    non_delivery_option = "return",
    restriction_type = "none",
    restriction_comments = "",
    customs_items = [customs_item]

# create shipment
shipment = easypost.Shipment.create(
    to_address = to_address,
    from_address = from_address,
    parcel = parcel,
    customs_info = customs_info

# buy postage label with one of the rate objects = shipment.rates[0])
# alternatively: = shipment.lowest_rate())


# Insure the shipment for the value



Up-to-date documentation is available at:

Client Library Development


  1. Add new features to
  2. Bump the version in easypost/ and
  3. Create a git tag
  4. Push to PyPI with python sdist upload

Running Tests

To run tests:

  • Create a virtualenv for your version of Python (e.g., python2.7 -m virtualenv venv)
  • Install dependencies in that virtualenv (./venv/bin/pip install requests six)
  • Install test dependencies (./venv/bin/pip install -r requirements-tests.txt)
  • Export $TEST_API_KEY and $PROD_API_KEY appropriately (these are set by .travis.yml for CI)
  • Run the tests with py.test (./venv/bin/py.test -vs tests)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for easypost, version 5.0.0
Filename, size File type Python version Upload date Hashes
Filename, size easypost-5.0.0-py2-none-any.whl (10.0 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size easypost-5.0.0-py3-none-any.whl (10.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size easypost-5.0.0.tar.gz (14.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page