{"id":16989597,"url":"https://github.com/didas-git/anilist-wrapper","last_synced_at":"2025-06-20T07:36:48.889Z","repository":{"id":63740322,"uuid":"569009236","full_name":"Didas-git/anilist-wrapper","owner":"Didas-git","description":"An UNOFFICIAL wrapper for the anilist graphql api","archived":false,"fork":false,"pushed_at":"2024-02-18T15:03:20.000Z","size":540,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-12T21:22:02.715Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Didas-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-21T22:11:08.000Z","updated_at":"2024-10-12T18:20:45.000Z","dependencies_parsed_at":"2023-02-10T05:45:59.135Z","dependency_job_id":"50a8f775-46d3-4b75-b22a-ce8633be56d2","html_url":"https://github.com/Didas-git/anilist-wrapper","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"d6cab90d405decda927d27a6ffe40e81be1f87fa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Didas-git/anilist-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fanilist-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fanilist-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fanilist-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fanilist-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Didas-git","download_url":"https://codeload.github.com/Didas-git/anilist-wrapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fanilist-wrapper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260901665,"owners_count":23079806,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T03:07:11.808Z","updated_at":"2025-06-20T07:36:43.863Z","avatar_url":"https://github.com/Didas-git.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anilist Wrapper\n\nAn UNOFFICIAL wrapper for the anilist api written in typescript that tries to follow the [builder pattern](https://refactoring.guru/design-patterns/builder) to give a more consistent interface to create objects.\n\nYou can visit the official graphql docs for anilist [here](https://anilist.github.io/ApiV2-GraphQL-Docs/) to find out everything you can do[^*].\n\n## Table of Contents\n\n- [Anilist Wrapper](#anilist-wrapper)\n  - [Table of Contents](#table-of-contents)\n  - [Status](#status)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Creating a query](#creating-a-query)\n    - [Query arguments](#query-arguments)\n    - [Creating the query](#creating-the-query)\n      - [Page Query](#page-query)\n      - [Other Queries](#other-queries)\n        - [Fetching without building the query](#fetching-without-building-the-query)\n        - [Creating a complete search query](#creating-a-complete-search-query)\n        - [Relations](#relations)\n        - [Passing arguments at run time](#passing-arguments-at-run-time)\n  - [OAuth](#oauth)\n    - [`createOAuthURI`](#createoauthuri)\n      - [Implicit Grant URI](#implicit-grant-uri)\n      - [Authorization Code Grant](#authorization-code-grant)\n    - [`getAccessToken`](#getaccesstoken)\n\n## Status\n\nTo see the current status of the wrapper check the [todo](TODO.md) list.\n\n\u003e **Warning**\n\u003e As of v0.12 the only way to create queries is `query.\u003cqueryName\u003e`\n\n## Installation\n\n```sh\nnpm i anilist\n```\n\n## Usage\n\n### Creating a query\n\n```ts\nconst query = anilist.query.media();\n```\n\n### Query arguments\n\nThe queries can accept either an object of `MediaArguments` or a string.\n\nIf you pass in a string it will be transformed into `{ search: string }` internally.\n\n```ts\nconst queryByName = anilist.query.media(\"Kamisama Ni Natta Hi\");\n/*\nquery {\n    Media(type: ANIME, search: \"Kamisama Ni Natta Hi\") {\n        id\n    }\n}\n*/\n\nconst queryById = anilist.query.media({\n    id: 118419\n});\n/*\nquery {\n    Media(type: ANIME, id: 118419) {\n        id\n    }\n}\n*/\n```\n\n### Creating the query\n\n#### Page Query\n\nif you build the query and fetch it without telling which fields to return it will default to returning `{ media: { id } }` with `{ page: 1, perPage: 10 }`\n\n```ts\nconst query = anilist.pageQuery()\n\nawait query.fetch()\n/*\n{\n  media: [\n    { id: 1 },  { id: 5 }, \n    { id: 6 },  { id: 7 }, \n    { id: 8 },  { id: 15 },\n    { id: 16 }, { id: 17 },\n    { id: 18 }, { id: 19 } \n  ]\n}\n*/\n\nquery.withMedia(media =\u003e media.withTitles())\n\nawait query.fetch()\n/*\n{\n  media: [\n    { title: { romaji: 'Cowboy Bebop' } },\n    { title: { romaji: 'Cowboy Bebop: Tengoku no Tobira' } },\n    { title: { romaji: 'TRIGUN' } },\n    { title: { romaji: 'Witch Hunter ROBIN' } },\n    { title: { romaji: 'Bouken Ou Beet' } },\n    { title: { romaji: 'Eyeshield 21' } },\n    { title: { romaji: 'Hachimitsu to Clover' } },\n    { title: { romaji: 'Hungry Heart: Wild Striker' } },\n    { title: { romaji: 'Initial D FOURTH STAGE' } },\n    { title: { romaji: 'MONSTER' } }\n  ]\n}\n*/\n```\n\n#### Other Queries\n\n##### Fetching without building the query\n\nIf you build the query and try to fetch it without telling which fields to return it will default to returning `id` to avoid errors.\n\n```ts\nconst query = anilist.query.media(\"Kamisama Ni Natta Hi\");\n\nawait query.fetch();\n/*\n{ id: 118419 }\n*/\n\nquery.withEpisodes();\n\nawait query.fetch();\n/*\n{ episodes: 12 }\n*/\n```\n\n##### Creating a complete search query\n\nAs the library follows the builder pattern you can just nest functions until you have every field you want.\n\n```ts\nconst query = anilist.query.media(\"Kamisama Ni Natta Hi\")\n        .withId()\n        .withSiteUrl()\n        .withTitles()\n        .withStatus();\n\nawait query.fetch();\n/*\n{\n  id: 118419,\n  siteUrl: 'https://anilist.co/anime/118419',\n  title: {\n    romaji: 'Kamisama ni Natta Hi'\n  },\n  status: 'FINISHED'\n}\n*/\n```\n\n##### Relations\n\nAll relations that use edges and nodes will have the following structure\n\n```ts\nanilist.query.media().withRelations({\n  edges: (edge) =\u003e edge.withId().withNode((node) =\u003e node.withId()),\n  nodes: (node) =\u003e node.withId(),\n  pageInfo: (page) =\u003e page.withTotal(),\n  // And optionally they will have an args object\n})\n```\n\n##### Passing arguments at run time\n\nInstead of passing the query arguments on query creation you can use `\u003cquery.media\u003e.prototype.arguments` to change them every time you want to run fetch. This will avoid creating a new query instance every time you change something on it.\n\n```ts\nconst query = anilist.query.media();\n\nawait query.fetch()\n/*\n{ id: 1 }\n*/\n\nquery.arguments({\n  search: \"Kamisama Ni Natta\",\n  type: \"MANGA\"\n}).withId().withTitles(\"romaji\", \"native\")\n\nawait query.fetch()\n/*\n{\n  id: 135190,\n  title: { romaji: 'Kamisama ni Natta Hi', native: '神様になった日' }\n}\n*/\n```\n\n## OAuth\n\nThe library provides 2 helpers methods for OAuth and i will explain them here\n\n\u003e **Remember:** \n\u003e All options can be passed to the client constructor so you don't have to pass them in every function\n\n### `createOAuthURI`\n\nThis method returns the url with all required properties\n\n#### Implicit Grant URI\n\n```ts\n// \nconst uri = anilist.createOAuthURI({\n  clientId: /* the id (can be an number or string) */,\n  responseType: \"token\"\n});\n```\n\n#### Authorization Code Grant\n\n```ts\nconst uri = const uri = anilist.createOAuthURI({\n  clientId: /* the id (can be an number or string) */,\n  responseType: \"code\"\n})\n```\n\n### `getAccessToken`\n\nThis helper method allows you to convert the Authorization Code Grant into an access token \n\n```ts\nconst response = anilist.getAccessToken(codeGrant, {\n  clientId: /* the id (can be an number or string) */,\n  clientSecret: /* the client secret */,\n  redirectUri: /* the redirect uri, this is required for this step*/,\n})\n```\n\n[^*]: Not everything is supported yet, please refer to the todo list to see what has full implementation or open an issue to talk about it ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidas-git%2Fanilist-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidas-git%2Fanilist-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidas-git%2Fanilist-wrapper/lists"}