Possum Paradise API Docs

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:

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:

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