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
- type Anime
- type Broadcast
- type Character
- type Client
- func (c *Client) GetAnime(ctx context.Context, id int) (*Anime, error)
- func (c *Client) Schedule(ctx context.Context, limit int) ([]Anime, error)
- func (c *Client) SearchAnime(ctx context.Context, query string, limit int) ([]Anime, error)
- func (c *Client) SearchCharacters(ctx context.Context, query string, limit int) ([]Character, error)
- func (c *Client) SearchManga(ctx context.Context, query string, limit int) ([]Manga, error)
- func (c *Client) SearchPeople(ctx context.Context, query string, limit int) ([]Person, error)
- func (c *Client) Season(ctx context.Context, year int, season string, limit int) ([]Anime, error)
- func (c *Client) TopAnime(ctx context.Context, typ string, limit int) ([]Anime, error)
- type Config
- type Domain
- type Genre
- type Manga
- type Person
- type Studio
Constants ¶
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 (*Client) GetAnime ¶ added in v0.1.1
GetAnime fetches a single anime by its MAL ID using the /full endpoint.
func (*Client) Schedule ¶ added in v0.1.1
Schedule returns today's airing anime schedule. Limit is clamped to 25.
func (*Client) SearchAnime ¶ added in v0.1.1
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
SearchManga searches manga by title keyword. Limit is clamped to 25.
func (*Client) SearchPeople ¶ added in v0.1.1
SearchPeople searches MAL people (voice actors, staff) by name. 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) 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.
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.).