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.
Response Fields
Indicates if the request was successful
Array of habitat objectsUnique identifier for the habitat
Name of the habitat (e.g., “Savannah”, “Jungle”, “Marshlands”)
Detailed description of the habitat
URL path to the habitat’s image (original size)
URL path to the habitat’s medium-sized image
URL path to the habitat’s large-sized image
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.
Path Parameters
The unique identifier of the habitat
Response Fields
Indicates if the request was successful
Habitat object containing detailed informationUnique identifier for the habitat
Detailed description of the habitat
URL path to the habitat’s image (original size)
URL path to the habitat’s medium-sized image
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