Skip to main content

Overview

The Animals API provides access to the zoo’s animal collection data, including species information, habitats, and images.

List All Animals

Returns a complete list of all animals in the zoo with their basic information.
GET /api/animals

Response Fields

success
boolean
Indicates if the request was successful
message
string
Success message describing the operation
data
array
Array of animal objects
id
integer
Unique identifier for the animal
name
string
Name of the animal
gender
string
Gender of the animal (e.g., “Male”, “Female”)
species
string
Species name of the animal
category
string
Category/classification of the animal (e.g., “Mammal”, “Bird”)
habitat
string
Name of the habitat where the animal resides
image
string
URL path to the animal’s image (original size)
image_medium
string
URL path to the animal’s medium-sized image
image_large
string
URL path to the animal’s large-sized image

Example Request

curl https://zoo-arcadia.example.com/api/animals

Example Response

{
  "success": true,
  "message": "Animals retrieved successfully",
  "data": [
    {
      "id": 1,
      "name": "Simba",
      "gender": "Male",
      "species": "Lion",
      "category": "Mammal",
      "habitat": "Savannah",
      "image": "/uploads/animals/lion-simba.jpg",
      "image_medium": "/uploads/animals/lion-simba-medium.jpg",
      "image_large": "/uploads/animals/lion-simba-large.jpg"
    },
    {
      "id": 2,
      "name": "Koko",
      "gender": "Female",
      "species": "Gorilla",
      "category": "Mammal",
      "habitat": "Jungle",
      "image": "/uploads/animals/gorilla-koko.jpg",
      "image_medium": "/uploads/animals/gorilla-koko-medium.jpg",
      "image_large": "/uploads/animals/gorilla-koko-large.jpg"
    }
  ]
}

Get Animal by ID

Retrieves detailed information about a specific animal by its unique identifier.
GET /api/animals/{id}

Path Parameters

id
integer
required
The unique identifier of the animal

Response Fields

success
boolean
Indicates if the request was successful
message
string
Success message describing the operation
data
object
Animal object containing detailed information
id
integer
Unique identifier for the animal
name
string
Name of the animal
gender
string
Gender of the animal
species
string
Species name of the animal
category
string
Category/classification of the animal
habitat
string
Name of the habitat where the animal resides
image
string
URL path to the animal’s image (original size)
image_medium
string
URL path to the animal’s medium-sized image
image_large
string
URL path to the animal’s large-sized image

Example Request

curl https://zoo-arcadia.example.com/api/animals/1

Example Response

{
  "success": true,
  "message": "Animal retrieved successfully",
  "data": {
    "id": 1,
    "name": "Simba",
    "gender": "Male",
    "species": "Lion",
    "category": "Mammal",
    "habitat": "Savannah",
    "image": "/uploads/animals/lion-simba.jpg",
    "image_medium": "/uploads/animals/lion-simba-medium.jpg",
    "image_large": "/uploads/animals/lion-simba-large.jpg"
  }
}

Error Responses

Invalid Animal ID

When an invalid or non-numeric ID is provided:
{
  "error": true,
  "message": "Invalid animal ID"
}
HTTP Status Code: 400 Bad Request

Animal Not Found

When the requested animal ID does not exist:
{
  "error": true,
  "message": "Animal not found"
}
HTTP Status Code: 404 Not Found

Build docs developers (and LLMs) love