zeromero-dev / AniAPI.js

A Javascript wrapper for aniapi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AniAPI.js

A Javascript wrapper for aniapi

Installation

npm i @mattplays/aniapi

Usage

To get your JWT login to ANIAPI here

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT"); 

For more info on the provided functions:

  1. Anime
    1. GetByID
    2. Get
    3. Random
  2. Episode
    1. GetByID
    2. Get
  3. Song
    1. GetByID
    2. Get
    3. Random
  4. Resource
    1. GetLastAvailableResourceVersion
    2. Get
  5. User
    1. GetByID
    2. Get
    3. Update
    4. Delete
  6. UserStory
    1. GetByID
    2. Get
    3. Create
    4. Update
    5. Delete
  7. Enums
    1. AnimeFormat
    2. AnimeStatus
    3. AnimeSeasonPeriod
    4. AnimeSongType
    5. AnimeResourceType
    6. UserRole
    7. UserGender
    8. UserStoryStatus

All Responses from this Wrapper should be in accordance with the docs

⚠ If not, Please Inform ⚠

Anime.GetByID

Parameters

Parameter Type Description
id string ID of the Anime you want - more info

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Anime.GetByID(11).then((data) => {
    // Your Code HERE :D
}).catch((err) => {
    // Handle err here D:
});

Anime.Get

Parameters

Parameter Type Description
filters AnimeFilters Filters you want to apply [At least 1] - more info
page number The page number of the paginated results
per_page number Number of results you want per page

Currently the following filters and their types are:

Filter Type Description
title string A case-insensitive pattern filter on the list based on the titles field values.
anilist_id number A filter on the list based on the anilist_id field value.
mal_id number A filter on the list based on the mal_id field value.
formats AnimeFormat[] A filter on the list based on the format field value.
status AnimeStatus[] A filter on the list based on the status field value.
year number A filter on the list based on the season_year field value.
season number A filter on the list based on the season_period field value.
genres string[] A case-sensitive pattern filter on the list based on the genres field values.
nsfw boolean A filter on the list which excludes Anime classified as Not Safe For Work.

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Anime.Get({
    genres: [
      "Action",
      "Adventure",
      "Comedy"
    ],
    formats: [ANIAPI.ENUMS.AnimeFormat.TV, ANIAPI.ENUMS.AnimeFormat.MOVIE], // 0 is for TV, 2 is for Movie,
    status: [ANIAPI.ENUMS.AnimeStatus.FINISHED, ANIAPI.ENUMS.AnimeStatus.RELEASING] // 0 is for Finished, 1 is for Releasing
}, 1, 100).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

Anime.Random

Parameters

Parameter Type Description
count number N/A

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Anime.Random(10).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

Episode.GetByID

Parameters

Parameter Type Description
id string ID of the Episode you want - more info

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Episode.GetByID(485).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

Episode.Get

Parameters

Parameter Type Description
filters EpisodeFilters Filters you want to apply [At least 1] - more info
page number The page number of the paginated results
per_page number Number of results you want per page

Currently the following filters and their types are:

Filter Type Description
anime_id number A filter on the list based on the anime_id field value.
number number a filter on the list based on the episode number
source string a filter on the list based on the publisher of the anime episode
locale string a filter on the list based on the language of the episode

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Episode.Get({
    anime_id: 11,
    source: "dreamsub",
    locale: "it",
}, 1, 100).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

Song.GetByID

Parameters

Parameter Type Description
id string ID of the Song you want - more info

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Song.GetByID(11).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

Song.Get

Parameters

Parameter Type Description
filters SongFilters Filters you want to apply [At least 1] - more info
page number The page number of the paginated results
per_page number Number of results you want per page

Currently the following filters and their types are:

Filter Type Description
anime_id number A filter on the list based on the anime_id field value.
title string A case-insensitive pattern filter on the list based on the title field value.
artist string A case-insensitive pattern filter on the list based on the artist field value.
year number A filter on the list based on the year field value.
season AnimeSeasonPeriod[] A filter on the list based on the season field value.
type AnimeSongType[] A filter on the list based on the type field value.

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Song.Get({
    anime_id: 4,
    season: [ANIAPI.ENUMS.AnimeSeasonPeriod.WINTER, ANIAPI.ENUMS.AnimeSeasonPeriod.SPRING], // 0 Is for Winter, 1 is for Spring
    type: [ANIAPI.ENUMS.AnimeSongType.OPENING, ANIAPI.ENUMS.AnimeSongType.ENDING] // 0 is for Opening, 1 is for Ending
}).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

Song.Random

Parameters

Parameter Type Description
count number N/A

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Song.Random(10).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

Resource.GetLastAvailableResourceVersion

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Resource.GetLastAvailableResourceVersion().then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

Resource.Get

Parameters

Parameter Type Description
version string a string which identifies the latest available Resources' version.
type AnimeResourceType N/A

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.Resource.Get("1.0", ANIAPI.ENUMS.AnimeResourceType.GENRES).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
});

User.GetByID

Parameters

Parameter Type Description
id string ID of the User you want - more info

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.User.GetByID(134).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

User.Get

Parameters

Parameter Type Description
filters UserFilters Filters you want to apply [At least 1] - more info
page number The page number of the paginated results
per_page number Number of results you want per page

Currently the following filters and their types are:

Filter Type Description
username number A case-insensitive pattern filter on the list based on the username field value.
email string A case-sensitive filter on the list based on the email field value.

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.User.Get({
    username: "SomebodyRandom",
    email: "real@email.com"
}, 1, 100).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

User.Update

Parameters

Parameter Type Description
id string The User's id to update
changes UserChanges The changes you want to apply. More Info

Currently the following changes and their types are:

Change Type Description
password string The User's new password value.
gender UserGender The User's gender value.
localization string The User's new localization value.
anilist_id number The User's AniList account external id.
anilist_token string The User's AniList account external token. This value becomes required when you provide the anilist_id field.

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.User.Update(134, {
    gender: aniapi.ENUMS.UserGender.MALE
}).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

User.Delete

Parameters

Parameter Type Description
id string The User's id to delete

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.User.Delete(134).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

UserStory.GetByID

Parameters

Parameter Type Description
id string The User_Story's id to fetch

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.UserStory.GetByID(1).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

UserStory.Get

Parameters

Parameter Type Description
filters UserStoryFilters Filters you want to apply [At least 1] - more info
page number The page number of the paginated results
per_page number Number of results you want per page

Currently the following filters and their types are:

Filter Type Description
anime_id number A filter on the list based on the anime_id field value.
user_id number A filter on the list based on the user_id field value.
status UserStoryStatus A filter on the list based on the status field value.
synced boolean A filter on the list based on the synced field value. synced field indicates if an UserStory has been synchronized with User's linked trackers.

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.UserStory.Get({
    status: aniapi.ENUMS.UserStoryStatus.COMPLETED,
    synced: true
}).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

UserStory.Create

Parameters

Parameter Type Description
input UserStoryChanges The User_Story's object to create

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.UserStory.Create({
    user_id: 134,
    anime_id: 11,
    status: aniapi.ENUMS.UserStoryStatus.COMPLETED,
    current_episode: 24,
}).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

UserStory.Update

Parameters

Parameter Type Description
changes UserStoryChanges The User_Story's object to update

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.UserStory.Update({
    id: 1,
    anime_id: 11,
    status: aniapi.ENUMS.UserStoryStatus.COMPLETED,
    current_episode: 24,
}).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

UserStory.Delete

Parameters

Parameter Type Description
id string The User_Story's id to delete

Usage

const ANIAPI = require("@mattplays/aniapi");
const API = new ANIAPI.API("DUMMY_JWT");

API.UserStory.Delete(1).then((data) => {
    // Your Code Here :D
}).catch((err) => {
    // Handle error Here D:
})

Enums

AnimeFormat

Possible enum values

"TV": 0,
"TV_SHORT": 1,
"MOVIE": 2,
"SPECIAL": 3,
"OVA": 4,
"ONA": 5,
"MUSIC": 6

AnimeStatus

Possible enum values

"FINISHED": 0,
"RELEASING": 1,
"NOT_YET_RELEASED": 2,
"CANCELLED": 3

AnimeSeasonPeriod

Possible enum values

"WINTER": 0,
"SPRING": 1,
"SUMMER": 2,
"FALL": 3,
"UNKNOWN": 4

AnimeSongType

Possible enum values

"OPENING": 0,
"ENDING": 1,
"NONE": 2

AnimeResourceType

Possible enum values

"GENRES": 0,
"LOCALIZATIONS": 1

UserRole

Possible enum values

"BASIC": 0,
"MODERATOR": 1,
"ADMINISTRATOR": 2,

UserGender

Possible enum values

"UNKNOWN": 0,
"MALE": 1,
"FEMALE": 2,

UserStoryStatus

"CURRENT": 0,
"PLANNING": 1,
"COMPLETED": 2,
"DROPPED": 3,
"PAUSED": 4,
"REPEATING": 5

License

MIT License - Copyright (c) 2021 MattPlays License

About

A Javascript wrapper for aniapi

License:MIT License


Languages

Language:JavaScript 100.0%