π Anichin API adalah sebuah API RESTful yang dikembangkan untuk memudahkan developer dalam mengakses data anime dan donghua. Proyek ini telah direfactor dengan type annotations, logging komprehensif, dan error handling yang robust untuk production-ready deployment.
- π Search Anime/Donghua - Pencarian berdasarkan query
- π Anime Information - Detail lengkap anime/donghua
- π¬ Episode Details - Informasi episode dan video sources
- π·οΈ Genre Filtering - Filter berdasarkan genre
- π Home Page Content - Konten halaman utama dengan section
- π₯ Video Sources - Ekstraksi link video streaming
- π Comprehensive Logging - Logging sistem untuk monitoring
- π‘οΈ Type Safety - Full type annotations untuk better development experience
- π Error Handling - Robust error handling untuk stabilitas
- Framework: Flask with CORS support
- Web Scraping: BeautifulSoup4 + Requests
- Type Safety: Python typing module
- Logging: Python logging with file and console output
- Environment: python-dotenv for configuration
http://localhost:5000
| Endpoint | Method | Description | Parameters | Response |
|---|---|---|---|---|
/ |
GET | Get home page content | page (optional) - int |
JSON dengan data halaman utama |
/search/<query> |
GET | Search anime by query | query - string (required) |
JSON dengan hasil pencarian |
/<slug> |
GET | Get anime details | slug - string (required) |
JSON dengan detail anime |
/genres |
GET | List all genres | None | JSON dengan daftar genre |
/genre/<slug> |
GET | Get anime by genre | slug - string (required)page (optional) - int |
JSON dengan anime berdasarkan genre |
/episode/<slug> |
GET | Get episode details | slug - string (required) |
JSON dengan detail episode |
/video-source/<slug> |
GET | Get video sources | slug - string (required) |
JSON dengan sumber video |
/anime |
GET | List anime with filters | Query parameters optional | JSON dengan daftar anime |
{
"result": {...},
"source": "https://anichin.club/...",
"total": 10
}{
"message": "Error description",
"error": "Detailed error information"
}- Python 3.8+
- pip package manager
git clone https://github.com/asmindev/anichin-api
cd anichin-apipip install -r requirements.txtCreate a .env file in the root directory:
USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3# Development mode
python main.py
# Production mode
gunicorn -w 4 -b 0.0.0.0:5000 main:appThe API will be available at http://localhost:5000
Aplikasi menggunakan comprehensive logging system:
- File Logging: Logs disimpan di
anichin_api.log - Console Logging: Output ke terminal untuk development
- Log Levels: DEBUG, INFO, WARNING, ERROR
- Structured Format: Timestamp, module, level, dan message
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('anichin_api.log'),
logging.StreamHandler(sys.stdout)
]
)| HTTP Status | Description | Example |
|---|---|---|
200 |
Success | Request berhasil |
400 |
Bad Request | Parameter tidak valid |
404 |
Not Found | Resource tidak ditemukan |
500 |
Internal Server Error | Error server internal |
anichin-api/
βββ main.py # Flask application entry point
βββ api/
β βββ __init__.py # Main API handler class
β βββ utils/ # Utility modules
β βββ parsing.py # Base scraping class
β βββ info.py # Anime information scraper
β βββ search.py # Search functionality
β βββ episode.py # Episode details scraper
β βββ home.py # Home page content scraper
β βββ genre.py # Genre listing and filtering
β βββ anime.py # Anime listing scraper
β βββ video.py # Video source extraction
βββ requirements.txt # Python dependencies
βββ anichin_api.log # Application logs
βββ README.md # Documentation
Proyek ini menggunakan type annotations untuk better development experience:
def get_info(self, slug: str) -> Dict[str, Any]:
"""Get anime information by slug."""
try:
logger.info(f"Getting info for slug: {slug}")
return Info(slug).to_json()
except Exception as e:
logger.error(f"Error getting info for {slug}: {e}")
return {"result": None, "error": str(e)}- Inherit dari
Parsingbase class - Implement required methods dengan type hints
- Add comprehensive error handling
- Include proper logging
- Update main API handler
curl "http://localhost:5000/search/one%20piece"curl "http://localhost:5000/battle-through-the-heavens-season-5"curl "http://localhost:5000/video-source/perfect-world-episode-03-subtitle-indonesia"curl "http://localhost:5000/genres"- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow type annotations
- Add comprehensive logging
- Include error handling
- Write descriptive commit messages
- Test endpoints thoroughly
This project is licensed under the MIT License - see the LICENSE file for details.
- @iniasmin_ - Original Developer
- @asmindev - Maintainer
- Anichin.club untuk sumber data
- Flask community untuk framework yang amazing
- BeautifulSoup untuk web scraping capabilities
Jika ada pertanyaan atau masalah, silakan:
- Open an issue di GitHub repository
- Contact via Instagram @iniasmin_
Made with β€οΈ for the anime community