Skip to main content

Overview

The Habitats API provides access to information about the different habitats in Zoo Arcadia, including the Savannah, Jungle, and Marshlands areas.

List All Habitats

Returns a list of all habitats in the zoo with their descriptions and associated media.
GET /api/habitats

Response Fields

success
boolean
Indicates if the request was successful
data
array
Array of habitat objects
id_habitat
integer
Unique identifier for the habitat
habitat_name
string
Name of the habitat (e.g., “Savannah”, “Jungle”, “Marshlands”)
description_habitat
string
Detailed description of the habitat
media_path
string
URL path to the habitat’s image (original size)
media_path_medium
string
URL path to the habitat’s medium-sized image
media_path_large
string
URL path to the habitat’s large-sized image
animal_count
integer
Number of animals residing in this habitat (when requested)

Example Request

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

Example Response

{
  "success": true,
  "data": [
    {
      "id_habitat": 1,
      "habitat_name": "Savannah",
      "description_habitat": "Experience the African plains with our lions, zebras, and giraffes in their natural savannah environment.",
      "media_path": "/uploads/habitats/savannah.jpg",
      "media_path_medium": "/uploads/habitats/savannah-medium.jpg",
      "media_path_large": "/uploads/habitats/savannah-large.jpg"
    },
    {
      "id_habitat": 2,
      "habitat_name": "Jungle",
      "description_habitat": "Explore the dense tropical rainforest home to gorillas, parrots, and exotic reptiles.",
      "media_path": "/uploads/habitats/jungle.jpg",
      "media_path_medium": "/uploads/habitats/jungle-medium.jpg",
      "media_path_large": "/uploads/habitats/jungle-large.jpg"
    },
    {
      "id_habitat": 3,
      "habitat_name": "Marshlands",
      "description_habitat": "Discover wetland species including crocodiles, flamingos, and aquatic birds.",
      "media_path": "/uploads/habitats/marshlands.jpg",
      "media_path_medium": "/uploads/habitats/marshlands-medium.jpg",
      "media_path_large": "/uploads/habitats/marshlands-large.jpg"
    }
  ]
}

Get Habitat by ID

Retrieves detailed information about a specific habitat including its description and media.
GET /api/habitats/{id}

Path Parameters

id
integer
required
The unique identifier of the habitat

Response Fields

success
boolean
Indicates if the request was successful
data
object
Habitat object containing detailed information
id_habitat
integer
Unique identifier for the habitat
habitat_name
string
Name of the habitat
description_habitat
string
Detailed description of the habitat
media_path
string
URL path to the habitat’s image (original size)
media_path_medium
string
URL path to the habitat’s medium-sized image
media_path_large
string
URL path to the habitat’s large-sized image

Example Request

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

Example Response

{
  "success": true,
  "data": {
    "id_habitat": 1,
    "habitat_name": "Savannah",
    "description_habitat": "Experience the African plains with our lions, zebras, and giraffes in their natural savannah environment.",
    "media_path": "/uploads/habitats/savannah.jpg",
    "media_path_medium": "/uploads/habitats/savannah-medium.jpg",
    "media_path_large": "/uploads/habitats/savannah-large.jpg"
  }
}

Error Responses

Invalid Habitat ID

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

Habitat Not Found

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

Resource Not Found

When the habitats endpoint is not available:
{
  "error": true,
  "message": "Resource 'habitats' not found"
}
HTTP Status Code: 404 Not Found

Build docs developers (and LLMs) love