Skip to content

Repository files navigation

🍡 anilist

Command-line client for the AniList GraphQL API

anilist is an OCaml command-line client for the AniList GraphQL API. It lowers concise CLI arguments into GraphQL operations and prints JSON responses.

Screenshot

Features

  • Ergonomic lowering for common AniList queries
  • Tree-shaped selection support with --field and --selection-set
  • Variables, fragments, inline fragments, and multi-operation documents
  • Schema introspection via schema, schema --type, and schema --directive
  • Custom HTTP headers with repeated --header
  • Docker runner for use without a local OCaml toolchain

Build

dune build

Install

Install the executable into your local opam prefix:

dune install --release

Then run:

anilist media --id 1 --selection-set id,title.romaji,format,status

Docker

Build the image:

docker build -t fuwn/anilist .

Run a query:

docker run --rm fuwn/anilist media --id 1 --selection-set id,title.romaji,format,status

Shell Script Savings

In a shell script, the usual GraphQL flow means carrying an endpoint, a JSON payload, and a quoted query string:

endpoint='https://graphql.anilist.co'

curl \
  --silent \
  --header 'Content-Type: application/json' \
  --data '{"query":"query { Media(id: 1) { id title { romaji } format status } }"}' \
  "$endpoint"

With anilist, the same request becomes the command itself:

anilist media --id 1 --selection-set id,title.romaji,format,status

That removes the JSON wrapper, the embedded GraphQL string, and most of the shell quoting friction while keeping the JSON response unchanged.

Usage

Get an anime:

anilist media --id 1 --selection-set id,title.romaji,format,status

Inspect the schema:

anilist schema
anilist schema --type Media
anilist schema --directive include

Send an authorization header:

anilist --header 'Authorization: Bearer <token>' media --id 1 --selection-set id,title.romaji

Use variables explicitly:

anilist query \
  --variable-definition '$media_id: Int!' \
  --variable 'media_id=1' \
  --field media \
  --id var:media_id \
  --selection-set id,title.romaji,format,status

The endpoint defaults to https://graphql.anilist.co. Override it with ANILIST_GRAPHQL_ENDPOINT:

ANILIST_GRAPHQL_ENDPOINT='https://graphql.anilist.co' anilist media --id 1 --selection-set id,title.romaji

License

Licensed under the GNU Affero General Public License v3.0 only. See LICENSE.

About

🍡 Command-line client for the AniList GraphQL API

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Contributors

Languages