-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the studio function Added and moved the search function under the class AniList Fleshed out more of the package.json file. Added the start of the documentation file.
- Loading branch information
1 parent
8b470ae
commit 002e940
Showing
6 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#Media | ||
- `media.anime(id)` | Fetches an anime by its id | ||
- `media.manga(id)` | Fetches a manga by its id | ||
|
||
#People | ||
- `people.character(id)` | Fetches a character by their id | ||
- `character.id` | Character's id | ||
- `character.name` | Character's name (Three sub-values: first, last, native.) | ||
- `character.image` | Character's image (Two sub-values: large and medium) | ||
- `character.description` | Character's description | ||
- `character.isFavourite` | [Requires login]: Character on the user's favourite list | ||
- `character.siteUrl` | Character's AniList URL | ||
- `character.media` | All media that the character is in (Returns ids only) | ||
|
||
- `people.staff(id)` | Fetches a staff member by their id | ||
- `staff.id` | Staff's id | ||
- `staff.name` | Staff's name (Three sub-values: first, last, native) | ||
- `staff.language` | Staff's language | ||
- `staff.image` | Staff's image (Two sub-values: large and medium) | ||
- `staff.description` | Staff's description | ||
- `staff.isFavourite` | [Requires login]: Staff is on the user's favourite list | ||
- `staff.siteUrl` | Staff's AniList URL | ||
- `staff.staffMedia` | All media that the staff has been apart of (Returns ids only) | ||
- `staff.characters` | All characters that the staff has voiced (Returns ids only) | ||
|
||
#Search | ||
- `Anilist.search(term, page, amount)` | Searches the database for an anime or manga that resembles the term provided. | ||
- `search.pageInfo` | Page object | ||
- `pageInfo.total` | Total amount of pages in search | ||
- `pageInfo.currentPage` | Current page of the search | ||
- `pageInfo.lastPage` | Last page of searched term | ||
- `pageInfo.hasNextPage` | If the page has a next page or not | ||
- `pageInfo.perPage` | How many results are on each page | ||
- `search.media` | Search results (Returns as an array) | ||
- `media.id` | Media ID | ||
- `media.title` | Title of the media (Four sub-values: english, native, romaji, userPreferred) | ||
|
||
#User | ||
- `user.profile(username|id)` | Fetches an AniList user by either their username or id. Usernames must be strings and ids must be integers. | ||
- `profile.id` | User's id | ||
- `profile.name` | User's username | ||
- `profile.about` | User's description | ||
- `profile.avatar` | User's avatar (Two sub-values: large and medium) | ||
- `profile.bannerImage` | User's banner image | ||
- `profile.isFollowing` | [Requires login] Logged in user following user | ||
- `profile.options` | User's options (Four sub-values: titleLanguage, displayAdultContent, airingNotifications, profileColor) | ||
- `profile.mediaListOptions` | Undocumented (Five sub-values: scoreFormat, rowOrder, useLegacyLists, sharedTheme, sharedThemeEnabled) | ||
- `profile.unreadNotificationCount` | Amount of unreadNotifications the user has | ||
- `profile.siteUrl` | User's AniList URL | ||
- `profile.donatorTier` | Check if the user is a donator | ||
- `profile.moderatorStatus` | Check if the user is a moderator | ||
- `profile.updatedAt` | Timestamp of the last update of the user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
const User = require('./user'); | ||
const media = require('./media'); | ||
const extra = require('./extras'); | ||
const people = require('./people'); | ||
const fetcher = require('./fetcher'); | ||
const Fetch = new fetcher(); | ||
|
||
module.exports = class AniList { | ||
constructor () { | ||
this.user = new User(); | ||
|
||
this.user = new User(); | ||
this.media = new media(); | ||
this.people = new people(); | ||
}; | ||
|
||
this.extra = new extra(); | ||
studio(id) { | ||
if (!id) { throw new Error("Studio id is not provided."); } | ||
return Fetch.send(`query($id: Int) { Studio(id: $id) { | ||
id name media { edges { id } } | ||
siteUrl isFavourite } }`, { id: id }); | ||
}; | ||
|
||
this.people = new people(); | ||
search(term, page, amount){ | ||
if (!term || !page || !amount) { throw new Error("Search term, page count, or amount per page was not provided!"); } | ||
return Fetch.send(`query ($id: Int, $page: Int, $perPage: Int, $search: String) { | ||
Page (page: $page, perPage: $perPage) { | ||
pageInfo { total currentPage lastPage hasNextPage perPage } | ||
media (id: $id, search: $search) { id title { romaji english native userPreferred } } | ||
} | ||
}`, { search: term, page: page, perPage: amount}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
{ | ||
"name": "anilist-node", | ||
"version": "1.0.0", | ||
"description": "", | ||
"description": "A lightweight Node.js wrapper for the AniList API", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Butterstroke", | ||
"author": { | ||
"name": "Yvain Hoekstra", | ||
"email": "[email protected]" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/butterstroke/Anilist-Node" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/butterstroke/Anilist-Node/issues" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"node-fetch": "^2.1.2" | ||
} | ||
} | ||
} |