AniList API Wrapper
A comprehensive, modular Rust wrapper for the AniList GraphQL API.
Features
- Modular Design: Separate endpoints for all AniList features
- Authentication Support: Both authenticated and unauthenticated clients
- Async/Await Support: Built with Tokio for asynchronous operations
- Type Safety: Strongly typed responses with Serde serialization
- Comprehensive Coverage: Full AniList API coverage including social features
- Error Handling: Proper error types for different failure scenarios
- Pagination: Built-in support for paginated results
- Tested: Comprehensive test suite covering all endpoints
Supported Endpoints
Core Content
- Anime: Popular, trending, search, seasonal, top-rated, airing
- Manga: Popular, trending, search, top-rated, releasing, completed
- Characters: Popular, search, by ID, with media roles
- Staff: Popular, search, by ID, with media roles
- Studios: Search, by ID, with media productions
Social & Community
- Users: Profiles, statistics, favorites, lists, followers
- Forums: Threads, comments, categories, search
- Activities: Text activities, list updates, replies, likes
- Reviews: Create, read, update, delete user reviews
- Recommendations: Browse and manage anime/manga recommendations
- Notifications: Read, manage, and mark as read
Scheduling & Discovery
- Airing Schedules: Upcoming episodes, recently aired, date ranges
- Trending & Popular: Real-time trending content across all types
Quick Start
Add this to your Cargo.toml:
[]
= "0.1.1"
= { = "1.0", = ["full"] }
Authentication
For endpoints requiring authentication, set up your environment:
# Get your token from https://anilist.co/settings/developer
API Endpoints
Public Endpoints (No Authentication Required)
All clients (authenticated and unauthenticated) can access these endpoints:
Anime
get_popular(page, per_page)- Get popular animeget_trending(page, per_page)- Get trending animeget_by_id(id)- Get anime by IDsearch(query, page, per_page)- Search anime by titleget_by_season(season, year, page, per_page)- Get anime by season/yearget_top_rated(page, per_page)- Get highest rated animeget_airing(page, per_page)- Get currently airing anime
Manga
get_popular(page, per_page)- Get popular mangaget_trending(page, per_page)- Get trending mangaget_by_id(id)- Get manga by IDsearch(query, page, per_page)- Search manga by titleget_top_rated(page, per_page)- Get highest rated mangaget_releasing(page, per_page)- Get currently releasing mangaget_completed(page, per_page)- Get completed manga
Characters
get_popular(page, per_page)- Get popular charactersget_by_id(id)- Get character by IDsearch(query, page, per_page)- Search characters by nameget_by_birthday(month, day, page, per_page)- Get characters by birthdayget_most_favorited(page, per_page)- Get most favorited characters
Staff
get_popular(page, per_page)- Get popular staffget_by_id(id)- Get staff by IDsearch(query, page, per_page)- Search staff by nameget_by_birthday(month, day, page, per_page)- Get staff by birthdayget_most_favorited(page, per_page)- Get most favorited staff
Users (Public Data)
get_by_id(id)- Get user by IDget_by_name(name)- Get user by usernamesearch(query, page, per_page)- Search usersget_most_anime_watched(page, per_page)- Get users with most anime watchedget_most_manga_read(page, per_page)- Get users with most manga read
Authenticated Endpoints (Requires Access Token)
These endpoints require an authenticated client created with AniListClient::with_token():
User (Private Data)
get_current_user()- Get current authenticated user's profileget_current_user_anime_list(status)- Get current user's anime list
Note: More authenticated endpoints will be added in future versions for list management, favorites, etc.
Usage Examples
Basic Usage
use AniListClient;
async
Authenticated Client
For accessing user-specific data, you'll need an authenticated client:
use AniListClient;
async
Getting an Access Token
To get an access token for authentication:
- Register your application at AniList Developer Console
- Implement OAuth2 flow to get user authorization
- Exchange authorization code for access token
- Use the access token with
AniListClient::with_token()
Anime Operations
use AniListClient;
async
Manga Operations
use AniListClient;
async
Character Operations
use AniListClient;
async
Staff Operations
use AniListClient;
async
User Operations
use AniListClient;
async
Error Handling
The library provides comprehensive error handling:
use ;
async
Data Models
The library includes comprehensive data models for all AniList entities:
- Anime: Complete anime information including titles, descriptions, episodes, genres, etc.
- Manga: Complete manga information including chapters, volumes, status, etc.
- Character: Character details including names, images, descriptions, birthdays, etc.
- Staff: Staff information including names, roles, occupations, etc.
- User: User profiles including statistics, favorites, and preferences.
Testing
Run the test suite:
The library includes comprehensive tests for all endpoints:
- Unit tests for each endpoint method
- Integration tests for the complete API workflow
- Error handling tests
- Pagination tests
Rate Limiting
The AniList API has rate limiting. The client handles basic error responses, but you should implement your own rate limiting logic for production applications.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.