Monica
Log in
API v1
v1
View as Markdown

List countries

GET QUERY /api/v1/countries

List every country an address can be in, named in the language of the request, in the order the address form offers them.

The active favourites of the Countries value list come first, in their order, then the 256 countries and territories of the standard, sorted the way that language sorts. A favourite is listed again at its place among every country, so deduplicate on code if you want one entry per country.

A favourite typed as a name, with no country code, is not listed here. It is still listed by List value lists. The language comes from the Accept-Language header, and falls back to English names where a language has none.

This endpoint answers GET and QUERY alike. It takes no parameters, so both requests return the same answer. How QUERY works.

Returns

Every country, not paged. The favourites of another account are never included.

data array

The favourite countries of the account, then every country.

data[] object

One country.

data[].code string

Its two letter ISO 3166 code, which is what the country of an address takes.

data[].name string

Its name in the language of the request. A favourite whose name the account wrote reads as written.

data[].favourite_id integer

The id of the favourite of the Countries list standing for this country, or null when it is not a favourite. A favourite whose name the account wrote is listed first but stands only for itself, so its country is listed with null.

Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in X-RateLimit-Remaining.

GET
curl https://my.monicahq.com/api/v1/countries \
-H "Authorization: Bearer $MONICA_TOKEN"
const response = await fetch('https://my.monicahq.com/api/v1/countries', {
headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
$response = Http::withToken($token)->get('https://my.monicahq.com/api/v1/countries');
QUERY
curl https://my.monicahq.com/api/v1/countries \
-X QUERY \
-H "Authorization: Bearer $MONICA_TOKEN"
const response = await fetch('https://my.monicahq.com/api/v1/countries', {
method: 'QUERY',
headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
$response = Http::withToken($token)->query('https://my.monicahq.com/api/v1/countries');
Response 200
{
"data": [
{
"code": "US",
"name": "United States",
"favourite_id": 12
},
{
"code": "CA",
"name": "Canada",
"favourite_id": 13
},
{
"code": "AF",
"name": "Afghanistan",
"favourite_id": null
},
{
"code": "US",
"name": "United States",
"favourite_id": 12
}
]
}

Keys act as you, with exactly the access you have. Make one per integration so you can revoke it alone.