REST API

Five read-only endpoints let apps, themes and other sites use the same list. They are public on purpose: they only return the public list of administrative units and never write anything.

Base URL: https://your-site.com/wp-json/freeday-vietnam-address/v1. Responses are JSON and can be cached for a day (Cache-Control: public, max-age=86400).

Endpoints

RouteReturns
GET /provincesAll 34 provinces and cities: code, key, name, short, type
GET /provinces/{key|code}/wards?search=The province and its wards; search filters without accents
GET /lookup?province=&ward=The official ward for a typed name (404 if none or ambiguous)
GET /wards/{code}One ward by its 5-digit code, with its province
GET /metaSource, legal basis, valid-as-of date and counts

Examples

Search the wards of a province

$ curl "https://example.com/wp-json/freeday-vietnam-address/v1/provinces/HCM/wards?search=ben%20thanh"

{
  "province": { "code": "79", "key": "HCM", "name": "Thành phố Hồ Chí Minh", "short": "TP. Hồ Chí Minh", "type": "city" },
  "wards": [ { "code": "26743", "name": "Phường Bến Thành" } ]
}

Look up what a customer typed

$ curl "https://example.com/wp-json/freeday-vietnam-address/v1/lookup?province=HCM&ward=ben%20thanh"

{
  "province": { "code": "79", "key": "HCM", … },
  "ward": { "code": "26743", "name": "Phường Bến Thành" }
}

Errors

CodeStatusWhen
vafw_unknown_province404The province key or code does not exist
vafw_no_ward404No single ward of the province matches the lookup
vafw_unknown_ward404No ward has that 5-digit code

Turn it off

Untick REST API in Settings → Vietnam Address, or use add_filter( 'vafw_rest_enabled', '__return_false' );.