Skip to content

asmindev/anichin-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Anichin API

🎌 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.

✨ Features

  • πŸ” 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

πŸ› οΈ Technology Stack

  • 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

πŸ“‹ API Reference

Base URL

http://localhost:5000

Endpoints

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

Response Format

Success Response

{
  "result": {...},
  "source": "https://anichin.club/...",
  "total": 10
}

Error Response

{
    "message": "Error description",
    "error": "Detailed error information"
}

πŸš€ Installation & Setup

Prerequisites

  • Python 3.8+
  • pip package manager

Clone Repository

git clone https://github.com/asmindev/anichin-api
cd anichin-api

Install Dependencies

pip install -r requirements.txt

Environment Configuration

Create 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

Run the Application

# Development mode
python main.py

# Production mode
gunicorn -w 4 -b 0.0.0.0:5000 main:app

The API will be available at http://localhost:5000

πŸ“Š Logging

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

Log Configuration

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.FileHandler('anichin_api.log'),
        logging.StreamHandler(sys.stdout)
    ]
)

πŸ›‘οΈ Error Handling

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

πŸ—οΈ Architecture

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

πŸ”§ Development

Type Safety

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)}

Adding New Scrapers

  1. Inherit dari Parsing base class
  2. Implement required methods dengan type hints
  3. Add comprehensive error handling
  4. Include proper logging
  5. Update main API handler

πŸ“ Example Usage

Search Anime

curl "http://localhost:5000/search/one%20piece"

Get Anime Details

curl "http://localhost:5000/battle-through-the-heavens-season-5"

Get Video Sources

curl "http://localhost:5000/video-source/perfect-world-episode-03-subtitle-indonesia"

Get Genres

curl "http://localhost:5000/genres"

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow type annotations
  • Add comprehensive logging
  • Include error handling
  • Write descriptive commit messages
  • Test endpoints thoroughly

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Authors

πŸ™ Acknowledgments

  • Anichin.club untuk sumber data
  • Flask community untuk framework yang amazing
  • BeautifulSoup untuk web scraping capabilities

πŸ“ž Support

Jika ada pertanyaan atau masalah, silakan:

  • Open an issue di GitHub repository
  • Contact via Instagram @iniasmin_

Made with ❀️ for the anime community

About

Unofficial API from anichin site wrapped in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages