Skip to main content

Countries List

This endpoint provides a list of available countries in the LAX application. The list is cached for 7 days to improve performance.

Request

Endpoint

  • Method: GET
  • URL: /api/lists/countries

Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
Accept-Languageen/arNo

Response Format

The response will include a list of countries with their IDs and names. The name will be returned in either English or Arabic based on the Accept-Language header.

Success Response

{
"success": true,
"message": "Data has been retrieved successfully",
"data": [
{
"id": 1,
"name": "Saudi Arabia"
},
{
"id": 2,
"name": "United Arab Emirates"
}
],
"status_code": 200
}

Error Responses

Invalid Accept Header (406)

{
"success": false,
"message": "Not Acceptable",
"data": null,
"status_code": 406
}

Invalid Content-Type (415)

{
"success": false,
"message": "Unsupported Media Type",
"data": null,
"status_code": 415
}

Server Error (500)

{
"success": false,
"message": "Something went wrong",
"data": null,
"status_code": 500
}

Cache Behavior

The countries list is cached for 7 days to improve performance. The cache is automatically invalidated when:

  • A new country is added
  • An existing country is updated
  • A country is deleted

Response Fields

FieldTypeDescription
idintegerUnique identifier for the country
namestringCountry name in the requested language (English/Arabic)

Example Implementation Flow

  1. Make a GET request to /api/lists/countries
    • Set Accept-Language header to get names in preferred language
  2. Upon success:
    • Store the countries list in local state
    • Use the list to populate country selection dropdowns
    • Can be used in user registration or profile updates
    • Note: The list is already sorted alphabetically by name
  3. Upon error:
    • Display error message to user
    • Implement retry mechanism if needed
    • Check if the error is due to invalid headers and fix accordingly