https://github.com/fuwn/anilist-cli
🍡 Command-line client for the AniList GraphQL API
https://github.com/fuwn/anilist-cli
anilist anime api api-client cli client graphql light-novel light-novels manga ocaml
Last synced: about 2 months ago
JSON representation
🍡 Command-line client for the AniList GraphQL API
- Host: GitHub
- URL: https://github.com/fuwn/anilist-cli
- Owner: Fuwn
- License: agpl-3.0
- Created: 2026-04-02T05:15:52.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-02T05:35:55.000Z (2 months ago)
- Last Synced: 2026-04-04T16:19:10.368Z (about 2 months ago)
- Topics: anilist, anime, api, api-client, cli, client, graphql, light-novel, light-novels, manga, ocaml
- Language: OCaml
- Homepage:
- Size: 107 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🍡 `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.
## 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
```bash
dune build
```
## Install
Install the executable into your local opam prefix:
```bash
dune install --release
```
Then run:
```bash
anilist media --id 1 --selection-set id,title.romaji,format,status
```
## Docker
Build the image:
```bash
docker build -t fuwn/anilist .
```
Run a query:
```bash
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:
```bash
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:
```bash
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:
```bash
anilist media --id 1 --selection-set id,title.romaji,format,status
```
Inspect the schema:
```bash
anilist schema
anilist schema --type Media
anilist schema --directive include
```
Send an authorization header:
```bash
anilist --header 'Authorization: Bearer ' media --id 1 --selection-set id,title.romaji
```
Use variables explicitly:
```bash
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`:
```bash
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](./LICENSE).