Registry / communication / lob
library4.5.4pypypi✓ verified 85d ago

The `lob` Python client library provides bindings for the Lob.com API, enabling programmatic access to services like mail, print, and address verification. This registry entry specifically covers the 4.x series of the library. While still maintained for critical fixes, new major versions (5.x and above) are released under a separate PyPI package, `lob-python`.

pip install lob
INSTALL
IMPORT
SIG · LOB
L
lob
communicationpythonv4.5.4
Install
3.0s avg
Import
614ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.5.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.642s · 22.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.0s · import 0.586s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lob
import lob
import lob_python
The `lob_python` package is for the 5.x series of the Lob API client. This entry is for the 4.x `lob` package.

This quickstart demonstrates how to initialize the Lob client and create an address object using the `lob` (v4.x) package. Ensure your Lob API key is set as an environment variable named `LOB_API_KEY`. You can obtain test API keys from your Lob dashboard.

import os import lob # Get your API key from environment variables lob.api_key = os.environ.get('LOB_API_KEY', '') # For demonstration, ensure a valid API key is present if not lob.api_key: print("Error: LOB_API_KEY environment variable not set.") print("Please set it with your Lob Test API key (e.g., test_****************).") exit(1) try: # Create a simple address address = lob.Address.create( name='Joe Smith', address_line1='123 Main St', address_city='San Francisco', address_state='CA', address_zip='94107', address_country='US' ) print(f"Successfully created Address ID: {address.id}") print(f"Address Line 1: {address.address_line1}") print(f"Address City: {address.address_city}") print(f"Address State: {address.address_state}") except lob.LobError as e: print(f"Lob API Error: {e.message}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingVersion 5.x of the Lob Python client is distributed under a *separate PyPI package* named `lob-python`. Users upgrading from `lob` (v4.x) must install `lob-python` and update import paths and API usage patterns.
fix
To upgrade, install `pip install lob-python` and update imports from `import lob` to `import lob_python`. The API structure also changes, requiring adaptation to the new module and class organization (e.g., `lob_python.Configuration`, `lob_python.api.addresses_api`).
affects: All users of `lob` (v4.x) wishing to upgrade to `lob-python` (v5.x).
gotchaLob API uses HTTP Basic authentication where the API key is provided as the username and the password field is left blank. Ensure you use the correct API key type (e.g., `test_...` for sandbox, `live_...` for production) as they have different capabilities and billing implications. Test API keys will not send real mail.
fix
Set `lob.api_key = os.environ.get('LOB_API_KEY', '')` with your secret API key. Never expose secret keys in client-side code.
affects: All versions of `lob` client.
gotchaThe Lob API has rate limits, typically 150 requests per 5 seconds per endpoint. Exceeding this limit will result in an `HTTP 429 Too Many Requests` response.
fix
Implement retry logic with exponential backoff or ensure your application adheres to the defined rate limits to avoid service disruption.
affects: All versions.
Errors
Common errors & fixes
401 Unauthorized
The API key used for authentication is missing, invalid, or incorrectly provided for the Lob API request.
fix
Ensure you have obtained a valid Lob API key (test or live) from your dashboard settings and set it correctly as `lob.api_key = 'YOUR_API_KEY'` before making any API calls. Lob uses HTTP Basic authentication where the API key serves as the username, and the password remains blank.
ImportError: cannot import name 'Configuration' from 'lob'
This specific import `Configuration` is part of the newer `lob-python` (v5.x+) package, which has a different module structure. It does not exist in the `lob` (v4.x) library, leading to a common import mismatch when using examples from the newer client with the older package.
fix
If you are using `lob` v4.x, import the main `lob` module directly (`import lob`) and interact with its top-level classes (e.g., `lob.Addresses`, `lob.Postcards`). If you intend to use v5.x+ features and their associated imports, ensure you install `lob-python` (`pip install lob-python`) instead.
AttributeError: module 'lob' has no attribute 'verify_address'
In `lob` v4.x, API methods like `verify_address` are not directly available on the top-level `lob` module. Instead, they are accessed through specific API service objects, such as `lob.Addresses` for address-related operations.
fix
Instantiate the appropriate API service object and call its methods. For address verification in `lob` v4.x, you would typically use `lob.Addresses.verify()` after setting `lob.api_key`.
ValueError: Missing the required parameter `body`
This error indicates that an API request was made without providing a mandatory parameter or with an incorrectly formatted request body, which the Lob API requires for the specific endpoint being called.
fix
Review the official Lob API documentation for the specific endpoint you are calling to identify all required parameters. Ensure they are included and correctly populated in your request payload (e.g., all necessary address components like `address_line1`, `address_city`, `address_state`, `address_zip` for an address creation or verification).
Upgrade
Version history
4.5.4latest on PyPI · released Feb 19, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
lob — pip install lob · libregistry