Skip to content

Repository files navigation

Jikan C++ Library

License: MIT C++17

A professional, modern C++ library for the Jikan API - the unofficial MyAnimeList REST API.

Features

  • 🚀 Complete API Coverage - All Jikan v4 endpoints supported
  • Rate Limiting Built-in - Automatic 3 req/s limit handling
  • 🔒 Thread-Safe - Safe for concurrent usage
  • 📦 Easy Integration - Header-organized design
  • Well Tested - Comprehensive unit tests

Requirements

  • C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
  • libcurl (for HTTP requests)
  • nlohmann/json (included as single header)

Installation

# Clone the repository
git clone https://github.com/mhmmdyusran/jikan-cpp.git
cd jikan-cpp

# Build the library
make

# Install (Linux/macOS)
sudo make install

Complete Usage Guide

Include the Library

#include <jikan/jikan.hpp>

Create Client

jikan::Client client;  // Rate limiting is automatic

Anime Endpoints

Get Anime by ID

auto anime = client.anime().getById(1);  // Cowboy Bebop
std::cout << "Title: " << anime.title << std::endl;
std::cout << "Score: " << *anime.score << std::endl;
std::cout << "Episodes: " << *anime.episodes << std::endl;
std::cout << "Status: " << *anime.status << std::endl;
std::cout << "Synopsis: " << *anime.synopsis << std::endl;

Get Full Anime Details

auto anime = client.anime().getFullById(1);
// Includes relations, themes, streaming links
for (const auto& rel : anime.relations) {
    std::cout << rel.relation << std::endl;
}

Get Anime Characters

auto characters = client.anime().getCharacters(1);
for (const auto& c : characters) {
    std::cout << c.character.name << " - " << c.role << std::endl;
    for (const auto& va : c.voice_actors) {
        std::cout << "  VA: " << va.person.name << " (" << va.language << ")" << std::endl;
    }
}

Get Anime Episodes

auto response = client.anime().getEpisodes(1, 1);  // page 1
for (const auto& ep : response.data) {
    std::cout << "Episode " << ep.mal_id << ": " << ep.title << std::endl;
}

Get Anime Staff

auto staff = client.anime().getStaff(1);
for (const auto& s : staff) {
    std::cout << s.person.name << ": ";
    for (const auto& pos : s.positions) {
        std::cout << pos << " ";
    }
    std::cout << std::endl;
}

Get Anime News, Videos, Statistics

auto news = client.anime().getNews(1);
auto videos = client.anime().getVideos(1);
auto stats = client.anime().getStatistics(1);

std::cout << "Watching: " << stats.watching << std::endl;
std::cout << "Completed: " << stats.completed << std::endl;

Get Anime Reviews

auto reviews = client.anime().getReviews(1);
for (const auto& r : reviews.data) {
    std::cout << r.user.username << " scored: " << r.score << std::endl;
}

Search Anime

jikan::AnimeSearchParams params;
params.q = "Naruto";
params.type = "tv";
params.status = "complete";
params.min_score = 7.0;
params.order_by = "score";
params.sort = "desc";
params.sfw = true;

auto results = client.anime().search(params);
for (const auto& a : results.data) {
    std::cout << a.title << " - Score: " << *a.score << std::endl;
}

// Pagination info
std::cout << "Page: " << results.pagination.current_page << std::endl;
std::cout << "Has next: " << results.pagination.has_next_page << std::endl;

Manga Endpoints

Get Manga by ID

auto manga = client.manga().getById(1);  // Monster
std::cout << "Title: " << manga.title << std::endl;
std::cout << "Chapters: " << *manga.chapters << std::endl;
std::cout << "Volumes: " << *manga.volumes << std::endl;

Search Manga

jikan::MangaSearchParams params;
params.q = "One Piece";
params.type = "manga";
params.status = "publishing";

auto results = client.manga().search(params);

Character Endpoints

Get Character by ID

auto character = client.characters().getById(1);  // Spike Spiegel
std::cout << "Name: " << character.name << std::endl;
std::cout << "Favorites: " << character.favorites << std::endl;

Get Character Anime/Manga Appearances

auto anime = client.characters().getAnime(1);
auto manga = client.characters().getManga(1);

Get Voice Actors

auto voices = client.characters().getVoices(1);
for (const auto& v : voices) {
    std::cout << v.person.name << " (" << v.language << ")" << std::endl;
}

Search Characters

jikan::CharacterSearchParams params;
params.q = "Naruto";
auto results = client.characters().search(params);

People Endpoints

Get Person by ID

auto person = client.people().getById(1);
std::cout << "Name: " << person.name << std::endl;
std::cout << "Birthday: " << *person.birthday << std::endl;

Get Person's Anime/Voice Roles

auto anime = client.people().getAnime(1);
auto voices = client.people().getVoices(1);

User Endpoints

Get User Profile

auto user = client.users().getByUsername("Nekomata1037");
std::cout << "Username: " << user.username << std::endl;
std::cout << "Joined: " << *user.joined << std::endl;

Get User Statistics

auto stats = client.users().getStatistics("Nekomata1037");
std::cout << "Anime watched: " << stats.anime.completed << std::endl;
std::cout << "Mean score: " << stats.anime.mean_score << std::endl;
std::cout << "Days watched: " << stats.anime.days_watched << std::endl;

Get User Favorites

auto favorites = client.users().getFavorites("Nekomata1037");
for (const auto& a : favorites.anime) {
    std::cout << "Favorite anime: " << a.title << std::endl;
}

Get User Anime/Manga List

jikan::UserListParams params;
params.status = "completed";

auto animeList = client.users().getAnimeList("Nekomata1037", params);
for (const auto& entry : animeList.data) {
    std::cout << entry.title << " - Score: " << entry.score << std::endl;
}

auto mangaList = client.users().getMangaList("Nekomata1037", params);

Get User History and Friends

auto history = client.users().getHistory("Nekomata1037");
auto friends = client.users().getFriends("Nekomata1037");

Season Endpoints

Get Current Season

auto current = client.seasons().getNow();
for (const auto& a : current.data) {
    std::cout << a.title << std::endl;
}

Get Specific Season

auto winter2024 = client.seasons().getSeason(2024, "winter");
auto summer2023 = client.seasons().getSeason(2023, "summer");

Get Upcoming Season

auto upcoming = client.seasons().getUpcoming();

Get Season Archive

auto archive = client.seasons().getArchive();

Top Rankings

Get Top Anime/Manga

auto topAnime = client.top().getTopAnime();
auto topManga = client.top().getTopManga();

for (int i = 0; i < 10 && i < topAnime.data.size(); i++) {
    std::cout << "#" << (i+1) << " " << topAnime.data[i].title << std::endl;
}

Get Top by Filter

jikan::TopAnimeParams params;
params.type = "tv";
params.filter = "airing";
auto airing = client.top().getTopAnime(params);

params.filter = "bypopularity";
auto popular = client.top().getTopAnime(params);

Get Top Characters/People

auto topCharacters = client.top().getTopCharacters();
auto topPeople = client.top().getTopPeople();

Schedule Endpoints

Get Weekly Schedule

auto schedule = client.schedule().getSchedule();  // All days

Get Schedule by Day

auto monday = client.schedule().getSchedule("monday");
auto saturday = client.schedule().getSchedule("saturday");

Producers & Magazines

Get Producer/Studio Info

auto producer = client.producers().getById(1);  // Studio Pierrot
std::cout << "Studio: " << producer.titles[0].title << std::endl;

Search Producers

jikan::ProducerSearchParams params;
params.q = "MAPPA";
auto results = client.producers().search(params);

Get Magazine Info

auto magazine = client.magazines().getById(1);

Club Endpoints

Get Club Details

auto club = client.clubs().getById(1);
std::cout << "Club: " << club.name << std::endl;
std::cout << "Members: " << club.members_count << std::endl;

Get Club Members/Staff

auto members = client.clubs().getMembers(1);
auto staff = client.clubs().getStaff(1);

Genre Endpoints

Get All Genres

auto animeGenres = client.genres().getAnimeGenres();
auto mangaGenres = client.genres().getMangaGenres();

for (const auto& g : animeGenres) {
    std::cout << g.name << " (" << g.count << " anime)" << std::endl;
}

Random Endpoints

Get Random Content

auto randomAnime = client.random().getAnime();
auto randomManga = client.random().getManga();
auto randomCharacter = client.random().getCharacter();
auto randomPerson = client.random().getPerson();

Recent Reviews & Recommendations

Get Recent Reviews

auto animeReviews = client.reviews().getAnimeReviews();
auto mangaReviews = client.reviews().getMangaReviews();

Get Recent Recommendations

auto animeRecs = client.recommendations().getAnimeRecommendations();
auto mangaRecs = client.recommendations().getMangaRecommendations();

Watch Endpoints

Get Recent Episodes & Promos

auto recentEps = client.watch().getRecentEpisodes();
auto popularEps = client.watch().getPopularEpisodes();
auto promos = client.watch().getRecentPromos();

Error Handling

#include <jikan/exceptions.hpp>

try {
    auto anime = client.anime().getById(99999999);
} catch (const jikan::NotFoundException& e) {
    std::cerr << "Not found: " << e.what() << std::endl;
} catch (const jikan::RateLimitException& e) {
    std::cerr << "Rate limited: " << e.what() << std::endl;
} catch (const jikan::ApiException& e) {
    std::cerr << "API error (" << e.statusCode() << "): " << e.what() << std::endl;
} catch (const jikan::NetworkException& e) {
    std::cerr << "Network error: " << e.what() << std::endl;
} catch (const jikan::ParseException& e) {
    std::cerr << "Parse error: " << e.what() << std::endl;
}

Build Commands

make              # Build static library (default)
make static       # Build static library (libjikan.a)
make shared       # Build shared library (libjikan.so)
make tests        # Build and run unit tests
make examples     # Build example programs
make install      # Install to /usr/local
make uninstall    # Remove installation
make clean        # Remove build directory
make DEBUG=1      # Debug build

Compile Your Program

# After installation
g++ -std=c++17 your_program.cpp -ljikan -lcurl -o your_program

# Without installation (using local build)
g++ -std=c++17 -I./include -I./third_party your_program.cpp \
    -L./build/lib -ljikan -lcurl -o your_program

Examples

See the examples directory:

  • basic_usage.cpp - Basic anime/manga lookup
  • search_example.cpp - Advanced search with filters
  • user_list.cpp - Fetching user anime/manga lists

License

MIT License - see LICENSE for details.

Acknowledgments

About

No description, website, or topics provided.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages