shentai
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.7 • Public • Published
    sHentai

    sHentai

    Discord Support License NPM downloads NPM version

    Simple and User-Friendly API for nHentai.

    Recommended for REST API, Bots, Sites

    Table of content:

    Installation

    $ npm install shentai

    Usage

    // in async function
    const nHentai = require('shentai')
    const sHentai = new nHentai
    
    // Get a Random Doujin
    await sHentai.getRandom().then(doujin => console.log(doujin))
    
    // Get a indicated Doujin
    await sHentai.getDoujin(1).then(doujin => console.log(doujin))
    
    // Searching
    await sHentai.search('dev').then(search => console.log(search.results))
    
    // Next Page
    const search = await sHentai.search('dev')
    const nextPage = await search.next()
    console.log(nextPage.results)

    Methods

    getPopular()

    Returns the not full object of a doujins.

    Usage example:

    // in async function
    const doujins = await sHentai.getPopular()
    console.log(doujins)
    Returns: Promise<search model class>

    getNew()

    Returns the not full object of a doujins.

    Usage example:

    // in async function
    const doujins = await sHentai.getNew()
    console.log(doujins)
    Returns: Promise<search model class>

    getDoujin()

    Param Type Description
    [id] string/number ID of Doujin

    Usage example:

    // in async function
    const doujin = await sHentai.getDoujin(0)
    console.log(doujin)
    Returns: Promise<Doujin model object>

    getRandom()

    Usage example:

    // in async function
    const doujin = await sHentai.getRandom()
    console.log(doujin)
    Returns: Promise<Doujin model object>

    byAuthor()

    Returns the not full object of a doujins.

    Param Type Description
    text string Text for entering search input on a site

    Usage example:

    // in async function
    const doujins = await sHentai.getPopular()
    console.log(doujins)
    Returns: Promise<search model class>

    search()

    Returns the not full object of a doujins.

    Param Type Description
    text string Text for entering search input on a site

    Usage example:

    // in async function
    const search = await sHentai.search('dev')
    const doujin = await sHentai.getDoujin(search.results[0].id)
    console.log(doujin)
    Returns: Promise<search model class>

    Data models

    Doujin

    Doujin data models is a object.
    {
      id: String, // ID of Doujin
      author: String, // Author name of Doujin
      titles: {
        english: String, // English adaptation of the title
        original: String, //Original name of the title
      },
      pages: Array<String>, // Links of Images of Doujin
      tags: Array<String>, // Tags of Doujin
      cover: String // Link of Cover of Doujin
    }

    SearchResult Class

    {
        results: Object[], // Search results on a site
        allDoujinsCount: Number, // Amount of all Doujins, which you can find
        lastPage: Number, // Number of All Pages from Search
        currentPage: Number, // Number of Current Page of Search
        next: Promise<SearchResult>, // Returns this class with new results of search next page
        prev: Promise<SearchResult>, // Returns this class with new results of search previous page
        first: Promise<SearchResult>, // Returns this class with new results of search first page
        last: Promise<SearchResult>, // Returns this class with new results of search last page
        getPage: Promise<SearchResult>, // Returns this class with new results of search indicated page
    }

    Search Result

    Search data models is a array of objects.
    [
      {
        id: String, // ID of Doujin
        titles: Object, // english property every time(for user-friendly with fullObject's condition), title of the doujin
        cover: String //url of the cover image
      },
    ]

    Catching Errors without .catch()

    In a Node.JS 15.x, reject use a strict mode. So, when Promise returns a reject, your app crashes.
    So, my library is user-friendly, and i don't want crash your app, if some wrong. So, how you can catch a errors?

    For Example:

    // in async function
    let doujin = await sHentai.getDoujin(0)
    if (doujin.status) return console.error(doujin.message);

    And, your app don't be crashes :)

    Support

    Discord Server


    License

    UNLICENSED

    Copyright © Mikun Hatsune

    Install

    npm i shentai

    DownloadsWeekly Downloads

    274

    Version

    2.0.7

    License

    UNLICENSED

    Unpacked Size

    29.8 kB

    Total Files

    16

    Last publish

    Collaborators

    • mikun_hatsune