Accounts Reference

The accounts interface provides a way to login, register and modify user specific data with the Kemono API.

Account Types

The types of different accounts, by rank.

class pykemo.accounts.kinds.cons.Consumer(*, id, username, created_at, session)

A basic consumer account.

Warning

It is not recommended to use unless you know what you’re doing. Methods like login() are preferred as they automatically create a session internally.

Parameters:
  • id (int) – The account ID.

  • username (str) – The name of the user’s account.

  • created_at (datetime.datetime) – When was the account created.

  • ks (KemoSession) – The underlying session of the account context.

  • session (KemoSession)

async change_password(current_password, new_password, close_on_fail=True)

Attempts to change the current password for this account.

Warning

Be careful. If this launches an exception and close_on_fail is set to False, the internal session will not close. It’s the responsability of the programmer at this point to close it if that happens.

Parameters:
  • current_password (str) – The password that is already set.

  • new_password (str) – The new value to overwrite the current password with.

  • close_on_fail (bool, optional) – Wether to close the internal session if this launches an exception, defaults to True.

Raises:

PyKemoException – If the change fails for whatever reason.

Return type:

None

async favorite_artists()

Tries to retrieve this account’s favorite artists. Alias for favorite_creators().

Returns:

The list of favorite artists (creators).

Return type:

list[Creator]

async favorite_creators()

Tries to retrieve this account’s favorite creators.

Returns:

The list of favorite creators.

Return type:

list[Creator]

async favorite_posts()

Tries to retrieve this account’s favorite posts.

Returns:

The list of favorite posts.

Return type:

list[Post]

async get_creator(service, creator_id)

A wrapper for fetching a creator with the account session.

Parameters:
  • service (ServiceLike) – The service of the creator.

  • creator_id (str) – The ID of the creator.

Returns:

The creator instance, if found. Otherwise returns None.

Return type:

Optional[Creator]

async get_post(service, post_id)

Wrapper for fetching a post without the creator ID.

Parameters:
  • service (ServiceLike) – The service the post falls under.

  • post_id (PostID) – The ID of the specific post.

Returns:

The loaded post, if it was found. If not, returns None.

Return type:

Optional[Post]

async classmethod login(user, password, session=None)

Tries to login with a given user and password.

Parameters:
  • user (str) – The username to try to login with.

  • password (str) – The password to try to login with.

  • session (KemoSession, optional) – The Kemono session to use, defaults to None.

Raises:
Returns:

The account of the user, if sucessfully logged in.

Return type:

Self

async logout()

Log out of the session.

Return type:

None

async random_creator()

Wrapper for retrieving a random creator from the site.

Returns:

If a creator is found, retrieve and create a Creator instance, otherwise return None.

Return type:

Optional[Creator]

async random_post()

Wrapper for retrieving a random post from the site.

Returns:

If a creator is found, retrieve and create a Post instance, otherwise return None.

Return type:

Optional[Post]

async classmethod register(user, password)

Tries to register a account user.

Parameters:
  • user (str) – The username to try to register with.

  • password (str) – The password to try to register with.

Raises:
Returns:

The account of the user, if sucessfully logged in after registering.

Return type:

Self

static role()

Tries to describe this account’s rank.

Returns:

The account role type.

Return type:

AccountRole

class pykemo.accounts.kinds.mod.Moderator(*, id, username, created_at, session)

A moderator account.

Warning

It is not recommended to use unless you know what you’re doing. Methods like login() are preferred as they automatically create a session internally.

Parameters:
  • id (int) – The account ID.

  • username (str) – The name of the user’s account.

  • created_at (datetime.datetime) – When was the account created.

  • ks (KemoSession) – The underlying session of the account context.

  • session (KemoSession)

async change_password(current_password, new_password, close_on_fail=True)

Attempts to change the current password for this account.

Warning

Be careful. If this launches an exception and close_on_fail is set to False, the internal session will not close. It’s the responsability of the programmer at this point to close it if that happens.

Parameters:
  • current_password (str) – The password that is already set.

  • new_password (str) – The new value to overwrite the current password with.

  • close_on_fail (bool, optional) – Wether to close the internal session if this launches an exception, defaults to True.

Raises:

PyKemoException – If the change fails for whatever reason.

Return type:

None

Fetches a list of creator link requests that have yet to be reviewed.

Raises:

InsufficientPrivileges – If, somehow, the one invoking this operation isn`t at least a moderator.

Returns:

A list of pending creator link requests, if any.

Return type:

list[CreatorLinkRequest]

async favorite_artists()

Tries to retrieve this account’s favorite artists. Alias for favorite_creators().

Returns:

The list of favorite artists (creators).

Return type:

list[Creator]

async favorite_creators()

Tries to retrieve this account’s favorite creators.

Returns:

The list of favorite creators.

Return type:

list[Creator]

async favorite_posts()

Tries to retrieve this account’s favorite posts.

Returns:

The list of favorite posts.

Return type:

list[Post]

async get_creator(service, creator_id)

A wrapper for fetching a creator with the account session.

Parameters:
  • service (ServiceLike) – The service of the creator.

  • creator_id (str) – The ID of the creator.

Returns:

The creator instance, if found. Otherwise returns None.

Return type:

Optional[Creator]

async get_post(service, post_id)

Wrapper for fetching a post without the creator ID.

Parameters:
  • service (ServiceLike) – The service the post falls under.

  • post_id (PostID) – The ID of the specific post.

Returns:

The loaded post, if it was found. If not, returns None.

Return type:

Optional[Post]

async classmethod login(user, password, session=None)

Tries to login with a given user and password.

Parameters:
  • user (str) – The username to try to login with.

  • password (str) – The password to try to login with.

  • session (KemoSession, optional) – The Kemono session to use, defaults to None.

Raises:
Returns:

The account of the user, if sucessfully logged in.

Return type:

Self

async logout()

Log out of the session.

Return type:

None

async random_creator()

Wrapper for retrieving a random creator from the site.

Returns:

If a creator is found, retrieve and create a Creator instance, otherwise return None.

Return type:

Optional[Creator]

async random_post()

Wrapper for retrieving a random post from the site.

Returns:

If a creator is found, retrieve and create a Post instance, otherwise return None.

Return type:

Optional[Post]

async classmethod register(user, password)

Tries to register a account user.

Parameters:
  • user (str) – The username to try to register with.

  • password (str) – The password to try to register with.

Raises:
Returns:

The account of the user, if sucessfully logged in after registering.

Return type:

Self

static role()

Tries to describe this account’s rank.

Returns:

The account role type.

Return type:

AccountRole

class pykemo.accounts.kinds.admin.Admin(*, id, username, created_at, session)

An administrator account.

Warning

It is not recommended to use unless you know what you’re doing. Methods like login() are preferred as they automatically create a session internally.

Parameters:
  • id (int) – The account ID.

  • username (str) – The name of the user’s account.

  • created_at (datetime.datetime) – When was the account created.

  • ks (KemoSession) – The underlying session of the account context.

  • session (KemoSession)

async change_password(current_password, new_password, close_on_fail=True)

Attempts to change the current password for this account.

Warning

Be careful. If this launches an exception and close_on_fail is set to False, the internal session will not close. It’s the responsability of the programmer at this point to close it if that happens.

Parameters:
  • current_password (str) – The password that is already set.

  • new_password (str) – The new value to overwrite the current password with.

  • close_on_fail (bool, optional) – Wether to close the internal session if this launches an exception, defaults to True.

Raises:

PyKemoException – If the change fails for whatever reason.

Return type:

None

async change_roles(mod_ids, cons_ids)

_summary_

Parameters:
  • mod_ids (Iterable[CreatorID]) – The IDs of the soon to-be moderators.

  • cons_ids (Iterable[CreatorID]) – The IDs of the soon to-be consumers.

Raises:

InsufficientPrivileges – If, somehow, the one invoking this operation isn`t at least an administrator.

Returns:

A boolean value indicating if the operation was a success.

Return type:

bool

Fetches a list of creator link requests that have yet to be reviewed.

Raises:

InsufficientPrivileges – If, somehow, the one invoking this operation isn`t at least a moderator.

Returns:

A list of pending creator link requests, if any.

Return type:

list[CreatorLinkRequest]

async favorite_artists()

Tries to retrieve this account’s favorite artists. Alias for favorite_creators().

Returns:

The list of favorite artists (creators).

Return type:

list[Creator]

async favorite_creators()

Tries to retrieve this account’s favorite creators.

Returns:

The list of favorite creators.

Return type:

list[Creator]

async favorite_posts()

Tries to retrieve this account’s favorite posts.

Returns:

The list of favorite posts.

Return type:

list[Post]

async get_creator(service, creator_id)

A wrapper for fetching a creator with the account session.

Parameters:
  • service (ServiceLike) – The service of the creator.

  • creator_id (str) – The ID of the creator.

Returns:

The creator instance, if found. Otherwise returns None.

Return type:

Optional[Creator]

async get_post(service, post_id)

Wrapper for fetching a post without the creator ID.

Parameters:
  • service (ServiceLike) – The service the post falls under.

  • post_id (PostID) – The ID of the specific post.

Returns:

The loaded post, if it was found. If not, returns None.

Return type:

Optional[Post]

async classmethod login(user, password, session=None)

Tries to login with a given user and password.

Parameters:
  • user (str) – The username to try to login with.

  • password (str) – The password to try to login with.

  • session (KemoSession, optional) – The Kemono session to use, defaults to None.

Raises:
Returns:

The account of the user, if sucessfully logged in.

Return type:

Self

async logout()

Log out of the session.

Return type:

None

async random_creator()

Wrapper for retrieving a random creator from the site.

Returns:

If a creator is found, retrieve and create a Creator instance, otherwise return None.

Return type:

Optional[Creator]

async random_post()

Wrapper for retrieving a random post from the site.

Returns:

If a creator is found, retrieve and create a Post instance, otherwise return None.

Return type:

Optional[Post]

async classmethod register(user, password)

Tries to register a account user.

Parameters:
  • user (str) – The username to try to register with.

  • password (str) – The password to try to register with.

Raises:
Returns:

The account of the user, if sucessfully logged in after registering.

Return type:

Self

async remove_creator(creator)

Removes a creator from its linked accounts. This is useful when when dealing with wrongful linkage where creators linked are not acutally the same person.

Parameters:

creator (Creator) – The creator to separate from the other links.

Raises:

InsufficientPrivileges – If, somehow, the one invoking this operation isn`t at least an administrator.

Returns:

A boolean value indicating if the operation was successful or not.

Return type:

bool

Removes a creator from its linked accounts. This is useful when when dealing with wrongful linkage where creators linked are not acutally the same person. This one uses only the service and ID, without loading a creator.

Parameters:
  • service (ServiceLike) – The service of the creator in question.

  • creator_id (CreatorID) – The ID of the creator to separate from the other links.

Raises:

InsufficientPrivileges – If, somehow, the one invoking this operation isn`t at least an administrator.

Returns:

A boolean value indicating if the operation was successful or not.

Return type:

bool

static role()

Tries to describe this account’s rank.

Returns:

The account role type.

Return type:

AccountRole

async view_accounts(*, name=None, role=None, page=None, limit=None)

Tries to fetch accounts with minimal info, unlike the ones that manage their own session.

Parameters:
  • name (str, optional) – An account name to filter results by, defaults to None

  • role (AccountRole, optional) – An account role type to filter results by, defaults to None

  • page (int, optional) – A value for paging in account view retrieving, defaults to None

  • limit (int, optional) – A value for fetching limiting in account view retrieving, defaults to None

Raises:
  • ValueError – If page or limit are present and any of them has value 0 or less.

  • InsufficientPrivileges – If, somehow, the one invoking this operation isn`t at least an administrator.

Returns:

A list of simplified account views, if found.

Return type:

list[AccountView]

Account View

A simplified view of an account, purely for seeing basic data.

class pykemo.accounts.view.AccountView(*, id, username, created_at, role)

A basic view of an Account.

Parameters:
  • id (int)

  • username (str)

  • created_at (datetime)

  • role (AccountRole)