
- Enhance character model with additional fields - Create relationship between anime and characters - Implement character search functionality - Create Alembic migration for character table - Add sample character data for seeding - Update README with character endpoint information
Anime Information API
This is a FastAPI application that provides anime information via a RESTful API.
Features
- Anime Information: Comprehensive anime data including titles, synopsis, episodes, scores, etc.
- Genre Management: Create, read, update, and delete anime genres
- Character Management: Create, read, update, and delete anime characters
- Advanced Search: Search anime with multiple filters including year, score range, source, studio, etc.
- Smart Pagination: Built-in pagination with metadata for easy navigation
- Statistics Dashboard: Get statistical insights about the anime collection
- Health Endpoint: Check the health of the application and its database connection
Tech Stack
- Framework: FastAPI
- Database: SQLite with SQLAlchemy ORM
- Migration Tool: Alembic
- Validation: Pydantic
- Code Quality: Ruff linter
Project Structure
anime-information-api/
├── alembic/ # Database migrations
├── app/ # Application code
│ ├── api/ # API endpoints
│ │ └── endpoints/ # Route definitions
│ ├── core/ # Core application components
│ ├── crud/ # CRUD operations
│ ├── db/ # Database setup
│ ├── initial_data/ # Data seeding
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── storage/ # Storage for SQLite database
├── alembic.ini # Alembic config
├── main.py # Application entry point
├── requirements.txt # Dependencies
└── seed_data.py # Script to seed initial data
Getting Started
Prerequisites
- Python 3.9+
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Database Setup
Run the Alembic migrations to set up the database schema:
alembic upgrade head
Seed the database with initial data:
python seed_data.py
Running the Application
Start the application with:
uvicorn main:app --reload
The API will be available at http://localhost:8000, and the interactive API documentation at http://localhost:8000/docs.
API Endpoints
Health Check
GET /health
: Check application health
Anime
GET /api/v1/anime/
: Get anime list with advanced filtering and paginationGET /api/v1/anime/statistics
: Get statistics about the anime collectionPOST /api/v1/anime/
: Create new animeGET /api/v1/anime/{id}
: Get anime by IDPUT /api/v1/anime/{id}
: Update animeDELETE /api/v1/anime/{id}
: Delete anime
Genres
GET /api/v1/genres/
: Get genre listPOST /api/v1/genres/
: Create new genreGET /api/v1/genres/{id}
: Get genre by IDPUT /api/v1/genres/{id}
: Update genreDELETE /api/v1/genres/{id}
: Delete genre
Characters
GET /api/v1/characters/
: Search characters with filters (name, anime_id, role)POST /api/v1/characters/
: Create new characterGET /api/v1/characters/{id}
: Get character by IDPUT /api/v1/characters/{id}
: Update characterDELETE /api/v1/characters/{id}
: Delete characterGET /api/v1/characters/anime/{anime_id}
: Get all characters for a specific anime
Advanced Search Parameters
Anime Search Parameters
The anime search endpoint supports the following parameters:
title
: Filter by title (partial match)genre_id
: Filter by genre IDstatus
: Filter by anime status (airing, finished, upcoming)year_from
: Filter by starting year (inclusive)year_to
: Filter by ending year (inclusive)score_min
: Filter by minimum score (inclusive)score_max
: Filter by maximum score (inclusive)source
: Filter by source material (manga, light novel, etc.)studio
: Filter by studio name (partial match)sort_by
: Sort by field (id, title, score, popularity, etc.)sort_order
: Sort order (asc, desc)skip
: Number of items to skip for paginationlimit
: Maximum number of items to return
Character Search Parameters
The character search endpoint supports the following parameters:
name
: Filter by character name (partial match)anime_id
: Filter by anime IDrole
: Filter by character role (Main, Supporting, Antagonist, etc.)skip
: Number of items to skip for paginationlimit
: Maximum number of items to return
Statistics
The statistics endpoint provides the following information:
- Total anime count
- Average score and episode count
- Distribution by status, source, and studio
- Yearly distribution of releases
- Score distribution
- Top genres
Description
Languages
Python
99.2%
Mako
0.8%