/AddressFormatterAPI

An API which reduces redundancies & returns properly formatted addresses.

Primary LanguagePythonMIT LicenseMIT

An API built to format given addresses using Python and Flask.


About

The API returns properly formatted data, i.e. removing duplicate fields, distinguish missing fields etc.

Project (solution) submission for Aadhaar Hackathon 2021, conducted by UIDAI.

Documentation

The API comes with two endpoints, v1 & v2.

v1 API is designed to handle just a single key-value pair, while the v2 API can handle a split field key-value JSON POST request.

Examples:

v1 API: Requires a single field JSON input, i.e. "raw" (key), followed by a string (value) which is the unformatted address.

Input:

{
	"raw":"41, 1st Cross, Sv Rd, Bonny Plaza Shpg Ctr, Andheri,, Mumbai, Maharashtra, 400058"
}

Output:

{
    "building": "41",
    "district": "Mumbai",
    "landmark": "Bonny Plaza Shpg Ctr",
    "locality": "Sv Rd",
    "pincode": "400058",
    "state": "Maharashtra",
    "street": "1st Cross",
    "sub_district": "NA",
    "vtc": "Andheri"
}

v2 API: Requires multiple split field JSON input.

Input:

{
    "building": "41",
    "street": "1st Cross",
    "landmark": "Bonny Plaza Shpg Ctr",
    "locality": "Sv Rd",
    "vtc": "Andheri",
    "district": "Mumbai",
    "state": "Maharashtra"
 }

Output:

{
    "building": "41",
    "district": "Mumbai",
    "landmark": "Bonny Plaza Shpg Ctr",
    "locality": "Sv Rd",
    "pincode": "NA",
    "state": "Maharashtra",
    "street": "1st Cross",
    "sub_district": "NA",
    "vtc": "Andheri"
}
  • The API will return NA for missing or any blank fields.
  • Multiple languages are supported.

It's recommended to use v2 API as it performs better. v1 is just kept for legacy purposes.

Demo

The API (v2) is available here. Snapshots of the working code output are here.

It can be tested using Postman or any other relaible API testing application such as httpie or arc-electron.

Credits

Projects used in the making:

Other:

  • Repo logo created by rawpixel.com, obtained from freepik