Skip to main content

A tiny API client for the Pelias Libpostal REST service.

Project description

dripostal

Test Publish Coverage Package version

A tiny API client for the Pelias Libpostal REST service.


Documentation: https://dribia.github.io/dripostal

Source Code: https://github.com/dribia/dripostal


Libpostal is a widely known C library for parsing and normalizing street addresses around the world.

Despite having its own Python bindings, getting to install the library can be quite hard and time-consuming. A common workaround is then to use a dockerized service exposing Libpostal as a REST API, e.g. Pelias' Libpostal REST service.

Dripostal aims to provide a Python interface with such API, both in the synchronous and the asynchronous ways.

Key features

  • Query Libpostal's parse and expand methods.
  • Return results as Pydantic models.
  • Provides a mirror async client enabling asynchronous queries to the Libpostal REST service.

Example

In order to successfully run the following example, a Libpostal service should be running locally:

docker run -d -p 4400:4400 pelias/libpostal-service

!!!info The command above will be pulling the libpostal-service Docker image from Pelias and running a container that will serve the Libpostal REST service through its port 4400.

* With option `-p 4400:4400` we are mapping port 
  `4400` in the docker container to port `4400` in the docker host, i.e. your computer. 
  You could map it to another port of the host, e.g. the `8080`, changing `4400:4400` for `8080:4400`.
* With option `-d` we are running the docker container in _detached mode_, i.e. in the background. 

Now we should be able to run the following code:

from dripostal import DriPostal

dripostal = DriPostal(url="http://0.0.0.0:4400")

dripostal.parse("Planta 3 mòdul 303, Carrer de la Llacuna, 162, 08018 Barcelona")

"""
Address(
    house='mòdul 303', 
    house_number='162', 
    road='carrer de la llacuna', 
    level='planta 3', 
    postcode='08018', 
    city='barcelona', 
    country=None, 
    ...
)
"""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dripostal-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

dripostal-0.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file dripostal-0.1.1.tar.gz.

File metadata

  • Download URL: dripostal-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.10 CPython/3.7.12 Linux/5.8.0-1041-azure

File hashes

Hashes for dripostal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8dfd83c1ce91608f3bce0f91aacf5847d80ebcc28a22f0f788eb56530129eb36
MD5 4f6bb3557c0189ac1533a03a13f4336c
BLAKE2b-256 f98eb47862ad339b1fe55aa9305792e73732dc1c62389752b3708f29f8d0202c

See more details on using hashes here.

File details

Details for the file dripostal-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dripostal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.10 CPython/3.7.12 Linux/5.8.0-1041-azure

File hashes

Hashes for dripostal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8595c0313381c2f03433a7884a1cf5fae4e92e259e6f2d795fcd46bbe60b2312
MD5 5bbfe3331fc61f777698c2f127f27da3
BLAKE2b-256 ea737ded927b9963d76eb9675433b3be863bf2c5629e0aa63b75b4898cad1768

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page