AnimeHi API
A RESTful API for AnimeHi projects, providing access to anime data and streaming functionality using Hono.js, Node, Prisma, and TypeScript.
LiveUrl: https://api.animehi.live.
GitHub: Private Repository
This API powers the AnimeHi projects by providing access to anime data and streaming functionality. It is built with Hono.js, Node.js, Prisma, and TypeScript, and leverages both the Consumet API Node library and Anilist for comprehensive anime information.
The main goal of this application is to serve as a backend and to provide a learning experience in building RESTful APIs using Hono.js—a lightweight and fast web framework for Node.js. The API is designed to be efficient, scalable, and easy to use, offering endpoints for fetching anime data, streaming content, and managing user interactions.
Note: The repository is private for now, but I will make it public soon.
Will be updated soon with the repository link and proper documentation for the API endpoints.
Disclaimer: The content available through this API is sourced from the Consumet API and Anilist, and it is the user's responsibility to ensure compliance with copyright laws in their region.
Important: This API is a personal project and is not affiliated with any official anime streaming services. It is intended for educational purposes and to demonstrate the capabilities of Hono.js, Node.js, Prisma, and TypeScript in building api application.
What I Learned
- Setting up a VPS: DigitalOcean droplet with Ubuntu 22.04, configuring the server environment, and deploying the API.
- GitHub Actions: Setting up CI/CD pipelines for automated testing and deployment, ensuring code quality and reliability.
- Docker: Containerizing the application for consistent deployment across different environments, simplifying the development and deployment process.
- Testing: Implementing unit tests and integration tests to ensure the API endpoints function correctly and handle edge cases.
- Hono.js: Building a RESTful API using Hono.js, understanding its routing, middleware, and request handling capabilities.
- Securing the API: Implementing security measures such as rate limiting, cors, input validation, and error handling to protect against common vulnerabilities.
- Prisma: Learning how to use Prisma for database management, including schema design, migrations, and querying.
- Anilist OAuth: Integrating Anilist OAuth for user authentication and authorization, allowing users to log in and manage their watch history and bookmarks.
- Cheerio: Scraping additional anime data using Cheerio, enhancing the API's capabilities.
Features
- Anime Data Retrieval: Fetch detailed information about anime titles, including descriptions, genres, and ratings.
- Streaming Functionality: Provide endpoints for streaming anime episodes, ensuring a smooth viewing experience.
- User Authentication: Implement user authentication using Anilist OAuth, allowing users to log in and manage their profiles.
Technologies Used
- Hono.js: A lightweight web framework for building fast and efficient APIs.
- Node.js: The runtime environment for executing JavaScript on the server side.
- Prisma: An ORM for managing database interactions, providing a type-safe and efficient database layer.
- PostgreSQL: The database used for storing data.
- Anilist API: Used for fetching detailed anime information and user authentication.
- Vitest: A testing framework for writing unit and integration tests to ensure the API's reliability.
Development Process
The development of the AnimeHi API involved several key steps:
- Planning: Defining the API endpoints, data models, and overall architecture of the application.
- Design: Creating a clear and concise API specification, including request and response formats.
- Implementation: Building the API using Hono.js, integrating Prisma for database management, and implementing the necessary endpoints for anime data retrieval and streaming.
- Testing: Conducting thorough testing of the API endpoints to ensure they function correctly and handle edge cases gracefully.
- Deployment: Deploying the API to a production environment using Docker and DigitalOcean
Conclusion
The AnimeHi API is a powerful and efficient backend solution for the AnimeHi projects, providing access to a wide range of anime data and streaming functionality. It serves as a great learning experience in building RESTful APIs using modern technologies like Hono.js, Node.js, Prisma, and TypeScript. The API is designed to be scalable, secure, and easy to use, making it an excellent choice for developers looking to create their own anime streaming applications or learn more about API development.