new Bangumi(optionsopt)
Represents the Bangumi API client.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
<optional> |
Configuration options.
|
Example
const Bangumi = require('bangumi');
const bgm = new Bangumi({
access_token: "123456"
});
Methods
auth(params, callbackopt) → {Promise}
A POST method that login user with username and password, and returns auth string
- Deprecated:
- since version 1.0.0, newer version of api will use oauth.
- Source:
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
Parameters for the request
|
||||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
createCollection(subject_id, paramsopt, callbackopt) → {Promise}
A POST method that updates user's status on specific subject by subject id
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
subject_id |
number
|
ID of the target subject | |||||||||||||||||||||||||||||||
params |
object
|
<optional> |
Optional parameters for the request
|
||||||||||||||||||||||||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.createCollection(211567, {status: 'do', rating: 10});
fetchCalendar(callbackopt) → {Promise|undefined}
A GET method that gets current weekly shows' seclude
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
|undefined
- Returns a promise if no callback is provided
fetchCollection(subject_id, paramsopt, callbackopt) → {Promise}
A GET method that get current user's collection details on specific subject by subject id
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
subject_id |
number
|
ID of the target subject | |||||||||
params |
object
|
<optional> |
Optional parameters for the request
|
||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.fetchCollection(1);
fetchEps(subject_id, callbackopt) → {Promise}
A GET method that gets a list of episodes of a subject by subject id
- Deprecated:
- use fetchSubjectEps
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
subject_id |
number
|
ID of the target subject | |
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
fetchProgress(username, paramsopt, callbackopt) → {Promise}
A GET method that get lists of episodes that user already watched, sorted by subject id
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
username |
string
|
number
|
Username or UID of the target user | |||||||||||||
params |
object
|
<optional> |
Optional parameters for the request
|
||||||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.fetchProgress(1, {subject_id:899}).then(console.log);
fetchSubject(subject_id, paramsopt, callbackopt) → {Promise.<Subject>}
A GET method that gets details of a subject by id
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
subject_id |
number
|
ID of the target subject | |||||||||
params |
Object
|
<optional> |
Optional parameters for the request
|
||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise.<Subject>
- Returns a promise that resolves to the subject details
fetchSubjectEps(subject_id, callbackopt) → {Promise}
A GET method that gets a list of episodes of a subject by subject id
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
subject_id |
number
|
ID of the target subject | |
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.fetchSubjectEps(211567);
fetchUser(username, callbackopt) → {Promise|undefined}
A GET method that gets target user's profile
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
username |
string
|
number
|
Username or UID of the target user | |
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
|undefined
- Returns a promise if no callback is provided
fetchUserCollection(username, params, callbackopt) → {Promise}
A GET method that gets details of user's collection by user id
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
username |
string
|
number
|
Username or UID of the target user | |||||||||||||||||
params |
object
|
Parameters for the request
|
|||||||||||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.fetchUserCollection(1, {cat:'all_watching', responseGroup: 'small'}).then(console.log)
fetchUserCollections(username, subject_type, paramsopt, callbackopt) → {Promise}
A GET method that gets overview of user's collection by username and subject type
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
username |
string
|
number
|
Username or UID of the target user | |||||||||
subject_type |
string
|
Type of subject | |||||||||
params |
object
|
<optional> |
Optional parameters for the request
|
||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.fetchUserCollections('sai', 'real', {max_results: 1}).then(console.log).catch(console.error)
fetchUserCollectionsStatus(username, paramsopt, callbackopt) → {Promise}
A GET method that gets overview of user's collection statics by username
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
username |
string
|
number
|
Username or UID of the target user | |
params |
object
|
<optional> |
Optional parameters for the request |
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.fetchUserCollectionsStatus('sai').then(console.log).catch(console.error)
get(url, params, callbackopt) → {Promise|undefined}
A general GET request method for Bangumi API
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string
|
Base GET request path | |
params |
object
|
Parameters used for GET query string | |
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
|undefined
- Returns a promise if no callback is provided, otherwise undefined
post(url, params, callbackopt) → {Promise|undefined}
A general POST request method for Bangumi API
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string
|
Base POST request path | |
params |
object
|
Parameters used for POST body | |
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
|undefined
- Returns a promise if no callback is provided
search(keywords, paramsopt, callbackopt) → {Promise}
A GET method that searches and returns a list of subjects by keywords
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
keywords |
string
|
Query string for search | |||||||||||||||||||||
params |
object
|
<optional> |
Optional parameters for the request
|
||||||||||||||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.search('天元突破');
setAccessToken(access_token)
Updates the access token in case it's refreshed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
access_token |
string
|
The new access token. |
Example
bgm.setAccessToken('123456');
setPromiseProvider(provider)
Sets a custom promise provider. By default, the Node.js ES6 promise provider is used.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
provider |
function
|
Custom promise provider. |
Example
// Use Bluebird as the promise provider, so you can use features like .finally()
bgm.setPromiseProvider(require('bluebird'));
updateEpStatus(ep_id, status, paramsopt, callbackopt) → {Promise}
A POST method that updates user's status on specific episode by episode id
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ep_id |
number
|
ID of the target episode | |||||||||
status |
string
|
Accepts [watched|queue|drop|remove] | |||||||||
params |
object
|
<optional> |
Optional parameters for the request
|
||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.updateEpStatus(7036,'drop');
updateWatchedEps(subject_id, params, callbackopt) → {Promise}
A POST method that marks episode 1 to target number as watched
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
subject_id |
number
|
ID of the target subject | |||||||||||||
params |
object
|
Parameters for the request
|
|||||||||||||
callback |
function
|
<optional> |
Optional callback function |
Returns:
- Type:
-
Promise
- Returns a promise if no callback is provided
Example
bgm.updateWatchedEps(18462, {watched_eps: 10, watched_vols: 2});