yippi package

yippi.AbstractYippi module

class yippi.AbstractYippi.AbstractYippi(project_name: str, version: str, creator: str)[source]

Bases: abc.ABC

An abstract class (abc) for all the Yippi’s client.

Generally you don’t really need to use this, except if you want to use different implementation for the client.

Parameters
  • project_name – Your project’s name where this library is going to be used.

  • version – You project’s version number.

  • creator – Your e621 username.

  • session – The HTTP client session object.

  • loop – The event loop to run on. This is only required on async client.

VALID_CATEGORY = ('series', 'collection')
VALID_ORDER = ('name', 'created_at', 'updated_at', 'post_count')
abstract flags(post_id: Optional[int] = None, creator_id: Optional[int] = None, creator_name: Optional[str] = None, limit: Optional[int] = None) Union[List[yippi.Classes.Flag], Awaitable[List[yippi.Classes.Flag]]][source]

Search for flags

Parameters
  • post_id – The ID of the flagged post.

  • creator_id – The user’s ID that created the flag.

  • creator_name – The user’s name that created the flag.

  • limit – Limits the amount of notes returned to the number specified.

Returns

list of Flag of the flags.

login(username: str, api_key: str) None[source]

Supply login credentials to client.

Parameters
  • username – Your e621 username.

  • api_key – Your API key. Find it under “Account” on e621.

abstract notes(body_matches: Optional[str] = None, post_id: Optional[int] = None, post_tags_match: Optional[Union[List, str]] = None, creator_name: Optional[str] = None, creator_id: Optional[int] = None, is_active: Optional[bool] = None, limit: Optional[int] = None) Union[List[yippi.Classes.Note], Awaitable[List[yippi.Classes.Note]]][source]

Search for notes.

Parameters
  • body_matches – The note’s body matches the given terms. Use a * in the search terms to search for raw strings.

  • post_id – The post where the note is located.

  • post_tags_match – The note’s post’s tags match the given terms. Meta-tags are not supported.

  • creator_name – The creator’s name. Exact match.

  • creator_id – The creator’s user id.

  • is_active – Can be True or False.

  • limit – Limits the amount of notes returned to the number specified.

Returns

list of Note of the notes.

abstract pool(pool_id: int) Union[yippi.Classes.Pool, Awaitable[yippi.Classes.Pool]][source]

Fetch for a pool.

Parameters

pool_id – The pool’s ID to look up.

Returns

Pool of the pool.

abstract pools(name_matches: Optional[str] = None, id_: Optional[Union[int, List[int]]] = None, description_matches: Optional[str] = None, creator_name: Optional[str] = None, creator_id: Optional[int] = None, is_active: Optional[bool] = None, is_deleted: Optional[bool] = None, category: Optional[str] = None, order: Optional[str] = None, limit: Optional[int] = None) Union[List[yippi.Classes.Pool], Awaitable[List[yippi.Classes.Pool]]][source]

Search for pools.

Parameters
  • name_matches – Search for pool names.

  • id_ – Search for a pool ID. Multiple IDs are fine. .. warning:: Take note of the underscore (_) mark!

  • description_matches – Search for pool descriptions.

  • creator_name – Search for pools based on creator name.

  • creator_id – Search for pools based on creator ID.

  • is_active – If the pool is active or hidden. (True/False)

  • is_deleted – If the pool is deleted. (True/False)

  • category – Can either be “series” or “collection”.

  • order – The order that pools should be returned, can be any of: name, created_at, updated_at, post_count. If not specified it orders by updated_at.

  • limit – The limit of how many pools should be retrieved.

Returns

list of Pool of the pools.

abstract post(post_id: int) Union[yippi.Classes.Post, Awaitable[yippi.Classes.Post]][source]

Fetch for a post.

Parameters

post_id – The post’s ID to look up.

Returns

Post of the posts.

abstract posts(tags: Optional[Union[List, str]] = None, limit: Optional[int] = None, page: Optional[Union[int, str]] = None) Union[List[yippi.Classes.Post], Awaitable[List[yippi.Classes.Post]]][source]

Search for posts.

Parameters
  • tags – The tags to search.

  • limit – Limits the amount of notes returned to the number specified.

  • page – The page that will be returned.

Returns

list of Post of the posts.

yippi.AsyncYippi module

class yippi.AsyncYippi.AsyncYippiClient(project_name: str, version: str, creator: str, loop=None, session: Optional[aiohttp.client.ClientSession] = None)[source]

Bases: yippi.AbstractYippi.AbstractYippi

async close() None[source]
async flags(post_id: Optional[int] = None, creator_id: Optional[int] = None, creator_name: Optional[str] = None, limit: Optional[int] = None) List[yippi.Classes.Flag][source]

Search for flags

Parameters
  • post_id – The ID of the flagged post.

  • creator_id – The user’s ID that created the flag.

  • creator_name – The user’s name that created the flag.

  • limit – Limits the amount of notes returned to the number specified.

Returns

list of Flag of the flags.

async notes(body_matches: Optional[str] = None, post_id: Optional[int] = None, post_tags_match: Optional[Union[List, str]] = None, creator_name: Optional[str] = None, creator_id: Optional[int] = None, is_active: Optional[bool] = None, limit: Optional[int] = None) List[yippi.Classes.Note][source]

Search for notes.

Parameters
  • body_matches – The note’s body matches the given terms. Use a * in the search terms to search for raw strings.

  • post_id – The post where the note is located.

  • post_tags_match – The note’s post’s tags match the given terms. Meta-tags are not supported.

  • creator_name – The creator’s name. Exact match.

  • creator_id – The creator’s user id.

  • is_active – Can be True or False.

  • limit – Limits the amount of notes returned to the number specified.

Returns

list of Note of the notes.

async pool(pool_id: int) yippi.Classes.Pool[source]

Fetch for a pool.

Parameters

pool_id – The pool’s ID to look up.

Returns

Pool of the pool.

async pools(name_matches: Optional[str] = None, id_: Optional[Union[int, List[int]]] = None, description_matches: Optional[str] = None, creator_name: Optional[str] = None, creator_id: Optional[int] = None, is_active: Optional[bool] = None, is_deleted: Optional[bool] = None, category: Optional[str] = None, order: Optional[str] = None, limit: Optional[int] = None) List[yippi.Classes.Pool][source]

Search for pools.

Parameters
  • name_matches – Search for pool names.

  • id_ – Search for a pool ID. Multiple IDs are fine. .. warning:: Take note of the underscore (_) mark!

  • description_matches – Search for pool descriptions.

  • creator_name – Search for pools based on creator name.

  • creator_id – Search for pools based on creator ID.

  • is_active – If the pool is active or hidden. (True/False)

  • is_deleted – If the pool is deleted. (True/False)

  • category – Can either be “series” or “collection”.

  • order – The order that pools should be returned, can be any of: name, created_at, updated_at, post_count. If not specified it orders by updated_at.

  • limit – The limit of how many pools should be retrieved.

Returns

list of Pool of the pools.

async post(post_id: int) yippi.Classes.Post[source]

Fetch for a post.

Parameters

post_id – The post’s ID to look up.

Returns

Post of the posts.

async posts(tags: Optional[Union[List, str]] = None, limit: Optional[int] = None, page: Optional[Union[int, str]] = None) List[yippi.Classes.Post][source]

Search for posts.

Parameters
  • tags – The tags to search.

  • limit – Limits the amount of notes returned to the number specified.

  • page – The page that will be returned.

Returns

list of Post of the posts.

yippi.YippiSync module

class yippi.YippiSync.YippiClient(project_name: str, version: str, creator: str, session: Optional[requests.sessions.Session] = None)[source]

Bases: yippi.AbstractYippi.AbstractYippi

flags(post_id: Optional[int] = None, creator_id: Optional[int] = None, creator_name: Optional[str] = None, limit: Optional[int] = None) List[yippi.Classes.Flag][source]

Search for flags

Parameters
  • post_id – The ID of the flagged post.

  • creator_id – The user’s ID that created the flag.

  • creator_name – The user’s name that created the flag.

  • limit – Limits the amount of notes returned to the number specified.

Returns

list of Flag of the flags.

notes(body_matches: Optional[str] = None, post_id: Optional[int] = None, post_tags_match: Optional[Union[List, str]] = None, creator_name: Optional[str] = None, creator_id: Optional[int] = None, is_active: Optional[bool] = None, limit: Optional[int] = None) List[yippi.Classes.Note][source]

Search for notes.

Parameters
  • body_matches – The note’s body matches the given terms. Use a * in the search terms to search for raw strings.

  • post_id – The post where the note is located.

  • post_tags_match – The note’s post’s tags match the given terms. Meta-tags are not supported.

  • creator_name – The creator’s name. Exact match.

  • creator_id – The creator’s user id.

  • is_active – Can be True or False.

  • limit – Limits the amount of notes returned to the number specified.

Returns

list of Note of the notes.

pool(pool_id: int) yippi.Classes.Pool[source]

Fetch for a pool.

Parameters

pool_id – The pool’s ID to look up.

Returns

Pool of the pool.

pools(name_matches: Optional[str] = None, id_: Optional[Union[int, List[int]]] = None, description_matches: Optional[str] = None, creator_name: Optional[str] = None, creator_id: Optional[int] = None, is_active: Optional[bool] = None, is_deleted: Optional[bool] = None, category: Optional[str] = None, order: Optional[str] = None, limit: Optional[int] = None) List[yippi.Classes.Pool][source]

Search for pools.

Parameters
  • name_matches – Search for pool names.

  • id_ – Search for a pool ID. Multiple IDs are fine. .. warning:: Take note of the underscore (_) mark!

  • description_matches – Search for pool descriptions.

  • creator_name – Search for pools based on creator name.

  • creator_id – Search for pools based on creator ID.

  • is_active – If the pool is active or hidden. (True/False)

  • is_deleted – If the pool is deleted. (True/False)

  • category – Can either be “series” or “collection”.

  • order – The order that pools should be returned, can be any of: name, created_at, updated_at, post_count. If not specified it orders by updated_at.

  • limit – The limit of how many pools should be retrieved.

Returns

list of Pool of the pools.

post(post_id: int) yippi.Classes.Post[source]

Fetch for a post.

Parameters

post_id – The post’s ID to look up.

Returns

Post of the posts.

posts(tags: Optional[Union[List, str]] = None, limit: Optional[int] = None, page: Optional[Union[int, str]] = None) List[yippi.Classes.Post][source]

Search for posts.

Parameters
  • tags – The tags to search.

  • limit – Limits the amount of notes returned to the number specified.

  • page – The page that will be returned.

Returns

list of Post of the posts.

yippi.Classes module

class yippi.Classes.Flag(json_data=None, *args, **kwargs)[source]

Bases: yippi.Classes._BaseMixin

Representation of e621’s Flag object.

Parameters
  • data (optional) – The json server response of a post_flags.json call.

  • client (optional) – The yippi client, used for api calls.

Variables

All (Any) – Refer to e621 API docs for available attributes.

classmethod create()[source]
get_post() Union[Post, Awaitable[Post]][source]

Fetch the post linked with this flag.

Returns

yippi.Classes.Post – The post linked with this flag.

class yippi.Classes.Note(json_data=None, *args, **kwargs)[source]

Bases: yippi.Classes._BaseMixin

Representation of e621’s Note object.

Parameters
  • data (optional) – The json server response of a /notes.json call.

  • client (optional) – The yippi client, used for api calls.

Variables

All (Any) – Refer to e621 API docs for available attributes.

classmethod create(post: Union[Post, int], x: int, y: int, width: int, height: int, body: str, client: AbstractYippi) Note[source]
delete() None[source]
get_post() Union[Post, Awaitable[Post]][source]

Fetch the post linked with this note.

Returns

yippi.Classes.Post – The post linked with this note.

revert(version_id: str) dict[source]

Reverts note to specified version_id. This function has not been tested.

Parameters

version_id – Target version to revert.

Raises

UserError – Raised if - Note does not come from notes(). - client kwags was not supplied.

Returns

dict – JSON status response from API.

update() dict[source]

Updates the note. This function has not been tested.

Returns

dict – JSON status response from API.

upload() dict[source]

Uploads the note. This function has not been tested.

Returns

dict – JSON status response from API.

class yippi.Classes.Pool(json_data=None, *args, **kwargs)[source]

Bases: yippi.Classes._BaseMixin

Representation of e621’s Pool object.

Parameters
  • data (optional) – The json server response of a pools.json call.

  • client (optional) – The yippi client, used for api calls.

Variables

All (Any) – Refer to e621 API docs for available attributes.

classmethod create()[source]
get_posts() Union[List[Post], Awaitable[List[Post]]][source]

Fetch all posts linked with this pool.

If the client is an async client, it will automatically call get_posts_async().

Returns

list of yippi.Classes.Post – All the posts linked with this pool.

async get_posts_async() List[Post][source]

Async representation of get-posts()

Returns

list of yippi.Classes.Post – All the posts linked with this pool.

revert(version_id: str) dict[source]

Reverts note to specified version_id. This function has not been tested.

Parameters

version_id – Target version to revert.

Raises

UserError – Raised if - Pool does not come from pools(). - client kwargs was not supplied.

Returns

dict – JSON status response from API.

update()[source]
class yippi.Classes.Post(json_data=None, *args, **kwargs)[source]

Bases: yippi.Classes._BaseMixin

Representation of e621’s Post object.

Parameters
  • data (optional) – The json server response of a /posts.json call.

  • client (optional) – The yippi client, used for api calls.

Variables

All (Any) – Refer to e621 API docs for available attributes.

favorite() Union[dict, Awaitable[dict]][source]
classmethod from_file(path) Post[source]
classmethod from_url(url) Post[source]
unfavorite() None[source]
update(reason: Optional[str] = None) Union[List[dict], dict, Awaitable[Union[List[dict], dict]]][source]

Updates the post. This function has not been tested.

Parameters

reason (optional) – Reasoning behind the edit. Defaults to None.

Raises

UserError – If the post did not come from any Post endpoint or if no changes has been made.

upload() Union[dict, Awaitable[dict]][source]
vote(score: int = 1, replace: bool = False) dict[source]

Vote the post.

If you want to cancel your vote, repeat the same function again with same score value, but with replace set to False.

Parameters
  • score (optional) – Score to be given, this could be either 1 or -1, with

  • 1 represents vote up and -1 represent vote down. Defaults to 1.

  • replace (optional) – Replaces old vote or not. Defaults to False.

Raises

UserError – Raised if - Post does not come from post() or posts(). - If the value of score is out of scope. - client kwargs was not supplied.

Returns

dict – JSON response with keys score, up, down, and our_score. Where dict['our_score'] is 1, 0, -1 depending on the action.

class yippi.Classes.Tag(json_data=None, *args, **kwargs)[source]

Bases: yippi.Classes._BaseMixin

class yippi.Classes.TagCategory(value)[source]

Bases: enum.IntEnum

An enumeration.

ARTIST = 1
CHARACTER = 4
COPYRIGHT = 3
GENERAL = 0
INVALID = 6
LORE = 8
META = 7
SPECIES = 5

yippi.Exceptions module

exception yippi.Exceptions.APIError[source]

Bases: Exception

exception yippi.Exceptions.UserError(*args, json=None, **kwargs)[source]

Bases: Exception

yippi.Enums module

class yippi.Enums.Rating(value)[source]

Bases: enum.Enum

Enum for e621 rating.

EXPLICIT = 'e'
NONE = None
QUESTIONABLE = 'q'
SAFE = 's'