A full nHentai API implementation for .NET
⚠️ If nHentai changes their API format, please create an issue to let me know!
A User-Agent is required to use this API. The client will throw an error if none is provided. You can get your User-Agent by:
Example:
var client = new NHentaiClient("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
If nHentai implements CSRF protection, you can get the token by:
Important: The CSRF token must be obtained from the same IP address and User-Agent that will be used with the API. Using a token from a different IP or User-Agent will result in authentication failures.
var cookies = new Dictionary<string, string>
{
{"csrf_token", "your-token-here"}
};
var client = new NHentaiClient("your-user-agent", cookies);
-
prefix (exclusion)// Initialize client with User-Agent
var client = new NHentaiClient("your-user-agent-string");
// Search with filters
var result = await client.GetSearchPageListAsync("school swimsuit full color -loli", 2);
// Browse homepage
var homeResults = await client.GetHomePageListAsync(1);
var client = new NHentaiClient("your-user-agent-string");
// Get book by ID
var book = await client.GetBookAsync(123);
// Get related books
var related = await client.GetBookRecommendAsync(123);
var book = await client.GetBookAsync(123);
// Get full page image
byte[] picture = await client.GetPictureAsync(book, 1);
// Get cover image
byte[] cover = await client.GetBigCoverPictureAsync(book);
// Get thumbnails
byte[] thumbnail = await client.GetThumbPictureAsync(book, 1);
byte[] coverThumb = await client.GetBookThumbPictureAsync(book);
This project is licensed under the MIT License - see the LICENSE file for details.