GET api cities - raianul/gridscale GitHub Wiki

Retrieve All Cities

Retrieve all cities from the database. Apply filters for specific results.

Parameters

  • name (optional): Filter cities by name.
  • geo_location_latitude (optional): Filter cities by latitude (numeric).
  • geo_location_longitude (optional): Filter cities by longitude (numeric).
  • beauty (optional): Filter cities by beauty level. Possible values: ugly, average, gorgeous.

Endpoint

GET http://127.0.0.1:1337/api/cities

Response

Successful Response (HTTP Status Code: 200):

  • Returns a list of cities based on the applied filters.

Example Response Body:

[
  {
    "city_uuid": "f5569e6d-9121-44ff-9a9c-a4e76899e638",
    "name": "City Name",
    "geo_location_latitude": 20.0,
    "geo_location_longitude": 22.0,
    "beauty": "gorgeous",
    ...
  },
  {
    "city_uuid": "another-uuid",
    "name": "Another City",
    "geo_location_latitude": 25.0,
    "geo_location_longitude": 28.0,
    "beauty": "average",
    ...
  },
  ...
]

cURL request

curl -X GET "http://127.0.0.1:1337/api/cities?name=New_York&beauty=gorgeous"

Validation

  "message": "Validation error",
  "errors": {
    "geo_location_latitude": [
      "Must be greater than or equal to -90 and less than or equal to 90."
    ]
  }
}