A lightweight, easy-to-use synchronous e621 / e926 API wrapper written natively in Haxe.
- Install the library
Haxelib:
haxelib install monosodiumGit:
haxelib git monosodium https://github.com/hackx2/monosodium.git- Adding the library to your project
HXML :
-lib monosodiumLime/OpenFL :
<haxelib name="monosodium"/>final api:Monosodium = new monosodium.Monosodium(); // Create a new wrapper instance
api.mirror(monosodium.Mirror.E926); // Change the mirror target (E926 / E621)
api.verbose = true; // Enable verbose mode (optional)
api.authorize('USERNAME', 'TOKEN'); // authorization
// Get a post using an id:
api.posts.get(
12345, // Post id
post -> trace('Post #${post.id} has rating ${post.rating}'), // success callback by tracing "Post #12345 has rating s"
error -> trace(error) // error callback
);
// Get a random post:
api.posts.random(
["gay", "-female"], // tags
post -> trace(post.file_url), // success callback by tracing the file url
error -> trace(error) // error callback
);For more examples, please refer to Main
