/api/provincesMethod: GET
This API returns a list of all provinces. You can optionally filter by province code.
province_code (optional): Filter provinces by a specific province code.Returns a JSON object with a success boolean and a data array of province objects.
{
"success": true,
"data": [
{
"province_code": "01",
"name": "Thành phố Hà Nội",
"short_name": "Hà Nội",
"code": "HN",
"place_type": "Thành phố",
"wards": [...]
},
// ... more provinces
]
}Fetch all provinces:
fetch('/api/provinces')
.then(response => response.json())
.then(data => console.log(data));Fetch province with code '01':
fetch('/api/provinces?province_code=01')
.then(response => response.json())
.then(data => console.log(data));/api/wardsMethod: GET
This API returns a list of all wards. You can filter by province code and limit the number of results.
province_code (optional): Filter wards belonging to a specific province code.limit (optional): Limit the number of wards returned.Returns a JSON object with a success boolean and a data array of ward objects.
{
"success": true,
"data": [
{
"ward_code": "00001",
"name": "Phường Phúc Xá",
"province_code": "01"
},
// ... more wards
]
}Fetch all wards:
fetch('/api/wards')
.then(response => response.json())
.then(data => console.log(data));Fetch wards for province code '01':
fetch('/api/wards?province_code=01')
.then(response => response.json())
.then(data => console.log(data));Fetch 50 wards for province code '01':
fetch('/api/wards?province_code=01&limit=50')
.then(response => response.json())
.then(data => console.log(data));CORS Policy: These APIs are configured with Access-Control-Allow-Origin: *, allowing cross-origin requests from any domain.