jikan

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package jikan is the library behind the jikan command line: the HTTP client, request shaping, and the typed data models for the Jikan v4 API (api.jikan.moe), the unofficial open-source MyAnimeList proxy.

No API key is required. The client paces itself to 2 req/s to stay under Jikan's 3 req/s burst limit and 60 req/min sustained limit. Transient 429/5xx failures are retried with exponential back-off.

Index

Constants

View Source
const Host = "api.jikan.moe"

Host is the Jikan API host.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anime

type Anime struct {
	MalID         int       `json:"mal_id"`
	URL           string    `json:"url"`
	Title         string    `json:"title"`
	TitleEnglish  string    `json:"title_english"`
	TitleJapanese string    `json:"title_japanese"`
	Type          string    `json:"type"`
	Source        string    `json:"source"`
	Episodes      int       `json:"episodes"`
	Status        string    `json:"status"`
	Airing        bool      `json:"airing"`
	Score         float64   `json:"score"`
	ScoredBy      int       `json:"scored_by"`
	Rank          int       `json:"rank"`
	Popularity    int       `json:"popularity"`
	Members       int       `json:"members"`
	Synopsis      string    `json:"synopsis"`
	Background    string    `json:"background"`
	Premiered     string    `json:"premiered"`
	Season        string    `json:"season"`
	Year          int       `json:"year"`
	Broadcast     Broadcast `json:"broadcast"`
	Genres        []Genre   `json:"genres"`
	Studios       []Studio  `json:"studios"`
}

Anime is one anime entry returned by the Jikan v4 API. Episodes is 0 when the API reports null (ongoing with unknown count).

type Broadcast added in v0.1.1

type Broadcast struct {
	Day      string `json:"day"`
	Time     string `json:"time"`
	Timezone string `json:"timezone"`
}

Broadcast holds the weekly broadcast schedule for a currently-airing anime.

type Character added in v0.1.1

type Character struct {
	MalID     int      `json:"mal_id"`
	URL       string   `json:"url"`
	Name      string   `json:"name"`
	NameKanji string   `json:"name_kanji"`
	Nicknames []string `json:"nicknames"`
	Favorites int      `json:"favorites"`
	About     string   `json:"about"`
}

Character is a MAL character entry.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Jikan v4 API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) GetAnime added in v0.1.1

func (c *Client) GetAnime(ctx context.Context, id int) (*Anime, error)

GetAnime fetches a single anime by its MAL ID using the /full endpoint.

func (*Client) Schedule added in v0.1.1

func (c *Client) Schedule(ctx context.Context, limit int) ([]Anime, error)

Schedule returns today's airing anime schedule. Limit is clamped to 25.

func (*Client) SearchAnime added in v0.1.1

func (c *Client) SearchAnime(ctx context.Context, query string, limit int) ([]Anime, error)

SearchAnime searches anime by title keyword. Limit is clamped to 25 (Jikan's per-page maximum).

func (*Client) SearchCharacters added in v0.1.1

func (c *Client) SearchCharacters(ctx context.Context, query string, limit int) ([]Character, error)

SearchCharacters searches MAL characters by name. Limit is clamped to 25.

func (*Client) SearchManga added in v0.1.1

func (c *Client) SearchManga(ctx context.Context, query string, limit int) ([]Manga, error)

SearchManga searches manga by title keyword. Limit is clamped to 25.

func (*Client) SearchPeople added in v0.1.1

func (c *Client) SearchPeople(ctx context.Context, query string, limit int) ([]Person, error)

SearchPeople searches MAL people (voice actors, staff) by name. Limit is clamped to 25.

func (*Client) Season

func (c *Client) Season(ctx context.Context, year int, season string, limit int) ([]Anime, error)

Season returns anime from a specific year/season (winter, spring, summer, fall). Limit is clamped to 25.

func (*Client) TopAnime added in v0.1.1

func (c *Client) TopAnime(ctx context.Context, typ string, limit int) ([]Anime, error)

TopAnime returns the top-ranked anime of the given type. typ may be: tv, movie, ova, special, ona, music. Empty string returns all types. Limit is clamped to 25.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults. Rate is 500 ms (~2 req/s) to stay well under Jikan's 3 req/s burst limit.

type Domain

type Domain struct{}

Domain is the jikan driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns an input into the canonical (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Genre added in v0.1.1

type Genre struct {
	MalID int    `json:"mal_id"`
	Name  string `json:"name"`
}

Genre is a MAL genre tag.

type Manga added in v0.1.1

type Manga struct {
	MalID        int     `json:"mal_id"`
	URL          string  `json:"url"`
	Title        string  `json:"title"`
	TitleEnglish string  `json:"title_english"`
	Volumes      int     `json:"volumes"`
	Chapters     int     `json:"chapters"`
	Status       string  `json:"status"`
	Score        float64 `json:"score"`
	Rank         int     `json:"rank"`
	Genres       []Genre `json:"genres"`
	Synopsis     string  `json:"synopsis"`
}

Manga is one manga entry returned by the Jikan v4 API.

type Person added in v0.1.1

type Person struct {
	MalID      int    `json:"mal_id"`
	URL        string `json:"url"`
	Name       string `json:"name"`
	GivenName  string `json:"given_name"`
	FamilyName string `json:"family_name"`
	Birthday   string `json:"birthday"`
	Favorites  int    `json:"favorites"`
	About      string `json:"about"`
}

Person is a MAL people entry (voice actor, director, etc.).

type Studio added in v0.1.1

type Studio struct {
	MalID int    `json:"mal_id"`
	Name  string `json:"name"`
}

Studio is an anime production studio.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL