@icebrick/nhget
v2.0.1
Published
A simple library to fetch data from nhentai.net.
Readme
nhget
A simple library to fetch data from nhentai.net.
Installation
# Install the package
npm install @icebrick/nhgetUsage
// CommonJS
const { nhget } = require('@icebrick/nhget');
// ES Module
import nhget from '@icebrick/nhget';
(async () => {
const nh = new nhget({
endpoint: 'https://nhentai.net/api/v2/galleries/',
imageEndpoint: 'https://i.nhentai.net/galleries/',
thumbnailEndpoint: 'https://t.nhentai.net/galleries/',
cachePath: './cache'
});
const data = await nh.get(518372);
console.log(data);
})();API
Class: nhget
Constructor: nhget(args?: { endpoint?: string, imageEndpoint?: string, thumbnailEndpoint?: string, cachePath?: string })
- args:
object(optional)- endpoint:
string(optional)- Default:
'https://nhentai.net/api/v2/galleries/' - The endpoint of the nhentai.net API.
- Default:
- imageEndpoint:
string(optional)- Default:
'https://i.nhentai.net/galleries/' - The endpoint for image URLs.
- Default:
- thumbnailEndpoint:
string(optional)- Default:
'https://t.nhentai.net/galleries/' - The endpoint for thumbnail image URLs.
- Default:
- cachePath:
string(optional)- The path to the cache directory. Cache supports both v1 and v2 API formats.
- endpoint:
Method: get(id: number): Promise<GalleryDatav2>
- id:
number- The ID of the doujinshi.
- Returns a
Promisethat resolves to aGalleryDatav2object. - The library supports both v1 and v2 API responses, but always returns v2 format.
Method: getPages(id: number): Promise<Array<string>>
- id:
number- The ID of the doujinshi.
- Returns a
Promisethat resolves to an array of image URLs.
Method: getPagesThumbnail(id: number): Promise<Array<string>>
- id:
number- The ID of the doujinshi.
- Returns a
Promisethat resolves to an array of thumbnail image URLs.
Method: getCover(id: number): Promise<string>
- id:
number- The ID of the doujinshi.
- Returns a
Promisethat resolves to the cover image URL.
Method: getCoverThumbnail(id: number): Promise<string>
- id:
number- The ID of the doujinshi.
- Returns a
Promisethat resolves to the thumbnail cover image URL.
License
This project is licensed under the MIT License - see the LICENSE file for details.
