anilist

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: 13 Imported by: 0

Documentation

Overview

Package anilist is the library behind the anilist command line: the HTTP client, request shaping, and the typed data models for the AniList anime and manga database (graphql.anilist.co).

The AniList API is a GraphQL endpoint that accepts POST requests with a JSON body containing a "query" field and optional "variables". No API key or authentication required.

Index

Constants

View Source
const Host = "graphql.anilist.co"

Host is the AniList GraphQL API host.

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	ID     int    `json:"id"     kit:"id"`
	Name   string `json:"name"`
	Gender string `json:"gender"`
	Birth  string `json:"birth,omitempty"` // formatted date of birth
}

Character is a single character record returned by the character command.

type Client

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

Client talks to the AniList GraphQL API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Character

func (c *Client) Character(ctx context.Context, search string) (Character, error)

Character searches for a character by name.

func (*Client) Media

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

Media fetches a single media entry by its AniList integer ID.

func (*Client) Search

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

Search queries media by keyword. mediaType may be "ANIME", "MANGA", or "" for both. limit caps the number of results returned (0 uses the default of 20).

func (*Client) Top

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

Top returns the most popular anime or manga. mediaType must be "ANIME" or "MANGA". limit caps the number of results (0 uses 10).

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.

type Domain

type Domain struct{}

Domain is the anilist 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 Media

type Media struct {
	Rank         int      `json:"rank"`
	ID           int      `json:"id"           kit:"id"`
	TitleRomaji  string   `json:"title_romaji"`
	TitleEnglish string   `json:"title_english"`
	Type         string   `json:"type"`     // "ANIME" or "MANGA"
	Episodes     int      `json:"episodes"` // anime only; 0 for manga
	Chapters     int      `json:"chapters"` // manga only; 0 for anime
	Status       string   `json:"status"`   // "FINISHED", "RELEASING", etc.
	Score        int      `json:"score"`    // averageScore 0-100
	Genres       []string `json:"genres"`
	Description  string   `json:"description"` // HTML stripped, 200 char limit
	SiteURL      string   `json:"site_url"`    // e.g. https://anilist.co/anime/16498
}

Media is one anime or manga record emitted by every CLI command.

Jump to

Keyboard shortcuts

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