countries-api
Countries API
- Base Paths:
- Public:
/api/v1/countries - Admin:
/api/admin/countries
- Public:
- Auth:
- Public: not required
- Admin: required (admin middleware)
Provides a list of supported countries with an available flag to control whether a country is currently enabled across the app.
Model notes
- Country document stores:
name,isoAlpha2,isoAlpha3,isoNumeric,currency \{ code, name, symbol? \}, andavailable: boolean(defaulttrue).
Public: List Countries
- Method: GET
- Path:
/api/v1/countries - Query:
available(optional):true|false|all- When omitted or set to
all, returns all countries truereturns only enabled countriesfalsereturns only disabled countries
- When omitted or set to
- Response 200:
{
"result": [
{
"name": "India",
"available": true,
"listingAvailable": true,
"listingBlocked": false
},
{
"name": "United States",
"available": false,
"listingAvailable": true,
"listingBlocked": false
}
] }
- Errors: 500 on failure
- Notes:
- Results are sorted by name ascending.
- Fields exposed:
name,available,listingAvailable,listingBlocked listingAvailable: boolean indicating if listings are allowed for this country (computed as!listingBlocked)listingBlocked: boolean indicating if listings are blocked for this country
Admin: List Countries (with pagination + sorting)
- Method: GET
- Path:
/api/admin/countries - Auth: required
- Query:
available(optional):true|false|all(default:all)page(optional): number ≥ 1 (enables pagination when used withlimit)limit(optional): 1–100sort(optional):asc|desc(default:asc) — sort by country name
- Response 200 (paginated when
pageandlimitprovided):
{
"result": [
{
"_id": "...",
"id": 356,
"name": "India",
"isoAlpha2": "IN",
"isoAlpha3": "IND",
"isoNumeric": 356,
"currency": { "code": "INR", "name": "Indian Rupee", "symbol": "₹" },
"available": true
}
], "page": 1, "limit": 20, "total": 250, "totalPages": 13, "sort": "asc" }
- Response 200 (when
page/limitare omitted):- Returns a simple array of country objects (backward compatible)
- Errors: 401 unauthorized; 500 on failure
- Notes:
- On first call, the system seeds countries from
countries.jsonif the collection is empty.
- On first call, the system seeds countries from
Admin: Update Availability
- Method: PATCH
- Path:
/api/admin/countries/:isoAlpha2/availability - Auth: required
- Body:
\{ "available": boolean \} - Response 200:
{
"ok": true,
"country": { "name": "India", "isoAlpha2": "IN", "available": true },
"missingTaxRules": false
}
- Behavior:
- Toggles availability for the specified country (by ISO alpha‑2 code).
- When enabling a country with no active tax rules configured, response includes
missingTaxRules: trueand awarningmessage to prompt adding tax rules first.
- Errors: 400 invalid input; 401 unauthorized; 404 not found; 500 failure