https://github.com/pancaketas/nekos-best.c
A simple, lightweight c wrapper for nekos.best API
https://github.com/pancaketas/nekos-best.c
Last synced: 4 months ago
JSON representation
A simple, lightweight c wrapper for nekos.best API
- Host: GitHub
- URL: https://github.com/pancaketas/nekos-best.c
- Owner: PancakeTAS
- License: mit
- Archived: true
- Created: 2024-02-19T22:16:43.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2024-03-27T18:14:09.000Z (about 1 year ago)
- Last Synced: 2024-12-20T07:45:23.789Z (6 months ago)
- Language: C
- Homepage: https://pancaketas.github.io/nekos-best.c/
- Size: 103 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# nekos-best.c
A simple, lightweight c wrapper for [nekos.best](https://nekos.best/) API compliant with C99.Join the official Discord server [here](https://nekos.best/discord?ref=py).
## 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.```c
#define NEKOSBEST_IMPL
#include "nekosbest.h"
```## Documentation
Doxygen documentation is available [here](https://pancake.gay/nekos-best.c).
(Jump to [nekosbest.h](https://pancake.gay/nekos-best.c/nekosbest_8h.html))## Example
```c
#define NEKOSBEST_IMPL
#include#include
#includeint main() {
// manually create endpoint (use nekos_endpoints() to get all endpoints)
nekos_endpoint endpoint;
endpoint.name = "neko";
endpoint.format = NEKOS_PNG;// fetch image
nekos_result_list results;
nekos_category(&results, &endpoint, 1);// download first image
nekos_http_response http_response;
nekos_download(&http_response, results.responses[0].url);// save image to file
FILE *file = fopen("neko.png", "wb");
fwrite(http_response.text, 1, http_response.len, file);
fclose(file);// cleanup
nekos_free_results(&results, endpoint.format);
nekos_free_http_response(&http_response);
return EXIT_SUCCESS;
}
```
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/`.