address-parser-go-rest

command module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 9 Imported by: 0

README

Address Parser Go REST

Go Report Card

Address Parser Go REST is a REST API that provides address parsing functionality using the libpostal library. The purpose of this API is to allow users to easily parse addresses into their individual components without the need for the libpostal library to be included as a dependency in their projects.

Quickstart

docker run -p 8080:8080 gosom/address-parser-go-rest

This will take some time to load

then try a sample request

curl -X 'POST' \
  'http://localhost:8080/parse' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "address": "48 Leicester Square, London WC2H 7LU, United Kingdom",
   "title_case": true
}'

Response:

{
  "house_number": "48",
  "road": "Leicester Square",
  "postcode": "Wc2h 7Lu",
  "city": "London",
  "country": "United Kingdom",
  "components": [
    {
      "label": "house_number",
      "value": "48"
    },
    {
      "label": "road",
      "value": "Leicester Square"
    },
    {
      "label": "city",
      "value": "London"
    },
    {
      "label": "postcode",
      "value": "Wc2h 7Lu"
    },
    {
      "label": "country",
      "value": "United Kingdom"
    }
  ]
}

Open [swagger documentation] (http://localhost:8080/docs/)

See another example in this blog post

Run without docker

To install and run Address Parser Go REST, you can use the following steps:

  1. Make sure you have a recent version of Golang
  2. Install libpostal on your machine.
  3. go mod tidy
  4. go run main.go

Notes: you can change the port the service or the path for swagger is listening to by setting the following environment variables:

PARSER_HTTP_ADDR=:8080
DOCS_PATH=/docs

you can also put these in .env file in the root of the project.

If you want to rebuild the swagger documentation make sure that you have installed swag

to regenerate:

go generate

Contributing

If you would like to contribute to Address Parser Go REST, please create a pull request with your changes. You can also report any issues or bugs you encounter by creating a new issue on the GitHub repository.

License

Address Parser Go REST is licensed under the MIT License. See LICENSE for more information.

Acknowledgments

We would like to acknowledge the contributors of the libpostal library and the Go bindings used in this project.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL