Skip to main content

Pyap2: Python address parser

Pyap2 is a maintained fork of Pyap, a regex-based python library for detecting and parsing addresses. Currently it supports US 🇺🇸, Canadian 🇨🇦 and British 🇬🇧 addresses.

>>> import pyap
>>> test_address = """
    Lorem ipsum
    225 E. John Carpenter Freeway,
    Suite 1500 Irving, Texas 75062
    Dorem sit amet
    """
>>> addresses = pyap.parse(test_address, country='US')
>>> for address in addresses:
        # shows found address
        print(address)
        # shows address parts
        print(address.as_dict())
...

Installation

To install Pyap2, simply:

$ pip install pyap2

About

We started improving the original pyap by adopting poetry and adding typing support. It was extensively tested in web-scraping operations on thousands of US addresses. Gradually, we added support for many rarer address formats and edge cases, as well as the ability to parse a partial address where only street info is available.

Typical workflow

Pyap should be used as a first thing when you need to detect an address inside a text when you don’t know for sure whether the text contains addresses or not.

Limitations

Because Pyap2 (and Pyap) is based on regular expressions it provides fast results. This is also a limitation because regexps intentionally do not use too much context to detect an address.

In other words in order to detect US address, the library doesn’t use any list of US cities or a list of typical street names. It looks for a pattern which is most likely to be an address.

For example the string below would be detected as a valid address: “1 SPIRITUAL HEALER DR SHARIF NSAMBU SPECIALISING IN”

It happens because this string has all the components of a valid address: street number “1”, street name “SPIRITUAL HEALER” followed by a street identifier “DR” (Drive), city “SHARIF NSAMBU SPECIALISING” and a state name abbreviation “IN” (Indiana).

The good news is that the above mentioned errors are quite rare.

Release files for pyap2 0.2.19

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyap2 0.2.19
File Size Uploaded
pyap2-0.2.19.tar.gz 21.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyap2 0.2.19
File Interpreter ABI Platform
pyap2-0.2.19-py3-none-any.whl Python 3 none any Details

Total release size: 45.7 kB

Release files / pyap2-0.2.19.tar.gz

Download URL pyap2-0.2.19.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
32ef221742ea18d239ab9e4025a4dd93b30482c250af5ed0cf7442115edc6717
BLAKE2b-256 checksum
How to use checksums
0bb00569c7d935ca526c798264d2566a217fc36a411b06a3269224cd9718345e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pyap2-0.2.19-py3-none-any.whl

Download URL pyap2-0.2.19-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b779a278c5c70c50bda34cc2c7683c98d728e39d26f920018d6862280b3c9c0
BLAKE2b-256 checksum
How to use checksums
d23edc4db9913b653ba68a7b923289f00319a38dafe6a0584d9b75bbb22521b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page