skillfed

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.

pyap2 v0.2.17 245.5K downloads/30d#8,729 on PyPI4
Permissive license MIT Active released

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 pyap2

uv

uv add pyap2

poetry

poetry add pyap2

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Information AnalysisTopic :: Software Development :: LibrariesTopic :: Utilities

Tags

address parser regexextract addresses from textpostal address detectionUS address parsingaddress extraction libraryparse street addressesaddress recognition
text-extractionregex-basedweb-scraping

More Libraries packages