pyap2
Pyap2 is a maintained fork of pyap, a regex-based library for parsing US, CA, and UK addresses. The fork adds typing support, handles more address formats and edge cases.
What it is and what it does
Pyap2 is a maintained fork of the original Pyap library that uses regular expressions to find and parse postal addresses embedded in unstructured text. It extracts address components (street, city, state, zip) and returns them as structured objects or dictionaries. The library is designed for quick detection when you don't know whether text contains addresses at all, making it useful in web scraping and data extraction workflows.
Because it relies on regex patterns rather than city lists or street databases, it's fast but can produce false positives on strings that happen to match address-like patterns. The maintainers note that such errors are rare in practice. The fork adds type hints and handles more edge cases than the original, including partial addresses with only street information.
Use it for:
- Extract shipping or mailing addresses from user-submitted forms or scraped web content.
- Parse addresses from unstructured documents like emails or PDFs before geocoding or validation.
- Detect whether a text block contains an address as a preprocessing step in data pipelines.
- Normalize address components (street, city, state, zip) into structured fields for database storage.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pyap2 detects and parses postal addresses from unstructured text using regex patterns, currently supporting US, Canadian, and British address formats.
Yes, if you need lightweight regex-based address detection in US, Canadian, or British text and can tolerate occasional false positives. The low install friction, active maintenance, MIT license, and zero security vulnerabilities make it a safe choice. Not suitable if you require high accuracy on non-English addresses or need validation against authoritative address databases.
Install
pyap2 on PyPI
pip
pip install pyap2uv
uv add pyap2poetry
poetry add pyap2Installing pyap2
Before you install
Low install friction with no runtime dependencies. Actively maintained as of 2026-07-10 with recent releases; repository shows minimal activity (4 stars) but is not archived.
License in practice
MIT license permits commercial and private use with minimal restrictions; you must retain the license notice in distributions.
Quickstart
pip install pyap2
import pyap
test_address = "225 E. John Carpenter Freeway, Suite 1500 Irving, Texas 75062"
addresses = pyap.parse(test_address, country='US')
for address in addresses:
print(address.as_dict())
Requires Python 3.9 or later (supports 3.9, 3.10, 3.11).
Verify before relying
- Whether the library's regex-based approach performs adequately on your specific address formats and edge cases beyond the documented US, Canadian, and British support.
- Performance characteristics when parsing large volumes of text or addresses.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 35 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 245,531/month — #8,729 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyap2-0.2.17-py3-none-any.whl
Keywords: address, parser, regex
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
postalPython bindings to libpostal, a C library for…
permissive · top 15,000 on PyPI
pyapPyap detects and parses postal addresses from…
permissive · top 15,000 on PyPI
usaddressusaddress parses unstructured US address…
permissive · top 5,000 on PyPI
usaddress-scourgifyCleans and normalizes US addresses to USPS and…
unclear · top 5,000 on PyPI
pypostalcodeLooks up Canadian postal codes to retrieve…
permissive · top 15,000 on PyPI
geotextGeotext extracts mentions of countries and…
permissive · top 15,000 on PyPI
commonregexExtracts dates, times, emails, phone numbers,…
permissive · top 15,000 on PyPI
lobPython wrapper for the Lob.com API, providing…
permissive · top 15,000 on PyPI
mailbitsProvides utilities for parsing, converting, and…
permissive · top 15,000 on PyPI
google-i18n-addressValidates, normalizes, and formats postal…
permissive · top 15,000 on PyPI