Skip to main content

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.17

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.17
File Size Uploaded
pyap2-0.2.17.tar.gz 19.8 kB Details

Built distribution (wheel)

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

Total release size: 43.2 kB

Release files / pyap2-0.2.17.tar.gz

Download URL pyap2-0.2.17.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5fa880286a6e666508d032f7544c6fbf5de9bc2a6726f78aa95d9f99f4b08c0
BLAKE2b-256 checksum
How to use checksums
330d66363ec420f95ed29ea2c7fd17b2705f7e5355889b325f5a27fe33dee80d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 10, 2026.

Transparency log

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

Download URL pyap2-0.2.17-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8d9c62992f347eb0fefd3d4f5321d2e4a4778021a112a38bb63c784b6ddde61
BLAKE2b-256 checksum
How to use checksums
69fbcc3cc4b95d928d92481293c0f79fa84afc9d871eb4aad684747bcf4a169c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.18

2 release files

This release

0.2.17 This release

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

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