e621 library

A client library for the API of imageboards using the e621 fork of gelbooru.

Features

  • Implements all the endpoints of the e621 API : e621 API
  • Use Dart's native http package for making requests alloowing for using more advanced implementation on the fly.

Getting started

Add the package to your project by running the following command:

# http is a required dependency since we rely on ClientException
dart pub add e621 http

Usage

// Simple example to collect last ten post and display link

import 'package:e621/e621.dart';
import 'package:http/http.dart';

Future<void> main() async {

  /// You should see the `http`[https://pub.dev/packages/http#choosing-an-implementation](https://pub.dev/packages/http#choosing-an-implementation) package documentation for using an adequate [Client] for your platform
  final E621Client client = E621Client(host: Uri.parse('https://e621.net'), login: 'username', apiKey: 'api_key', userAgent: 'MyApp/1.0 (by username on e621)');

  final List<Post> posts;

  try {

    /// limit is optional but 10 will get the last 10 posts
    posts = await client.posts.list(limit: 10);

    /// [ClientException] is found in the `http` package
    /// it will be throw in case something went wrong with the request AT the connection time
  } on ClientException catch (e) {
    print('Failed to get posts: $e');
    return;

    /// [E621Exception] is found in the `e621` package
    /// It will throw is something went wrong with the request AFTER the connection time
  } on E621Exception catch (e) {
    print('Failed to get posts: $e');
    return;
  }

  if (posts.isEmpty) {
    print('No posts found');
    return;
  }

  for (final post in posts) {
    print('Post: ${post.id} - ${post.file.url}');
  }

}

No AI project / AI free Project

This project is written WITHOUT any AI assistance. If you fork this project and use AI please remove this section.

Special Thanks

  • Dasa: Your honesty and the morale boost to actually start this project.

Classes

DataAccessObject<T extends Resource>
A data access object for the e621 API.
E621Client
A client for the e621 API.
FavoriteDataAccessObject
A data access object for favorites. Unlike others DAO this one returns Post and no Favorite
Flag
A Flag on a Post.
FlagDataAccessObject
A data access object for flags.
Note
A Note on a Post.
NoteDataAccessObject
Allow to interact with notes.
Pool
A Pool of Posts.
PoolDataAccessObject
A data access object for pools.
Post
A Post on the E621Client.host imageboard.
PostDataAccessObject
A data access object for posts.
Resource
A resource in the e621 API.
Tag
A Tag on a Post.
TagAlias
A TagAlias for a given Tag.
TagAliasDataAccessObject
A data access object for tag aliases.
TagDataAccessObject
A data access object for tags.
TagImplication
A TagImplication for a given Tag.
TagImplicationDataAccessObject
A data access object for tag implications.
Vote
A vote in the e621 API. Since Vote aren't really Resource id is always 0. They're created as resource to make it easier to work with them through VoteDataAccessObject.
VoteDataAccessObject
A data access object for votes.

Enums

PoolCategory
The category of a pool.
PoolOrder
Enum for pool order
PostRating
Represents the rating of a post.
TagAliasOrder
An enum for the order of tag aliases.
TagAliasStatus
Represents the status of a tag alias.
TagCategory
A TagCategory linked to Tag.
TagImplicationOrder
An enum for the order of tag Implications.
TagImplicationStatus
Represents the status of a tag Implication.
TagOrder
An enum to represent the order of the tags.

Exceptions / Errors

E621Exception
An exception thrown by the e621 API.