Skip to content

About

REST API for random cat facts and breed information built with FastAPI

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐱 CatFactsAPI

API for getting random facts and information about cat breeds in English.

πŸ“‹ Description

CatFactsAPI is a simple and lightweight REST API built with FastAPI that returns random facts about cats and breed information. Perfect for educational projects, test applications, or just for fun.

πŸš€ Features

  • βœ… Random cat facts
  • βœ… 350+ unique facts in the database
  • βœ… Cat breed information
  • βœ… Get fact or breed by ID
  • βœ… Fact length information
  • βœ… Automatic documentation via Swagger UI
  • βœ… English-language API

πŸ“¦ Installation

Requirements

  • Python 3.8+
  • pip

Installation Steps

  1. Clone the repository:
git clone https://github.com/FelineFantasy/CatFactsAPI
cd CatFactsAPI
  1. Install dependencies:
pip install -r requirements.txt

πŸƒ Running

Local Run

Start the server using Uvicorn:

uvicorn main:app --reload

Or run the script directly (no reload):

python main.py

The server will be available at: http://localhost:8000

Online Version

The API is already deployed and available at: https://catfactsapi.onrender.com

πŸ“‘ API Endpoints

Cat Facts

Method Endpoint Description
GET / API information
GET /fact Random fact
GET /facts?limit=5 Multiple random facts
GET /fact/{id} Fact by ID (0–99)

Cat Breeds

Method Endpoint Description
GET /breed Random breed
GET /breeds?limit=5 Multiple breeds
GET /breed/{id} Breed by ID (0–9)

πŸ“– Documentation

Interactive documentation is available at:

When running locally:

πŸ§ͺ Usage Examples

cURL

# Random fact
curl https://catfactsapi.onrender.com/fact

# Random breed
curl https://catfactsapi.onrender.com/breed

# 3 random facts
curl https://catfactsapi.onrender.com/facts?limit=3

# Fact by ID
curl https://catfactsapi.onrender.com/fact/42

# Breed by ID
curl https://catfactsapi.onrender.com/breed/5

Python

import requests

# Random fact
response = requests.get("https://catfactsapi.onrender.com/fact")
data = response.json()
print(data["fact"])

# Random breed
response = requests.get("https://catfactsapi.onrender.com/breed")
data = response.json()
print(data["breed"], data["country"])

JavaScript (Fetch API)

// Random fact
fetch('https://catfactsapi.onrender.com/fact')
  .then(response => response.json())
  .then(data => console.log(data.fact));

// Random breed
fetch('https://catfactsapi.onrender.com/breed')
  .then(response => response.json())
  .then(data => console.log(data.breed, data.country));

πŸ“ Project Structure

CatFactsAPI/
β”œβ”€β”€ .github/
β”‚   └── FUNDING.yml           # Support link for DonationAlerts
β”œβ”€β”€ .gitignore                # Git ignore file
β”œβ”€β”€ LICENSE                   # MIT License
β”œβ”€β”€ main.py                   # Main application file
β”œβ”€β”€ facts.json                # Cat facts database (350+)
β”œβ”€β”€ breeds.json               # Cat breeds database (100+)
β”œβ”€β”€ requirements.txt          # Project dependencies
└── README.md                 # Documentation

πŸ’– Support the Project

If you enjoy CatFactsAPI and want to help keep the project alive, you can support me here:

DonationAlerts

Your support helps me:

  • 🐱 Keep developing new features
  • πŸ› οΈ Fix bugs and improve the game
  • β˜• Stay awake while coding at 4 AM

Every little bit is appreciated! ❀️

πŸ›  Technologies

  • FastAPI β€” Modern web framework for building APIs
  • Uvicorn β€” ASGI server
  • Render β€” Hosting (live version)

πŸ‘€ Author

  • FelineFantasy
  • License: MIT

fix: update readme

chore: cleanup

feat: add feature

refactor: improve

About

REST API for random cat facts and breed information built with FastAPI

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages