Module: Shikimori::API::V1::Animes

Included in:
Shikimori::API::V1
Defined in:
lib/shikimori/api/v1/animes.rb

Overview

Methods for the Animes API

Instance Method Summary collapse

Instance Method Details

#anime(id, headers: nil, **query) ⇒ Hash

Get an anime by id

Examples:

Get anime with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime(1) #=> { id: 1, ... }

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Hash)

    Hash representing anime

See Also:



87
88
89
# File 'lib/shikimori/api/v1/animes.rb', line 87

def anime(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s).url, headers: headers, query: query
end

Get an anime external links

Examples:

Get related external links for anime with id equal 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_external_links(1) #=> [{ id: 1, ... }, { id: nil, ... }]

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing anime’s extenal links

Raises:

See Also:



220
221
222
# File 'lib/shikimori/api/v1/animes.rb', line 220

def anime_external_links(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s, 'external_links').url, headers: headers, query: query
end

#anime_franchise(id, headers: nil, **query) ⇒ Hash

Get an anime franchise

Examples:

Get anime franchise tree for anime with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_franchise(1) #=> { links: [{ id: 1, ... }], nodes: [{ id: 1, ... }], current_id: 1 }

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Hash)

    Hash representing of anime’s franchise tree

Raises:

See Also:



198
199
200
# File 'lib/shikimori/api/v1/animes.rb', line 198

def anime_franchise(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s, 'franchise').url, headers: headers, query: query
end

Get an related animes

Examples:

Get a related anime, manga and ranobe titles for anime with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_related(1)
#=> [{ relation: "...", relation_russian: "...", anime: { id: 3, ... }, manga: { id: 1, ... } }]

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing related animes

Raises:

See Also:



154
155
156
# File 'lib/shikimori/api/v1/animes.rb', line 154

def anime_related(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s, 'related').url, headers: headers, query: query
end

#anime_roles(id, headers: nil, **query) ⇒ Hash

Get an anime roles

Examples:

Get a first anime roles

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_roles(1) #=> { roles: [...], roles_russian: [...], character: {...}, person: {...} }

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Hash)

    Hash representing anime roles

Raises:

See Also:



109
110
111
# File 'lib/shikimori/api/v1/animes.rb', line 109

def anime_roles(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s, 'roles').url, headers: headers, query: query
end

#anime_screenshots(id, headers: nil, **query) ⇒ Array<Hash>

Get an anime screenshots

Examples:

Get screenshots for anime with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_screenshots(1) #=> [{ original: "...", preview: "..." }]

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing anime screenshots

Raises:

See Also:



176
177
178
# File 'lib/shikimori/api/v1/animes.rb', line 176

def anime_screenshots(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s, 'screenshots').url, headers: headers, query: query
end

#anime_similar(id, headers: nil, **query) ⇒ Array<Hash>

Get an anime similar

Examples:

Get a similar anime titles for anime with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_similar(1) #=> { id: 2, ... }

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing similar animes

Raises:

See Also:



131
132
133
# File 'lib/shikimori/api/v1/animes.rb', line 131

def anime_similar(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s, 'similar').url, headers: headers, query: query
end

#anime_topics(id, headers: nil, **query) ⇒ Array<Hash>

Get an anime topics

Examples:

Get topics for anime with id equal 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_topics(1) #=> [{ id: 1, ... }]

Parameters:

  • id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (**query):

  • :page (Integer)

    Number of page. Must be between 1 and 100000

  • :limit (Integer)

    Number of titles per page. Must be a lower or equal that 50

  • :kind ('anons', 'ongoing', 'released', 'episode')

    Type of topic

  • :episode (Integer)

    Number of anime’s episode. Required for :kind equal to ‘episode’

Returns:

  • (Array<Hash>)

    Array of hashes representing anime’s topics

Raises:

See Also:



246
247
248
# File 'lib/shikimori/api/v1/animes.rb', line 246

def anime_topics(id, headers: nil, **query)
  rest.get base_url.join('animes', id.to_s, 'topics').url, headers: headers, query: query
end

#animes(headers: nil, **query) ⇒ Array<Hash>

Get list of anime titles

Examples:

Get 20 anime titles on second page

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.animes(page: 2, limit: 20) #=> [{ id: 1, ... }, { id: 2, ... }, ...]

Get top 50 ongoing anime titles

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.animes(limit: 50, status: 'ongoing', order: 'ranked') #=> [{ id: 1, ... }, { id: 2, ... }, ...]

Get 10 random anime titles released in the 90s

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.animes(limit: 10, order: 'random', season: '199x') #=> [{ id: 1, ... }, { id: 2, ... }, ...]

Parameters:

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Filters and pagination for animes

Options Hash (**query):

  • :page (Integer)

    Number of page. Must be between 1 and 100000

  • :limit (Integer)

    Number of titles per page. Must be a lower or equal that 50

  • :order ("id", "id_desc", "ranked", "kind", "popularity", "name", "aired_on", "episodes", "status", "random", "ranked_random", "ranked_shiki", "created_at", "created_at_desc")

    Sorting type.

  • :type (String, Symbol)

    Type of title. Deprecated! use :kind instead

  • :kind ("tv", "movie", "ova", "ona", "special", "tv_special", "music", "pv", "cm", "tv_13", "tv_24", "tv_48")

    Type of anime title

  • :status ("anons", "ongoing", "released")

    Anime title status

  • :season (String)

    Anime season. Examples: “summer_2017”, “2016”, “2014_2016”, “199x”

  • :score (Integer)

    Minimal anime score

  • :duration ("S", "D", "F")

    Duration of anime title episode, where S – less than 10 minutes, D – less than 30 minutes and F – more than 30 minutes

  • :rating ("none", "g", "pg", "pg_13", "r", "r_plus", "rx")

    Age limit level of anime title

  • :genre (String)

    List of genre ids separated by comma

  • :genre_v2 (String)

    List of genre v2 ids separated by comma

  • :studio (String)

    List of studio ids separated by comma

  • :franchise (String)

    List of franchises separated by comma

  • :censored (TrueClass, FalseClass)

    Set to false to allow hentai, yaoi and yuri

  • :mylist ("planned", "watching", "rewatching", "completed", "on_hold", "dropped")

    Status of anime in current user list

  • :ids (String)

    List of anime ids separated by comma

  • :exclude_ids (String)

    List of anime ids separated by comma

  • :search (String)

    Search phrase to filter animes by name

Returns:

  • (Array<Hash>)

    Array of hashes representing animes

See Also:



67
68
69
# File 'lib/shikimori/api/v1/animes.rb', line 67

def animes(headers: nil, **query)
  rest.get base_url.join('animes').url, headers: headers, query: query
end