Fun Random Facts API

Introduction

Welcome to the Fun Random Facts API. This service provides a treasure trove of interesting, quirky, and educational facts for your applications. No authentication required!

Base URL

All API requests should be made to:

https://cnichols1734.pythonanywhere.com

Endpoints

1. GET /facts/random

Returns a random fun fact. Prepare to be amazed!

Example Request:

GET https://cnichols1734.pythonanywhere.com/facts/random

Example Response:

{
    "id": 42,
    "fact": "The shortest war in history lasted 38 minutes.",
    "category": "History",
    "source": "Historical Records",
    "date_added": "2024-09-21 03:35:10",
    "language": "en",
    "tags": "war, history, shortest",
    "author": "admin"
}

2. GET /categories

Retrieves a list of all available categories.

Example Request:

GET https://cnichols1734.pythonanywhere.com/categories

Example Response:

{
    "categories": ["Science", "History", "Technology", "Art"]
}

3. GET /facts/random/<category>

Returns a random fun fact from a specified category.

URL Parameters:

  • category (string): The category from which to retrieve a random fact.

Example Request:

GET https://cnichols1734.pythonanywhere.com/facts/random/Science

Example Response:

{
    "id": 85,
    "fact": "Honey never spoils. Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still edible.",
    "category": "Science",
    "source": "National Geographic",
    "date_added": "2024-09-21 10:15:30",
    "language": "en",
    "tags": "honey, preservation, food",
    "author": "admin"
}
Try the Pretty View 🎨

Response Structure

The API returns a JSON object with the following structure:

Rate Limits

To ensure fair usage and prevent our servers from exploding, the API is limited to 120 requests per minute per IP address. Exceeding this limit will result in a 429 Too Many Requests response.

Error Handling

The API uses conventional HTTP response codes to indicate success or failure of requests: