Class: Jikanrb::Resources::AnimeResource

Inherits:
BaseResource show all
Defined in:
lib/jikanrb/resources/anime_resource.rb

Overview

Resource class for accessing Anime sub-resources from the Jikan API. Provides fluent API access to anime details, characters, staff, episodes, news, forum topics, videos, pictures, statistics, and more.

Examples:

Basic usage

client = Jikanrb::Client.new
anime = client.anime(1)
anime.info                   # GET /anime/1
anime.info(full: true)       # GET /anime/1/full
anime.characters             # GET /anime/1/characters
anime.episodes               # GET /anime/1/episodes

See Also:

Instance Attribute Summary

Attributes inherited from BaseResource

#id

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Jikanrb::Resources::BaseResource

Instance Method Details

#charactersHash

Returns characters and their voice actors for this anime

Examples:

client.anime(1).characters
# => { data: [{ character: { mal_id: 1, name: "Spike Spiegel" }, role: "Main", voice_actors: [...] }, ...] }

Returns:

  • (Hash)

    List of characters as IndifferentHash



44
45
46
# File 'lib/jikanrb/resources/anime_resource.rb', line 44

def characters
  get("anime/#{@id}/characters")
end

#episodes(page: nil) ⇒ Hash

Returns episodes for this anime

Examples:

Get first page of episodes

client.anime(1).episodes
# => { data: [{ mal_id: 1, title: "Asteroid Blues", ... }, ...], pagination: { ... } }

Get specific page

client.anime(1).episodes(page: 2)

Parameters:

  • page (Integer, nil) (defaults to: nil)

    Page number for pagination

Returns:

  • (Hash)

    List of episodes as IndifferentHash



70
71
72
# File 'lib/jikanrb/resources/anime_resource.rb', line 70

def episodes(page: nil)
  get("anime/#{@id}/episodes", { page: page }.compact)
end

#externalHash

Returns external links for this anime

Examples:

client.anime(1).external
# => { data: [{ name: "Official Site", url: "https://..." }, ...] }

Returns:

  • (Hash)

    List of external links as IndifferentHash



169
170
171
# File 'lib/jikanrb/resources/anime_resource.rb', line 169

def external
  get("anime/#{@id}/external")
end

#forumHash

Returns forum topics related to this anime

Examples:

client.anime(1).forum
# => { data: [{ mal_id: 1, title: "...", date: "...", author_username: "..." }, ...] }

Returns:

  • (Hash)

    List of forum topics as IndifferentHash



92
93
94
# File 'lib/jikanrb/resources/anime_resource.rb', line 92

def forum
  get("anime/#{@id}/forum")
end

#info(full: false) ⇒ Hash

Returns anime details

Examples:

Get basic info

client.anime(1).info
# => { data: { mal_id: 1, title: "Cowboy Bebop", ... } }

Get full info

client.anime(1).info(full: true)
# => { data: { mal_id: 1, title: "...", relations: [...], themes: {...} } }

Parameters:

  • full (Boolean) (defaults to: false)

    If true, returns extended information including relations, themes, external links, and streaming links

Returns:

  • (Hash)

    Anime data as IndifferentHash



32
33
34
35
# File 'lib/jikanrb/resources/anime_resource.rb', line 32

def info(full: false)
  path = full ? "anime/#{@id}/full" : "anime/#{@id}"
  get(path)
end

#newsHash

Returns news articles related to this anime

Examples:

client.anime(1).news
# => { data: [{ mal_id: 1, title: "...", date: "...", author_username: "..." }, ...] }

Returns:

  • (Hash)

    List of news articles as IndifferentHash



81
82
83
# File 'lib/jikanrb/resources/anime_resource.rb', line 81

def news
  get("anime/#{@id}/news")
end

#picturesHash

Returns pictures of this anime

Examples:

client.anime(1).pictures
# => { data: [{ jpg: { image_url: "https://..." }, webp: { ... } }, ...] }

Returns:

  • (Hash)

    List of pictures as IndifferentHash



114
115
116
# File 'lib/jikanrb/resources/anime_resource.rb', line 114

def pictures
  get("anime/#{@id}/pictures")
end

#recommendationsHash

Returns user recommendations for this anime

Examples:

client.anime(1).recommendations
# => { data: [{ entry: { mal_id: 5, title: "..." }, votes: 123 }, ...] }

Returns:

  • (Hash)

    List of recommendations as IndifferentHash



136
137
138
# File 'lib/jikanrb/resources/anime_resource.rb', line 136

def recommendations
  get("anime/#{@id}/recommendations")
end

#relationsHash

Returns related anime/manga entries

Examples:

client.anime(1).relations
# => { data: [{ relation: "Adaptation", entry: [{ mal_id: 173, type: "manga", name: "..." }] }, ...] }

Returns:

  • (Hash)

    List of relations as IndifferentHash



147
148
149
# File 'lib/jikanrb/resources/anime_resource.rb', line 147

def relations
  get("anime/#{@id}/relations")
end

#staffHash

Returns staff members for this anime

Examples:

client.anime(1).staff
# => { data: [{ person: { mal_id: 1, name: "..." }, positions: ["Director"] }, ...] }

Returns:

  • (Hash)

    List of staff as IndifferentHash



55
56
57
# File 'lib/jikanrb/resources/anime_resource.rb', line 55

def staff
  get("anime/#{@id}/staff")
end

#statisticsHash

Returns statistics for this anime

Examples:

client.anime(1).statistics
# => { data: { watching: 12345, completed: 67890, on_hold: 1234, ... } }

Returns:

  • (Hash)

    Statistics data as IndifferentHash



125
126
127
# File 'lib/jikanrb/resources/anime_resource.rb', line 125

def statistics
  get("anime/#{@id}/statistics")
end

#streamingHash

Returns streaming links for this anime

Examples:

client.anime(1).streaming
# => { data: [{ name: "Crunchyroll", url: "https://..." }, ...] }

Returns:

  • (Hash)

    List of streaming platforms as IndifferentHash



180
181
182
# File 'lib/jikanrb/resources/anime_resource.rb', line 180

def streaming
  get("anime/#{@id}/streaming")
end

#themesHash

Returns opening and ending themes for this anime

Examples:

client.anime(1).themes
# => { data: { openings: ["Tank! by The Seatbelts"], endings: ["The Real Folk Blues by ..."] } }

Returns:

  • (Hash)

    Theme songs as IndifferentHash



158
159
160
# File 'lib/jikanrb/resources/anime_resource.rb', line 158

def themes
  get("anime/#{@id}/themes")
end

#videosHash

Returns videos (PVs, episodes, music videos) for this anime

Examples:

client.anime(1).videos
# => { data: { promo: [...], episodes: [...], music_videos: [...] } }

Returns:

  • (Hash)

    Video data as IndifferentHash



103
104
105
# File 'lib/jikanrb/resources/anime_resource.rb', line 103

def videos
  get("anime/#{@id}/videos")
end