API ReferenceReference Data

Countries

List all countries or retrieve a single country by ID

GET /api/v1/countries

Returns all active countries with ISO 3166 codes and dialing prefixes.

Request

curl https://api.octopuscards.io/api/v1/countries \
  -H "Authorization: Bearer <token>"

No query parameters.

Response

[
  {
    "id": 1,
    "name": "United States",
    "official_name": "United States of America",
    "alpha_2": "US",
    "alpha_3": "USA",
    "numeric_code": "840",
    "dialing_prefix": "+1"
  }
]

Response Fields

KeyTypeDescription
idintegerUnique country identifier
namestringCommon country name
official_namestringOfficial country name
alpha_2stringISO 3166-1 alpha-2 code (2 characters, e.g. US)
alpha_3stringISO 3166-1 alpha-3 code (3 characters, e.g. USA)
numeric_codestringISO 3166-1 numeric code (e.g. 840)
dialing_prefixstringInternational dialing prefix (e.g. +1)

Errors

401 Unauthorized - Missing or invalid JWT token.

{
  "error": {
    "name": "UnauthorizedError",
    "code": "UNAUTHORIZED",
    "message": "Authorization header required"
  }
}

GET /api/v1/countries/:id

Returns a single country by its ID.

Request

curl https://api.octopuscards.io/api/v1/countries/1 \
  -H "Authorization: Bearer <token>"

Request Parameters

KeyTypeRequiredDescription
idintegerYesCountry ID (path parameter). Must be between 1 and 2,147,483,647.

Response

{
  "id": 1,
  "name": "United States",
  "official_name": "United States of America",
  "alpha_2": "US",
  "alpha_3": "USA",
  "numeric_code": "840",
  "dialing_prefix": "+1"
}

Response fields are identical to the list endpoint above.

Errors

400 Bad Request - ID is not a valid integer or out of range.

{
  "error": {
    "name": "BadRequestError",
    "code": "BAD_REQUEST",
    "message": "Invalid country ID"
  }
}

On this page