API Documentation: /api
Endpoint
GET /api
Description
This endpoint serves as an API to retrieve a random possum image from the server's collection. Each request logs the API access, including the IP address, user agent, and referrer for analytical purposes.
Request
There are no required parameters or headers for this endpoint.
Response
Success (200 OK):
Returns a JSON object containing a URL to a random possum image.
{
"url": "https://possumparadise.com/static/images/random_possum_image.jpg"
}
Properties:
url
(string): The absolute URL to the randomly selected possum image.
Error (500 Internal Server Error):
Returns a JSON object with an error message if no possum images are found on the server.
{
"error": "No possum images found"
}
Properties:
error
(string): A descriptive error message.
Example Usage
Using curl
curl -X GET https://possumparadise.com/api
Expected curl
Response (Success)
{
"url": "https://possumparadise.com/static/images/possum_123.jpg"
}
Using JavaScript (Fetch API)
fetch('https://possumparadise.com/api')
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log(data.url);
// Example: Display the image
const img = document.createElement('img');
img.src = data.url;
document.body.appendChild(img);
})
.catch(error => {
console.error('Error fetching possum image:', error);
});
Notes
- The IP address of the requester is anonymized and stored in the database for analytics.
- This endpoint is designed for simple integration into applications requiring random possum images.