{"id":20095342,"url":"https://github.com/rlalpha49/anilink","last_synced_at":"2025-10-24T19:08:36.198Z","repository":{"id":235931948,"uuid":"791565131","full_name":"RLAlpha49/AniLink","owner":"RLAlpha49","description":"API wrapper for AniManga sites such as Anilist, MyAnimeList, Kitsu.","archived":false,"fork":false,"pushed_at":"2024-05-22T22:42:26.000Z","size":9325,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-22T23:22:10.747Z","etag":null,"topics":["anilist","anilist-api","kitsu","kitsu-api","myanimelist","myanimelist-api","npm-package","typescript"],"latest_commit_sha":null,"homepage":"https://rlalpha49.github.io/AniLink/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RLAlpha49.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-04-25T00:20:03.000Z","updated_at":"2024-05-27T22:32:11.598Z","dependencies_parsed_at":"2024-05-27T22:32:03.173Z","dependency_job_id":"d7c04e9e-82e2-4a63-9ecf-93fa5fe30603","html_url":"https://github.com/RLAlpha49/AniLink","commit_stats":null,"previous_names":["rlalpha49/anilink"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RLAlpha49%2FAniLink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RLAlpha49%2FAniLink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RLAlpha49%2FAniLink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RLAlpha49%2FAniLink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RLAlpha49","download_url":"https://codeload.github.com/RLAlpha49/AniLink/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241534684,"owners_count":19978022,"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":["anilist","anilist-api","kitsu","kitsu-api","myanimelist","myanimelist-api","npm-package","typescript"],"created_at":"2024-11-13T16:54:56.081Z","updated_at":"2025-10-24T19:08:31.115Z","avatar_url":"https://github.com/RLAlpha49.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AniLink\n\nFor full documentation on methods and parameters, please refer to the [AniLink documentation](https://rlalpha49.github.io/AniLink/).\n\nAniLink is a TypeScript library for interacting with the AniList API. It provides methods for querying and mutating data, making it easier to integrate AniList's features into your own applications.\n\n## Installation\n\nTo install AniLink, you can use npm or yarn.:\n\n```bash\nnpm install anilink-api-wrapper\n```\n\nor\n\n```bash\nyarn add anilink-api-wrapper\n```\n\n## Initialization\n\n### AniList\n\nTo start using AniLink, you need to import it and initialize it with an optional authentication token. You can get an authentication token by registering your application on the AniList website.\n\n#### Typescript\n\n```typescript\nimport AniLink from 'anilink-api-wrapper';\n```\n\n#### Javascript\n\n```javascript\nconst AniLink = require('anilink-api-wrapper');\n```\n\n#### Initialization\n\n```typescript\nconst authToken = 'your-auth-token';\nconst aniLink = new AniLink(authToken);\n```\n\nYou can also initialize AniLink without an authentication token\n\n```typescript\nconst aniLink = new AniLink();\n```\n\n## AniList API\n\n### Structure\n\nAniLink for AniList is divided into two main sections: `anilist.query` and `anilist.mutation`. The `anilist.query` section contains methods for querying data from the AniList API, while the `anilist.mutation` section contains methods for mutating data.\n\n#### Custom Queries and Mutations\n\nIf needed there is a custom section `anilist.custom` that allows the user to pass a custom query or mutation to the AniList API.\n\nThe method accepts two parameters: the query or mutation string and an optional variables object.\n\n```typescript\nconst viewer = await aniLink.anilist.custom('query {Viewer {id}}');\n\nconst mutation = 'mutation ($about: String) {UpdateUser (about: $about) {id}}';\nconst variables = { about: \"New about text\" };\nconst response = await aniLink.anilist.custom(mutation, variables);\n```\n\n#### Query Methods\n\nThe `anilist.query` section is further divided into main query methods and page query methods. The main query methods return a single piece of data, while the page query methods return pages of data.\n\nList of main query methods in `anilist.query`:\n\n- user\n- media\n- mediaTrend\n- airingSchedule\n- character\n- staff\n- mediaList\n- mediaListCollection\n- genreCollection\n- mediaTagCollection\n- viewer\n- notification\n- studio\n- review\n- activity\n- activityReply\n- following\n- follower\n- thread\n- threadComment\n- recommendation\n- markdown\n- aniChartUser\n- siteStatistics\n- externalLinkSourceCollection\n\nList of page query methods in `anilist.query.page`:\n\n- users\n- medias\n- characters\n- staffs\n- studios\n- mediaLists\n- airingSchedules\n- mediaTrends\n- notifications\n- followers\n- following\n- activities\n- activityReplies\n- threads\n- threadComments\n- reviews\n- recommendations\n- likes\n\n#### Mutation Methods\n\nList of methods in `anilist.mutation`:\n\n- updateUser\n- saveMediaListEntry\n- updateMediaListEntries\n- deleteMediaListEntries\n- deleteCustomLists\n- saveTextActivity\n- saveMessageActivity\n- deleteActivity\n- toggleActivityPin\n- toggleActivitySubscription\n- saveActivityReply\n- deleteActivityReply\n- toggleLike\n- toggleLikeV2\n- toggleFollow\n- toggleFavourite\n- updateFavouriteOrder\n- saveReview\n- deleteReview\n- saveRecommendation\n- saveThread\n- deleteThread\n- toggleThreadSubscription\n- saveThreadComment\n- deleteThreadComment\n- updateAniChartSettings\n- updateAniChartHighlights\n\n### Error Handling\n\nAniLink will throw an error if the AniList API returns an error. You can catch these errors using a try-catch block.\n\n```typescript\ntry {\n  const user = await aniLink.anilist.query.user({id: 542244});\n  console.log(user);\n} catch (error) {\n  console.error(error);\n}\n```\n\nThis includes status codes and error messages returned by the AniList API. Here is an example rate limit handler to catch the errors thrown by AniLink:\n\n##### Typescript\n\n```typescript\nasync function handleRateLimit(apiCall: () =\u003e Promise\u003cany\u003e, retryAfter = 60) {\n  try {\n    let response;\n    try {\n      response = await apiCall();\n    } catch (error) {\n      throw error;\n    }\n    console.log(response.data);\n    return response;\n  } catch (error: any) {\n    if (error.response \u0026\u0026 error.response.status === 429) {\n      console.log('Rate limit exceeded, waiting for 1 minute before retrying...');\n      await new Promise(resolve =\u003e setTimeout(resolve, retryAfter * 1000));\n      console.log('Retrying...');\n      return handleRateLimit(apiCall, retryAfter);\n    } else {\n      if (error.response \u0026\u0026 error.response.data) {\n        throw error.response.data;\n      } else {\n        throw error.response || error;\n      }\n    }\n  }\n}\n```\n\n##### Javascript\n\n```javascript\nasync function handleRateLimit(apiCall, retryAfter = 60) {\n    // Same as above\n}\n```\n\nThe possible error codes returned by the AniList API are:\n- 400: Bad Request (e.g. missing variables, invalid variables, or invalid query)\n- 401: Unauthorized (e.g. invalid authentication token)\n- 404: Not Found (e.g. user not found)\n- 429: Too Many Requests (e.g. rate limit exceeded)\n- 500: Internal Server Error (e.g. AniList server error)\n\n#### Missing or Invalid Variables\n\nAniLink will also throw an error if any variables are missing or invalid. For example, if you try to query a user providing a string instead of a number for ID, AniLink will throw an error. Most variables are optional however there a few that are required.\n```typescript\ntry {\n  const user = await aniLink.anilist.query.user({id: '542244'});\n  console.log(user);\n} catch (error) {\n  console.error(error);\n}\n```\n\nExample Error Thrown:\n\n```typescript\n  Invalid id: 542244. Expected type: number\n```\n\n### Examples\n\nSee the [ANILIST_API_EXAMPLES](https://github.com/RLAlpha49/AniLink/blob/master/Examples/ANILIST_API_EXAMPLES.md) for examples of how to use AniLink to interact with the AniList API.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/RLAlpha49/AniLink/blob/master/LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlalpha49%2Fanilink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frlalpha49%2Fanilink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlalpha49%2Fanilink/lists"}