Registry / http-networking / censusgeocode

censusgeocode

JSON →
library0.5.3pypypi✓ verified 86d ago

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.

pip install censusgeocode
INSTALL
IMPORT
SIG · CENSUSGEOCODE
C
censusgeocode
http-networkingpythonv0.5.3
Install
2.2s avg
Import
600ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.3 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.631s · 21.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.2s · import 0.569s · 22MB
20MB installed
● package 20MB
Code
Verified usage

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

CensusGeocode
from censusgeocode import CensusGeocode
geocode
import censusgeocode censusgeocode.geocode(...)

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.

import censusgeocode # Initialize the geocoder client cg = censusgeocode.CensusGeocode() # Geocode a single address single_address_result = cg.address( street="123 Main St", city="Anytown", state="CA", zipcode="90210" ) print(f"Single address result: {single_address_result}") # Prepare addresses for batch geocoding # The Census Geocoder public API generally does not require an API key. batch_addresses = [ {"id": 1, "street": "123 Main St", "city": "Anytown", "state": "CA", "zipcode": "90210"}, {"id": 2, "street": "456 Oak Ave", "city": "Someville", "state": "NY", "zipcode": "10001"} ] # Geocode a batch of addresses batch_result = cg.addressbatch(batch_addresses) print(f"Batch address result: {batch_result}")
Debug
Known issues
gotchaThe `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.
fix
Always check if the returned list is empty: `result = cg.address(...); if not result: print('No match found'); else: print(result[0])`.
affects: All versions
gotchaAttempting 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.
fix
Split large batches into smaller chunks, each containing 10,000 records or fewer, and process them sequentially.
affects: 0.5.2 and later
Errors
Common errors & fixes
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
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.
fix
Upgrade `censusgeocode` to version 0.5.3 or newer to benefit from fixes addressing these connection stability issues: `pip install --upgrade censusgeocode`.
TypeError: 'NoneType' object is not subscriptable
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.
fix
Upgrade `censusgeocode` to version `0.4.3.post1` or newer: `pip install --upgrade censusgeocode`. This version includes a fix for parsing `addressbatch` results.
Upgrade
Version history
0.5.3latest on PyPI · released Feb 8, 2026
Audit
Dependencies
requestsrequiredUsed for making HTTP requests to the Census Geocoder API.
Agent activity
16 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
censusgeocode — pip install censusgeocode · libregistry