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.
- Ergonomic lowering for common AniList queries
- Tree-shaped selection support with
--fieldand--selection-set - Variables, fragments, inline fragments, and multi-operation documents
- Schema introspection via
schema,schema --type, andschema --directive - Custom HTTP headers with repeated
--header - Docker runner for use without a local OCaml toolchain
dune buildInstall the executable into your local opam prefix:
dune install --releaseThen run:
anilist media --id 1 --selection-set id,title.romaji,format,statusBuild the image:
docker build -t fuwn/anilist .Run a query:
docker run --rm fuwn/anilist media --id 1 --selection-set id,title.romaji,format,statusIn 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,statusThat removes the JSON wrapper, the embedded GraphQL string, and most of the shell quoting friction while keeping the JSON response unchanged.
Get an anime:
anilist media --id 1 --selection-set id,title.romaji,format,statusInspect the schema:
anilist schema
anilist schema --type Media
anilist schema --directive includeSend an authorization header:
anilist --header 'Authorization: Bearer <token>' media --id 1 --selection-set id,title.romajiUse 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,statusThe 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.romajiLicensed under the GNU Affero General Public License v3.0 only. See LICENSE.
