{"id":9574,"library":"censusgeocode","title":"US Census Geocoder Wrapper","description":"censusgeocode is a thin Python wrapper for the US Census Geocoder API, providing an easy-to-use interface to access its geocoding services. It allows users to geocode single addresses or batches of addresses programmatically. The current version is 0.5.3, with releases typically driven by bug fixes, upstream API changes, or minor feature enhancements.","status":"active","version":"0.5.3","language":"en","source_language":"en","source_url":"https://github.com/fitnr/censusgeocode","tags":["geocoding","census","location","address","us-census"],"install":[{"cmd":"pip install censusgeocode","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for making HTTP requests to the Census Geocoder API.","package":"requests"}],"imports":[{"symbol":"CensusGeocode","correct":"from censusgeocode import CensusGeocode"},{"symbol":"geocode","correct":"import censusgeocode\ncensusgeocode.geocode(...)"}],"quickstart":{"code":"import censusgeocode\n\n# Initialize the geocoder client\ncg = censusgeocode.CensusGeocode()\n\n# Geocode a single address\nsingle_address_result = cg.address(\n    street=\"123 Main St\", \n    city=\"Anytown\", \n    state=\"CA\", \n    zipcode=\"90210\"\n)\nprint(f\"Single address result: {single_address_result}\")\n\n# Prepare addresses for batch geocoding\n# The Census Geocoder public API generally does not require an API key.\nbatch_addresses = [\n    {\"id\": 1, \"street\": \"123 Main St\", \"city\": \"Anytown\", \"state\": \"CA\", \"zipcode\": \"90210\"},\n    {\"id\": 2, \"street\": \"456 Oak Ave\", \"city\": \"Someville\", \"state\": \"NY\", \"zipcode\": \"10001\"}\n]\n\n# Geocode a batch of addresses\nbatch_result = cg.addressbatch(batch_addresses)\nprint(f\"Batch address result: {batch_result}\")","lang":"python","description":"This example demonstrates how to initialize the `CensusGeocode` client and perform both single address and batch geocoding. The US Census Geocoder API typically does not require an API key for public use."},"warnings":[{"fix":"Always check if the returned list is empty: `result = cg.address(...); if not result: print('No match found'); else: print(result[0])`.","message":"The `address()` method returns an empty list (`[]`) if no match is found for the given address, rather than `None` or raising an error. Users should explicitly check for an empty list to determine if an address was successfully geocoded.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Split large batches into smaller chunks, each containing 10,000 records or fewer, and process them sequentially.","message":"Attempting to geocode more than 10,000 addresses in a single `addressbatch` call will result in a warning from the library and the Census API may reject the request or return partial results. This is a limit of the Census API.","severity":"gotcha","affected_versions":"0.5.2 and later"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Upgrade `censusgeocode` to version 0.5.3 or newer to benefit from fixes addressing these connection stability issues: `pip install --upgrade censusgeocode`.","cause":"Older versions of `censusgeocode` (prior to 0.5.3) could encounter `urllib.error.URLError` or similar connection issues due to underlying HTTP library usage, especially in specific network environments or with certain TLS/SSL configurations.","error":"urllib.error.URLError: <urlopen error [Errno 111] Connection refused>"},{"fix":"Upgrade `censusgeocode` to version `0.4.3.post1` or newer: `pip install --upgrade censusgeocode`. This version includes a fix for parsing `addressbatch` results.","cause":"Users of `censusgeocode` versions older than `0.4.3.post1` might encounter `TypeError` when attempting to process results from `addressbatch` calls, particularly in certain Python versions, due to a bug in parsing malformed or empty responses.","error":"TypeError: 'NoneType' object is not subscriptable"}]}