jikan

package
v0.1.0 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 API (api.jikan.moe), the unofficial open-source MyAnimeList proxy.

No API key is required. The client paces itself to ~2.5 req/s to stay under Jikan's 3 req/s rate limit, and retries transient 429/5xx failures with exponential backoff.

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 {
	Rank     int      `json:"rank"`
	MalID    int      `json:"mal_id"`
	Title    string   `json:"title"`
	TitleEn  string   `json:"title_english"`
	Score    float64  `json:"score"`
	Episodes int      `json:"episodes"` // 0 when unknown/ongoing
	Type     string   `json:"type"`     // "TV", "Movie", "OVA", "ONA", "Special", "Music"
	Season   string   `json:"season"`   // "spring", "summer", "fall", "winter"
	Year     int      `json:"year"`
	Status   string   `json:"status"` // "Finished Airing", "Currently Airing", "Not yet aired"
	Genres   []string `json:"genres"`
	URL      string   `json:"url"` // myanimelist.net URL
}

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

type Client

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

Client talks to the Jikan API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Search

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

Search returns anime matching the query string. Pass limit <= 0 to use the API default of 25.

func (*Client) Season

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

Season returns anime from the currently airing season. Pass limit <= 0 to use the API default of 25.

func (*Client) Top

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

Top returns the top-ranked anime by MAL score. Pass limit <= 0 to use the API default of 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 set to 400 ms (~2.5 req/s) to stay under Jikan's 3 req/s 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.

Jump to

Keyboard shortcuts

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