SpreeZipAutocomplete

spree_zip_autocomplete is an extension for Spree that provides an API to search for addresses by zipcode. It also enables automatic form filling for Spree::Address forms based on the input zipcode.

Installation

Add the gem to your Spree Gemfile:

# Gemfile
gem 'spree_zip_autocomplete', path: 'engines/spree_zip_autocomplete'

Run the following commands:

bundle install
rails g spree_zip_autocomplete:install

API

Search for Address by Zipcode

Endpoint:

GET /api/v2/zip_autocomplete/search?zipcode={zipcode}

Notes:

  • The zipcode parameter can be in the format 1510051 or 151-0051.
  • This API only supports addresses in Japan.

Request:

curl -X GET "http://yourstore.com/api/v2/zip_autocomplete/search?zipcode=1510051" \
     -H "Content-Type: application/json"

Response:

{
  "zipcode": "1510051",
  "prefecture": "東京都",
  "city": "渋谷区",
  "town": "千駄ヶ谷",
  "state_id": 1214,
  "country_id": 347
}

License

This extension is available as open source under the terms of either:

Credits

Originally created by Vinsol. Fork maintained by be agile Co., Ltd..%