EasyPost

raw JSON →
10.6.0 verified Mon Apr 27 auth: no python

EasyPost Shipping API Client Library for Python. Current version 10.6.0. Supports Python >=3.9. Released regularly with new features and bug fixes.

pip install easypost
error AttributeError: module 'easypost' has no attribute 'Address'
cause In v10, top-level resource classes (e.g., `easypost.Address`) have been removed. All operations are via client services.
fix
Use client.address.create(...) instead of easypost.Address.create(...).
error TypeError: Client() takes 1 positional argument but 2 were given
cause You attempted to pass both API key and another argument incorrectly, or used old `easypost.Client('key', ...)` with extra args.
fix
Use client = easypost.Client('EASYPOST_API_KEY') with only the key as a string.
error easypost.errors.InvalidRequestError: Missing required parameter: 'api_key'
cause You tried to make an API call without providing an API key, or the client was not instantiated properly.
fix
Set the API key either via client = easypost.Client('YOUR_KEY') or set environment variable EASYPOST_API_KEY and call client = easypost.Client().
breaking v10.0.0 drops support for Python 3.7 and 3.8. Also changed the client instantiation pattern; old `import easypost; easypost.api_key = '...'` no longer works. You must use `client = easypost.Client('API_KEY')` or set `easypost.api_key` only for backwards compatibility (deprecated).
fix Use `import easypost; client = easypost.Client('YOUR_API_KEY')` and pass this client to all service calls.
deprecated Setting `easypost.api_key` globally is deprecated as of v10.0.0. Methods that relied on the global key (e.g., `easypost.Address.create(...)`) will raise errors in future versions.
fix Use client-based calls such as `client.address.create(...)`.
gotcha All service methods are now called on the client object, not as top-level functions. For example, `easypost.Shipment.create(...)` is wrong; use `client.shipment.create(...)`.
fix Create a client and use `client.<resource>.<method>(...)`.
gotcha Rate limiting: EasyPost returns 429 errors when too many requests are made. The library does not automatically retry; you must implement retries with exponential backoff.
fix Catch `easypost.errors.RateLimitError` and retry after a delay.

Create a client and an address.

import easypost

client = easypost.Client(os.environ.get('EASYPOST_API_KEY', ''))

# Create an address
address = client.address.create(
    street1="417 MONTGOMERY ST",
    street2="FLOOR 5",
    city="SAN FRANCISCO",
    state="CA",
    zip="94104",
    country="US",
    company="EasyPost",
    phone="415-123-4567"
)

print(address)