Parse Address With Our Out-Of-The-Box API

We also offer an out-of-the-box REST API to parse addresses using FastAPI.

Installation

First, ensure you have Docker Engine and Docker Compose installed on your machine. If not, you can install them using the following documentation in the following order:

  1. Docker Engine

  2. Docker Compose

Once you have Docker Engine and Docker Compose installed, you can run the following command to start the FastAPI application:

docker compose up app

Sentry

Also, you can monitor your application usage with Sentry by setting the environment variable SENTRY_DSN to your Sentry project DSN. There is an example of the .env file in the project’s root named .env_example. You can copy it using the following command:

cp .env_example .env

Request Examples

Once the application is up and running and port 8000 is exported on your localhost, you can send a request with one of the following methods:

cURL POST request

curl -X POST --location "http://127.0.0.1:8000/parse/bpemb-attention" --http1.1 \
    -H "Host: 127.0.0.1:8000" \
    -H "Content-Type: application/json" \
    -d "[
          {\"raw\": \"350 rue des Lilas Ouest Quebec city Quebec G1L 1B6\"},
          {\"raw\": \"2325 Rue de l'Université, Québec, QC G1V 0A6\"}
        ]"

Python POST request

import requests

url = 'http://localhost:8000/parse/bpemb'
addresses = [
    {"raw": "350 rue des Lilas Ouest Quebec city Quebec G1L 1B6"},
    {"raw": "2325 Rue de l'Université, Québec, QC G1V 0A6"}
    ]

response = requests.post(url, json=addresses)
parsed_addresses = response.json()
print(parsed_addresses)