{"id":21702,"library":"postgrid-python","title":"PostGrid Python Library","description":"The official Python library for the PostGrid API. Provides convenient access to the PostGrid print-and-mail and address verification APIs. Current version 2.1.1, actively maintained with monthly releases.","status":"active","version":"2.1.1","language":"python","source_language":"en","source_url":"https://github.com/postgrid/postgrid-python","tags":["postgrid","print-and-mail","address-verification","api-client"],"install":[{"cmd":"pip install postgrid-python","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"In v2.x the client class is PostGridClient, not Client.","wrong":"import postgrid\nclient = postgrid.Client()","symbol":"PostGridClient","correct":"from postgrid import PostGridClient"}],"quickstart":{"code":"import os\nfrom postgrid import PostGridClient\n\nclient = PostGridClient(api_key=os.environ.get('POSTGRID_API_KEY', ''))\n\n# Verify an address\ntry:\n    result = client.addresses.verify(\n        firstLine='123 Main St',\n        city='New York',\n        provinceOrState='NY',\n        zipOrPostalCode='10001',\n        country='US'\n    )\n    print(result.to_dict())\nexcept Exception as e:\n    print(f'Error: {e}')","lang":"python","description":"Verify an address using the PostGrid API with environment variable for API key."},"warnings":[{"fix":"Upgrade to v2.0.0+ and refactor to use the new client pattern. See migration guide at https://github.com/postgrid/postgrid-python/releases/tag/v2.0.0","message":"In v2.0.0, the entire API surface was redesigned. v1.x had different resource names and method signatures.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Use `PostGridClient(api_key='...')` or set `POSTGRID_API_KEY` environment variable.","message":"API keys are passed to the client as `api_key` parameter, not `key` or `apikey`.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Pass merge variables directly inside the `to` address dictionary (e.g., `to={'firstLine': '...', 'mergeVariables': {...}}`)","message":"The `letter.create()` method's `merge_variables` parameter is deprecated in favor of `to` block fields.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Handle `postgrid.errors.PostGridError` with status 422, not 404.","message":"Address verification returns 422 if the address is invalid, not 404. Some users expect a 404.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install postgrid-python` and import as `from postgrid import PostGridClient`.","cause":"Package not installed or installed as 'postgrid-python' instead of 'postgrid'.","error":"ModuleNotFoundError: No module named 'postgrid'"},{"fix":"Use `from postgrid import PostGridClient` and instantiate `PostGridClient(api_key='...')`.","cause":"In v2.x the client class is renamed to PostGridClient.","error":"AttributeError: module 'postgrid' has no attribute 'Client'"},{"fix":"Double-check the address fields (e.g., firstLine, city, provinceOrState, zipOrPostalCode). Use the address verification endpoint to debug.","cause":"Address verification failed due to invalid or incomplete address.","error":"postgrid.errors.PostGridError: 422 Unprocessable Entity"},{"fix":"Use `client.letters.create(...)` (plural resource name) instead of `client.letter.create(...)`.","cause":"The client's resource access pattern changed in v2.0.0; resources are accessed via the client instance, not a direct attribute.","error":"AttributeError: 'PostGridClient' object has no attribute 'letter'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}