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 hostTypestring Host type.
apistring Endpoint type.
Returns:
APIArgs -API arguments.
-
async getBook(bookID) → {Promise.<Book>}
-
Get book by id.
Parameters:
Name Type Description bookIDnumber Book ID.
Returns:
Promise.<Book> -Book instance.
-
getImageURL(image) → {string}
-
Get image URL.
Parameters:
Name Type Description imageImage Image.
Returns:
string -Image URL.
-
getThumbURL(image) → {string}
-
Get image thumbnail URL.
Parameters:
Name Type Description imageImage Image.
Returns:
string -Image thumbnail URL.
-
request(options) → {Promise.<object>}
-
JSON get request.
Parameters:
Name Type Description optionsobject HTTP(S) request options.
Properties
Name Type Description hoststring Host.
pathstring Path.
Returns:
Promise.<object> -Parsed JSON.
-
async search(query, pageopt) → {Promise.<Search>}
-
Search by query.
Parameters:
Name Type Attributes Default Description querystring Query.
pagenumber <optional>
1 Page ID.
Returns:
Promise.<Search> -Search instance.
-
async searchAlike(book) → {Promise.<Search>}
-
Search related books.
Parameters:
Name Type Description booknumber | 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 tagnumber | Tag Tag or Tag ID.
pagenumber <optional>
1 Page ID.
Returns:
Promise.<Search> -Search instance.