### Install BooruSharp and BooruSharp.Others via NuGet Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Install the BooruSharp NuGet package to browse Booru websites, or BooruSharp.Others for additional non-booru sites like pixiv.net. ```powershell Install-Package BooruSharp ``` ```powershell Install-Package BooruSharp.Others ``` -------------------------------- ### Get search autocomplete results from Safebooru Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves search autocomplete suggestions from Safebooru for a given prefix and prints each suggestion name. ```Cs var booru = new BooruSharp.Booru.Safebooru(); var results = await booru.AutocompleteAsync("kasuga_"); Console.WriteLine(String.Join(Environment.NewLine, results.Select(x => "Autocomplete result:" + x.Name))); ``` -------------------------------- ### Get wiki entry from Konachan Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves a wiki entry from Konachan and prints its description, ID, creation date, and last update date. ```Cs var booru = new BooruSharp.Booru.Konachan(); var result = await booru.GetWikiAsync("loli"); Console.WriteLine("Description: " + result.Body + Environment.NewLine + "ID: " + result.ID + Environment.NewLine + "Created at: " + result.Creation.ToString("dd/MM/yy HH:mm:ss") + Environment.NewLine + "Last update at: " + result.LastUpdate.ToString("dd/MM/yy HH:mm:ss")); ``` -------------------------------- ### GetImage method signature Source: https://github.com/xwilarg/boorusharp/wiki/Post-functions Searches for an image by ID and tags. For example, ID 2 with tag 'loli' returns the 3rd image found with that tag. ```C# Task GetImage(int id, params string[] tagsArg); ``` -------------------------------- ### Get tag from Safebooru Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves a tag by name from Safebooru and prints its type and ID. ```Cs var booru = new BooruSharp.Booru.Safebooru(); var result = await booru.GetTagAsync("cirno"); Console.WriteLine("Tag type: " + result.Type + Environment.NewLine + "ID: " + result.ID); ``` -------------------------------- ### Get random image from Pixiv and save to file Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves a random post from Pixiv after logging in with a refresh token, then saves the image to a file. Requires a valid refresh token from the linked documentation. ```Cs var booru = new BooruSharp.Others.Pixiv(); await booru.LoginAsync("[refreshToken]"); // See https://github.com/Xwilarg/BooruSharp/#pixiv var result = await booru.GetRandomPostAsync("シンボリルドルフ(ウマ娘)"); File.WriteAllBytes($"output{Path.GetExtension(result.FileUrl.AbsolutePath)}", await b.ImageToByteArrayAsync(result)); // Save the image in a file ``` -------------------------------- ### Get random image from Gelbooru Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves a random post from Gelbooru with optional tags and prints the preview URL, file URL, safety rating, and tags. ```Cs var booru = new BooruSharp.Booru.Gelbooru(); var result = await booru.GetRandomPostAsync("hibiki_(kantai_collection)", "school_swimsuit"); Console.WriteLine("Image preview URL: " + result.PreviewUrl.AbsoluteUri + Environment.NewLine + "Image URL: " + result.FileUrl.AbsoluteUri + Environment.NewLine + "Image is safe: " + (result.Rating == BooruSharp.Search.Post.Rating.Safe) + Environment.NewLine + "Tags on the image: " + String.Join(", ", result.Tags)); ``` -------------------------------- ### Get comments from Lolibooru Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves comments for a post ID from Lolibooru and prints each comment's author, creation date, and body. ```Cs var booru = new BooruSharp.Booru.Lolibooru(); var results = await booru.GetCommentAsync(134097); Console.WriteLine(String.Join(Environment.NewLine, results.Select(delegate (BooruSharp.Search.Comment.SearchResult res) { return ("Author: " + res.AuthorName + ", the " + res.Creation.ToString("dd/MM/yy HH:mm:ss") + " - " + res.Body); }))); ``` -------------------------------- ### Get multiple random images from Sankaku Complex Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves 10 random posts from Sankaku Complex with specified tags and prints each image's file URL. ```Cs var booru = new BooruSharp.Booru.SankakuComplex(); var results = await booru.GetRandomPostsAsync(10, "ifrit_(arknights)", "silence_(arknights)"); Console.WriteLine(string.Join(Environment.NewLine, results.Select(x => "Random Image: " + x.FileUrl))); ``` -------------------------------- ### Get related tags from Yandere Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves related tags for a given tag from Yandere and prints each tag name with its count. ```Cs var booru = new BooruSharp.Booru.Yandere(); var results = await booru.GetRelatedAsync("see_through"); Console.WriteLine(String.Join(Environment.NewLine, results.Select(delegate (BooruSharp.Search.Related.SearchResult res) { return ("Name: " + res.Name +" (" + res.Count + ")"); }))); ``` -------------------------------- ### Get character tags containing a string from Yandere Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Retrieves all tags containing a string from Yandere and filters to only character tags, printing their names. ```Cs var yandere = new BooruSharp.Booru.Yandere(); var results = await yandere.GetTagsAsync("tsukiko"); Console.WriteLine(String.Join(Environment.NewLine, results.Where(delegate (BooruSharp.Search.Tag.SearchResult res) { return (res.Type == BooruSharp.Search.Tag.TagType.Character); }) .Select(delegate (BooruSharp.Search.Tag.SearchResult res) { return (res.Name); }))); ``` -------------------------------- ### Instantiate CustomBooru for Gelbooru Source: https://github.com/xwilarg/boorusharp/wiki/Custom-Booru Creates a custom Booru instance for gelbooru.com with UrlFormat.indexPhp, a maximum of 20000 images, and options disabling wiki and related APIs. The first argument is the domain, the second is the API URL format, the third is the maximum image count (null if none), and the remaining arguments are BooruOptions flags. ```C# new BooruSharp.Booru.Custom.CustomBooru("gelbooru.com", UrlFormat.indexPhp, 20000, BooruOptions.noWiki, BooruOptions.noRelated); ``` -------------------------------- ### Instantiate all Booru classes Source: https://github.com/xwilarg/boorusharp/wiki/Creating-a-new-Booru Shows how to create instances of each Booru class in the BooruSharp library. Each line creates a new instance of a specific Booru, such as E621, Gelbooru, Konachan, etc. The list includes 13 Booru classes, despite the text mentioning 9. ```C# new BooruSharp.Booru.E621(); new BooruSharp.Booru.Gelbooru(); new BooruSharp.Booru.Konachan(); new BooruSharp.Booru.Lolibooru(); new BooruSharp.Booru.Rule34(); new BooruSharp.Booru.Safebooru(); new BooruSharp.Booru.Yandere(); new BooruSharp.Booru.E926(); new BooruSharp.Booru.Sakugabooru(); new BooruSharp.Booru.Xbooru(); new BooruSharp.Booru.Furrybooru(); new BooruSharp.Booru.Realbooru(); new BooruSharp.Booru.DanbooruDonmai(); ``` -------------------------------- ### Check Booru wiki API support with HaveWikiAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns whether the Booru supports the wiki API. Use this to conditionally enable wiki features. ```Cs bool HaveWikiAPI(); ``` -------------------------------- ### Post Functions Source: https://github.com/xwilarg/boorusharp/wiki/Post-functions Methods to interact with posts from Booru websites, including counting images, retrieving limits, searching by ID, and fetching random images. ```APIDOC ## GetNbImage ### Description Returns the number of images available on the Booru given some tags. If no tags are given, it returns the total number of images available. ### Method Task GetNbImage(params string[] tags) ### Parameters - **tags** (string[]) - Optional - Tags to filter the image count. ### Returns - **Task** - The number of images matching the tags, or total if no tags provided. ``` ```APIDOC ## GetLimit ### Description Returns the limit of images available through the API. A null value means no limit. ### Method int? GetLimit() ### Returns - **int?** - The limit of images, or null if no limit. ``` ```APIDOC ## GetImage ### Description Searches for an image given an ID and some tags. For example, an ID of 2 with a tag of "loli" will give the 3rd image found with this tag. ### Method Task GetImage(int id, params string[] tagsArg) ### Parameters - **id** (int) - Required - The index of the image to retrieve (0-based). - **tagsArg** (string[]) - Optional - Tags to filter the search. ### Returns - **Task** - The search result containing image details. ``` ```APIDOC ## GetRandomImage ### Description Searches for a random image with the given tags. If no tags are provided, the image will be totally random. ### Method Task GetRandomImage(params string[] tags) ### Parameters - **tags** (string[]) - Optional - Tags to filter the random image selection. ### Returns - **Task** - The search result containing a random image's details. ``` -------------------------------- ### Add favorite on Safebooru Source: https://github.com/xwilarg/boorusharp/blob/master/README.md Adds a post to favorites on Safebooru after setting authentication with user ID and password hash. Requires valid credentials from the linked documentation. ```Cs var booru = new BooruSharp.Booru.Safebooru(); booru.SetBooruAuth(new BooruSharp.Booru.BooruAuth("yourUserId", "yourPasswordHash")); // See https://github.com/Xwilarg/BooruSharp/#booru await booru.AddFavoriteAsync(1759793); ``` -------------------------------- ### GetTags(string name) Source: https://github.com/xwilarg/boorusharp/wiki/Tag-Functions Returns all tags similar to the given name. On some Booru websites, it may only return the tag with the exact name. ```APIDOC ## GetTags(string name) ### Description Returns all tags similar to the given name. On some Booru websites, it may only return the tag with the exact name. ### Method GetTags ### Parameters - **name** (string) - Required - The name of the tag to search for. ### Returns Task - A task representing the asynchronous operation, containing an array of tag information. ### Example ```cs Task results = GetTags("example"); ``` ``` -------------------------------- ### GetWiki Source: https://github.com/xwilarg/boorusharp/wiki/Wiki-functions Retrieves the wiki entry (description) for a given tag. Returns a SearchResult containing the tag's ID, title, creation and update dates, and body text. ```APIDOC ## GetWiki ### Description Returns the wiki entry (description) for a specified tag. ### Method Task GetWiki(string query) ### Parameters - **query** (string) - Required - The tag name to look up. ### Returns - **Search.Wiki.SearchResult** - A structure containing: - **id** (uint) - ID of the tag - **title** (string) - Name of the tag - **creation** (DateTime) - Creation date of the wiki entry - **lastUpdate** (DateTime) - Last update of the wiki entry - **body** (string) - Description of the tag ### Example ```cs Task result = GetWiki("tag_name"); ``` ``` -------------------------------- ### BooruAuth constructor Source: https://github.com/xwilarg/boorusharp/wiki/Optional-Authentification-(E621-E926) Creates a BooruAuth instance with a login and password hash (API key). The passwordHash is obtained from https://e621.net/user/api_key while logged in. ```C# public BooruAuth(string login, string passwordHash); ``` -------------------------------- ### GetLimit method signature Source: https://github.com/xwilarg/boorusharp/wiki/Post-functions Returns a nullable int representing the API limit for images. Null means no limit. ```C# int? GetLimit(); ``` -------------------------------- ### GetTags by name Source: https://github.com/xwilarg/boorusharp/wiki/Tag-Functions Returns all tags similar to the given name. On some Booru sites, it may only return the tag with the exact name. ```C# Task GetTags(string name); ``` -------------------------------- ### GetRandomImage method signature Source: https://github.com/xwilarg/boorusharp/wiki/Post-functions Searches for a random image with the given tags. If no tags are provided, the image is totally random. ```C# Task GetRandomImage(params string[] tags); ``` -------------------------------- ### GetTag(string name) Source: https://github.com/xwilarg/boorusharp/wiki/Tag-Functions Returns information about a tag given its name. ```APIDOC ## GetTag(string name) ### Description Returns information about a tag given its name. ### Method GetTag ### Parameters - **name** (string) - Required - The name of the tag to retrieve. ### Returns Task - A task representing the asynchronous operation, containing the tag information. ### Example ```cs Task result = GetTag("example_tag"); ``` ``` -------------------------------- ### Check Booru availability with CheckAvailability Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns whether the Booru is currently available. Throws a System.HttpRequestException if it is not. ```Cs void CheckAvailability() ``` -------------------------------- ### CheckAvailability Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Checks if the Booru is currently available. Throws a System.HttpRequestException if it is not. ```APIDOC ## CheckAvailability ### Description Checks if the Booru is currently available. Throws a System.HttpRequestException if it is not. ### Method CheckAvailability ### Signature ```cs void CheckAvailability() ``` ### Exceptions - **System.HttpRequestException** - Thrown if the Booru is not available. ``` -------------------------------- ### GetNbImage method signature Source: https://github.com/xwilarg/boorusharp/wiki/Post-functions Returns the number of images available on the Booru given tags. If no tags are provided, returns the total number of images. ```C# Task GetNbImage(params string[] tags); ``` -------------------------------- ### Check Booru comment API support with HaveCommentAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns whether the Booru supports the comment API. Use this to conditionally enable comment features. ```Cs bool HaveCommentAPI(); ``` -------------------------------- ### GetTag(int id) Source: https://github.com/xwilarg/boorusharp/wiki/Tag-Functions Returns information about a tag given its ID. Note that searching by ID is not available for all Booru websites. ```APIDOC ## GetTag(int id) ### Description Returns information about a tag given its ID. Note that searching by ID is not available for all Booru websites. ### Method GetTag ### Parameters - **id** (int) - Required - The ID of the tag to retrieve. ### Returns Task - A task representing the asynchronous operation, containing the tag information. ### Example ```cs Task result = GetTag(12345); ``` ``` -------------------------------- ### GetTag by name or ID Source: https://github.com/xwilarg/boorusharp/wiki/Tag-Functions Returns information about a tag given its name or ID. Searching by ID may not be available for all Booru sites. ```C# Task GetTag(string name); Task GetTag(int id); ``` -------------------------------- ### HaveWikiAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns a boolean indicating whether the Booru has access to the wiki API. ```APIDOC ## HaveWikiAPI ### Description Returns a boolean indicating whether the Booru has access to the wiki API. ### Method HaveWikiAPI ### Signature ```cs bool HaveWikiAPI(); ``` ### Returns - **bool** - True if the Booru has access to the wiki API, otherwise false. ``` -------------------------------- ### GetComment method signature Source: https://github.com/xwilarg/boorusharp/wiki/Comment-functions Returns an array of comments for a given post ID. If there are no comments, the array will be empty. ```C# Task GetComment(int postId); ``` -------------------------------- ### Check Booru tag-by-id API support with HaveTagByIdAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns whether the Booru can search tags by id. Use this to conditionally enable tag-by-id search. ```Cs bool HaveTagByIdAPI(); ``` -------------------------------- ### GetLastComment method signature Source: https://github.com/xwilarg/boorusharp/wiki/Comment-functions Returns an array of the last comments published on the Booru. ```C# Task GetLastComment(); ``` -------------------------------- ### GetRelated method signature Source: https://github.com/xwilarg/boorusharp/wiki/Related-functions This snippet shows the method signature for retrieving an array of related tags from a Booru website. It returns a Task containing an array of SearchResult objects, where the first element is the original tag. Not all Booru websites support this feature. The returned structure contains the tag name and the count of images associated with it. ```C# Task GetRelated(string tag); ``` -------------------------------- ### GetComment Source: https://github.com/xwilarg/boorusharp/wiki/Comment-functions Returns an array of comments for a given post ID. If there are no comments, the array will be empty. ```APIDOC ## GetComment ### Description Returns an array of comments for a given post ID. If there are no comments, the array will be empty. ### Method Task GetComment(int postId) ### Parameters - **postId** (int) - Required - The ID of the post to retrieve comments for. ### Returns - **Task** - An array of SearchResult objects representing the comments. ``` -------------------------------- ### Check Booru related API support with HaveRelatedAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns whether the Booru supports the tag related API. Use this to conditionally enable related-tag features. ```Cs bool HaveRelatedAPI(); ``` -------------------------------- ### GetLastComment Source: https://github.com/xwilarg/boorusharp/wiki/Comment-functions Returns an array of the last comments published on the Booru. ```APIDOC ## GetLastComment ### Description Returns an array of the last comments published on the Booru. ### Method Task GetLastComment() ### Parameters None. ### Returns - **Task** - An array of SearchResult objects representing the latest comments. ``` -------------------------------- ### HaveCommentAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns a boolean indicating whether the Booru has access to the comment API. ```APIDOC ## HaveCommentAPI ### Description Returns a boolean indicating whether the Booru has access to the comment API. ### Method HaveCommentAPI ### Signature ```cs bool HaveCommentAPI(); ``` ### Returns - **bool** - True if the Booru has access to the comment API, otherwise false. ``` -------------------------------- ### HaveTagByIdAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns a boolean indicating whether the Booru can search tags by id. ```APIDOC ## HaveTagByIdAPI ### Description Returns a boolean indicating whether the Booru can search tags by id. ### Method HaveTagByIdAPI ### Signature ```cs bool HaveTagByIdAPI(); ``` ### Returns - **bool** - True if the Booru can search tags by id, otherwise false. ``` -------------------------------- ### SearchResult Structure Source: https://github.com/xwilarg/boorusharp/wiki/Comment-functions Structure containing comment data returned by the comment functions. ```APIDOC ## SearchResult Structure ### Description Represents a comment with its associated data. ### Fields - **commentId** (uint) - The ID of the comment. - **postId** (uint) - The ID of the post the comment is related to. - **authorId** (uint) - The ID of the author of the comment. - **creation** (DateTime) - The date when the comment was created. - **authorName** (string) - The name of the author of the comment. Will be "Anonymous" if the author is anonymous. - **body** (string) - The comment text. ``` -------------------------------- ### SearchResult Structure Source: https://github.com/xwilarg/boorusharp/wiki/Tag-Functions Structure containing data about a tag returned by GetTag or GetTags. ```APIDOC ## SearchResult Structure ### Description BooruSharp.Tag.SearchResult is a structure containing the following data: ### Fields - **id** (uint) - The ID of the tag. - **name** (string) - The name of the tag. - **type** (TagType) - The type of the tag (Trivia, Artist, Copyright, Character or Metadata). - **count** (uint) - The number of images existing with this tag. ``` -------------------------------- ### GetRelated Source: https://github.com/xwilarg/boorusharp/wiki/Related-functions Returns an array of tags related to the given tag. The first element of the array is the tag itself. The method is asynchronous and returns a Task of an array of SearchResult structures. ```APIDOC ## GetRelated ### Description Returns an array of tags related to the given tag. The first element of the array is the tag itself. ### Method Task GetRelated(string tag) ### Parameters - **tag** (string) - Required - The tag for which related tags are requested. ### Return Value - **Task** - An array of SearchResult structures, where the first element is the given tag. ### SearchResult Structure - **name** (string) - Name of the tag. - **count** (uint) - Number of images existing with this tag. ### Remarks This feature is not available for all Booru websites. ``` -------------------------------- ### HaveRelatedAPI Source: https://github.com/xwilarg/boorusharp/wiki/General-functions Returns a boolean indicating whether the Booru has access to the tag related API. ```APIDOC ## HaveRelatedAPI ### Description Returns a boolean indicating whether the Booru has access to the tag related API. ### Method HaveRelatedAPI ### Signature ```cs bool HaveRelatedAPI(); ``` ### Returns - **bool** - True if the Booru has access to the tag related API, otherwise false. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.