mirror of
https://github.com/RoyalnetworkTR/turkanime-client.git
synced 2026-09-25 06:00:09 +03:00
Co-authored-by: barkeser2002 <45911502+barkeser2002@users.noreply.github.com>
TurkAnime Backend
Python FastAPI backend for anime data and progress tracking.
Features
- LiveChart.me Integration: Fetch current season anime and trending content
- Title Matching: Advanced algorithm for matching Japanese, Romaji, and English titles
- AniList Integration: User progress tracking and OAuth2 authentication
- REST API: Clean and well-documented endpoints
Installation
-
Install Python 3.9 or higher
-
Install dependencies:
pip install -r requirements.txt
Running the Server
Option 1: Using the startup script
python start_server.py
Option 2: Direct uvicorn
uvicorn server:app --reload --host 0.0.0.0 --port 8000
Option 3: Using the server module
python -m backend.server
The server will start at http://localhost:8000
API Documentation
Once the server is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
API Endpoints
Anime Endpoints
GET /api/anime/current-season- Get current season anime from LiveChart.meGET /api/anime/news- Get anime news feedGET /api/anime/recently-aired- Get recently aired episodesGET /api/anime/search?q=<query>&source=<source>- Search animeGET /api/anime/details/{anime_id}- Get detailed anime information
Title Matching Endpoints
POST /api/titles/match- Find best matching title from candidatesPOST /api/titles/normalize- Normalize a title for comparison
AniList Endpoints
GET /api/anilist/user- Get current authenticated userGET /api/anilist/list- Get user's anime listPOST /api/anilist/progress- Update anime progressGET /api/anilist/auth/url- Get OAuth authorization URLPOST /api/anilist/auth/token- Exchange OAuth code for token
Testing
Run the test suite:
python test_backend.py
Configuration
Edit config.py to change:
- API host and port
- LiveChart.me endpoints
- Request timeouts
Development
The backend uses:
- FastAPI - Modern web framework
- BeautifulSoup4 - HTML parsing
- Requests - HTTP client
- Feedparser - RSS feed parsing
- Uvicorn - ASGI server
Adding New Endpoints
- Add your endpoint function to
server.py - Use FastAPI decorators (
@app.get,@app.post, etc.) - Add type hints using Pydantic models
- Document with docstrings
Example:
@app.get("/api/example")
async def example_endpoint():
"""Example endpoint description"""
return {"success": True, "data": "example"}
CORS Configuration
The backend is configured to allow requests from:
http://localhost:3000(Next.js default)http://127.0.0.1:3000
To add more origins, edit the allow_origins list in server.py.
Error Handling
All endpoints return responses in the format:
{
"success": true,
"data": { ... }
}
Or on error:
{
"detail": "Error message"
}
Dependencies
- fastapi>=0.104.0
- uvicorn[standard]>=0.24.0
- pydantic>=2.0.0
- requests>=2.31.0
- beautifulsoup4>=4.12.0
- feedparser>=6.0.10