API Districts Documentation

Districts Request

This is a GET request to retrieve the list of districts. Make a request to the following endpoint:

GET /api/districts

Available Query Parameters:

Parameter Type Description Example
page Integer Number of page (min: 1) 1
per_page Integer Number of items per page (max: 1000) 10
search String District name or code to search Example District

Sample Response (Comprehensive Format):


{
  "status": "success",
  "code": 200,
  "message": "Districts retrieved successfully",
  "data": {
    "current_page": 1,
    "data": [
            {
                "id": 1,
                "name": "Example District",
                "code": "12345",
            }
    ],
    "first_page_url": "http://127.0.0.1:8000/api/districts?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "http://127.0.0.1:8000/api/districts?page=1",
    "links": [
      {
        "url": null,
        "label": "« Previous",
        "active": false
      },
      {
        "url": "http://127.0.0.1:8000/api/districts?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Next »",
        "active": false
      }
    ],
    "next_page_url": null,
    "path": "http://127.0.0.1:8000/api/districts",
    "per_page": 10,
    "prev_page_url": null,
    "to": 1,
    "total": 1
  }
}
                

Response Explanation:

  • status: Indicates the success or failure of the request. For success, the value is "success".
  • code: The HTTP status code. In this case, it’s 200, indicating a successful request.
  • message: A human-readable message about the result of the request.
  • data: An array containing the district data. Each district object includes:
    • id: The unique ID of the district.
    • name: The name of the district.
    • code: A code assigned to the district.

Notes:

  • This endpoint retrieves a list of districts. If no districts are available, the `data` array will be empty.
  • Make sure the endpoint is authenticated (if required) or accessible via the proper headers (e.g., `Authorization`).