A simple, lightweight c wrapper for nekos.best API compliant with C99.
Join the official Discord server here.
Requirements
- libcurl (tested with 8.6.0-3)
- cjson (tested with 1.7.17-1)
Installation
Copy the single header file to source include directory and include the header. Specify NEKOSBEST_IMPL
before including the header in the source file where you want to use the library.
#define NEKOSBEST_IMPL
This file contains structs and functions for interacting with the nekos.best API.
Documentation
Doxygen documentation is available here. (Jump to nekosbest.h)
Example
#define NEKOSBEST_IMPL
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *file = fopen("neko.png", "wb");
fwrite(http_response.
text, 1, http_response.
len, file);
fclose(file);
return EXIT_SUCCESS;
}
@ NEKOS_PNG
Indicates that the response image is a png and nekos_source_png should be used.
Definition nekosbest.h:38
nekos_status nekos_download(nekos_http_response *http_response, const char *url)
Download an image.
void nekos_free_http_response(const nekos_http_response *http_response)
Free an http response.
void nekos_free_results(const nekos_result_list *results)
Free a list of results.
nekos_status nekos_category(nekos_result_list *results, const nekos_endpoint *endpoint, int amount)
Get a list of images from a category.
Struct for an endpoint/category.
Definition nekosbest.h:43
char * name
[out] Name of the endpoint/category.
Definition nekosbest.h:44
nekos_format format
[out] Format of the endpoint/category.
Definition nekosbest.h:45
Struct for an http response.
Definition nekosbest.h:85
char * text
[out] Non-nullterminated text of the response.
Definition nekosbest.h:86
size_t len
[out] Length of the response text.
Definition nekosbest.h:87
Struct for a list of result images.
Definition nekosbest.h:77
nekos_result * responses
[out] Array of result images.
Definition nekosbest.h:78
char * url
[out] URL to the image.
Definition nekosbest.h:73
This example fetches an image from the 'neko' endpoint saves it to a file. Please note that this example does not handle errors.
For more examples, see tests/
.