{"id":6394,"library":"lob","title":"Lob Python Client Library (v4.x)","description":"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`.","status":"maintenance","version":"4.5.4","language":"en","source_language":"en","source_url":"https://github.com/lob/lob-python","tags":["api client","mailing","postcards","letters","address verification"],"install":[{"cmd":"pip install lob","lang":"bash","label":"Install Lob (v4.x)"}],"dependencies":[],"imports":[{"note":"The `lob_python` package is for the 5.x series of the Lob API client. This entry is for the 4.x `lob` package.","wrong":"import lob_python","symbol":"lob","correct":"import lob"}],"quickstart":{"code":"import os\nimport lob\n\n# Get your API key from environment variables\nlob.api_key = os.environ.get('LOB_API_KEY', '')\n\n# For demonstration, ensure a valid API key is present\nif not lob.api_key:\n    print(\"Error: LOB_API_KEY environment variable not set.\")\n    print(\"Please set it with your Lob Test API key (e.g., test_****************).\")\n    exit(1)\n\ntry:\n    # Create a simple address\n    address = lob.Address.create(\n        name='Joe Smith',\n        address_line1='123 Main St',\n        address_city='San Francisco',\n        address_state='CA',\n        address_zip='94107',\n        address_country='US'\n    )\n\n    print(f\"Successfully created Address ID: {address.id}\")\n    print(f\"Address Line 1: {address.address_line1}\")\n    print(f\"Address City: {address.address_city}\")\n    print(f\"Address State: {address.address_state}\")\n\nexcept lob.LobError as e:\n    print(f\"Lob API Error: {e.message}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"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."},"warnings":[{"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`).","message":"Version 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.","severity":"breaking","affected_versions":"All users of `lob` (v4.x) wishing to upgrade to `lob-python` (v5.x)."},{"fix":"Set `lob.api_key = os.environ.get('LOB_API_KEY', '')` with your secret API key. Never expose secret keys in client-side code.","message":"Lob 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.","severity":"gotcha","affected_versions":"All versions of `lob` client."},{"fix":"Implement retry logic with exponential backoff or ensure your application adheres to the defined rate limits to avoid service disruption.","message":"The 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.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}