A simple client for using the API of Gelbooru's based imageboards.
- Implements all the endpoint of the Gelbooru API
- Doesn't use any scrapping method
- Use Dart's native
http
package for making requests allowing for using more advanced implementation on the fly.
Run the following command:
# the http package is required because we use ClientException from it
$ dart pub add gelbooru http
import 'dart:io';
import 'package:gelbooru/gelbooru.dart';
import 'package:http/http.dart';
/// Get last 10 posts from Gelbooru
void main() async {
final client = GelbooruClient.gelbooru(
apiKey: 'your_api_key',
userId: 'your_user_id',
userAgent: 'your_user_agent');
List<Post> posts;
try {
posts = await client.posts.index(limit: 10);
/// Exception that happens when the client can't connect to the server
} on ClientException catch (cex) {
print(cex.message);
exit(0);
/// Exception that happens when the server returns an error
} on GelbooruException catch (gex) {
print(gex.message);
exit(0);
}
for (Post post in posts) {
print('${post.fileUrl}');
}
}
- The package isn't conceived to actually detect if the imageboard is Gelbooru based.
This project is written WITHOUT any AI assistance. If you fork this project and use AI please remove this section.