API~API(options)

Class used for interaction with nHentai API.

new API(options)

Applies provided options on top of defaults.

Parameters:
Name Type Description
options nHentaiOptions

Options to apply.

Members

private APIPath :APIPath

API path class

net :https|http

Get http(s) module depending on options.ssl.

Methods

private getAPIArgs(hostType, api) → {APIArgs}

Get API arguments. This is internal method.

Parameters:
Name Type Description
hostType string

Host type.

api string

Endpoint type.

Returns:
APIArgs -

API arguments.

async getBook(bookID) → {Promise.<Book>}

Get book by id.

Parameters:
Name Type Description
bookID number

Book ID.

Returns:
Promise.<Book> -

Book instance.

getImageURL(image) → {string}

Get image URL.

Parameters:
Name Type Description
image Image

Image.

Returns:
string -

Image URL.

getThumbURL(image) → {string}

Get image thumbnail URL.

Parameters:
Name Type Description
image Image

Image.

Returns:
string -

Image thumbnail URL.

request(options) → {Promise.<object>}

JSON get request.

Parameters:
Name Type Description
options object

HTTP(S) request options.

Properties
Name Type Description
host string

Host.

path string

Path.

Returns:
Promise.<object> -

Parsed JSON.

Search by query.

Parameters:
Name Type Attributes Default Description
query string

Query.

page number <optional>
1

Page ID.

Returns:
Promise.<Search> -

Search instance.

async searchAlike(book) → {Promise.<Search>}

Search related books.

Parameters:
Name Type Description
book number | Book

Book instance or Book ID.

Returns:
Promise.<Search> -

Search instance.

async searchTagged(tag, pageopt) → {Promise.<Search>}

Search by tag id.

Parameters:
Name Type Attributes Default Description
tag number | Tag

Tag or Tag ID.

page number <optional>
1

Page ID.

Returns:
Promise.<Search> -

Search instance.