Skip to content

AsyncClient#

upbankapi.AsyncClient #

Bases: ClientBase

Asynchronous client for interacting with Up's API

rate_limit: RateLimit class-attribute #

The information regarding the current rate limiting status.

webhook = AsyncWebhookAdapter(self) instance-attribute #

Property for accessing webhook methods.

ping() async #

Retrieves the users unique id and checks if the token is valid.

Returns:

Type Description
str

The users unique id.

Raises:

Type Description
NotAuthorizedException

If the token is invalid.

account(account_id) async #

Retrieve a single account by its unique account id.

Parameters:

Name Type Description Default
account_id str

The unique identifier for an account.

required

Returns:

Type Description
AsyncAccount

The specified account.

accounts(type=None, ownership_type=None, *, limit=None, page_size=DEFAULT_PAGE_SIZE) async #

Retrieves a list of the users accounts.

Parameters:

Name Type Description Default
type Optional[AccountType]

The type of account for which to return records.

None
ownership_type Optional[OwnershipType]

The account ownership structure for which to return records.

None
limit int

The maximum number of records to return.

None
page_size int

The number of records to return in each page. (max appears to be 100)

DEFAULT_PAGE_SIZE

Returns:

Type Description
AsyncPaginatedList[AsyncAccount]

A paginated list of the accounts.

category(category_id) async #

Retrieve a category by its unique category id.

Parameters:

Name Type Description Default
category_id str

The unique identifier for a category.

required

Returns:

Type Description
AsyncCategory

The specified category.

categories(parent=None) async #

Retrieves a list of categories.

Parameters:

Name Type Description Default
parent Union[str, PartialCategory]

The parent category/id to filter categories by. Raises exception for invalid category.

None

Returns:

Type Description
List[AsyncCategory]

A list of the categories.

categorize(transaction, category) async #

Assign a category to a transaction.

Parameters:

Name Type Description Default
transaction Union[str, Transaction]

The transaction/id to change the category on. The transaction must be categorizable otherwise a ValueError will be raised.

required
category Optional[Union[str, PartialCategory]]

The category to assign to the transaction. Setting this to None will de-categorize the transaction.

required

Returns:

Type Description
bool

True if successful, otherwise raises exception.

Raises:

Type Description
ValueError

If the transaction is not categorizable.

tags(*, limit=None, page_size=DEFAULT_PAGE_SIZE) async #

Retrieves a list of the users tags.

Parameters:

Name Type Description Default
limit int

The maximum number of records to return.

None
page_size int

The number of records to return in each page. (max appears to be 100)

DEFAULT_PAGE_SIZE

Returns:

Type Description
AsyncPaginatedList[AsyncTag]

A paginated list of the tags.

add_tags(transaction, *tags) async #

Add tags to a given transaction.

Parameters:

Name Type Description Default
transaction Union[str, Transaction]

The transaction/id to add tags on.

required
*tags Union[str, Tag]

The tags or tag ids to add to the transaction.

()

Returns:

Type Description
bool

True if successful, otherwise raises exception.

remove_tags(transaction, *tags) async #

Remove tags from a given transaction.

Parameters:

Name Type Description Default
transaction Union[str, Transaction]

The transaction/id to remove tags on.

required
*tags Union[str, Tag]

The tags or tag ids to remove to the transaction.

()

Returns:

Type Description
bool

True if successful, otherwise raises exception.

transaction(transaction_id) async #

Retrieve a single transaction by its unique id.

Parameters:

Name Type Description Default
transaction_id str

The unique identifier for a transaction.

required

Returns:

Type Description
AsyncTransaction

The specified transaction.

transactions(account=None, *, status=None, since=None, until=None, category=None, tag=None, limit=None, page_size=DEFAULT_PAGE_SIZE) async #

Retrieves transactions for a specific account or all accounts.

Parameters:

Name Type Description Default
account Union[str, Account]

An account/id to fetch transactions from. If None, returns transactions across all accounts.

None
status TransactionStatus

The transaction status for which to return records.

None
since datetime

The start datetime from which to return records.

None
until datetime

The end datetime up to which to return records.

None
category Union[str, PartialCategory]

The category/id identifier for which to filter transactions. Raises exception for invalid category.

None
tag Union[str, Tag]

A transaction tag/id to filter for which to return records. Returns empty if tag does not exist.

None
limit int

The maximum number of records to return.

None
page_size int

The number of records to return in each page. (max appears to be 100)

DEFAULT_PAGE_SIZE

Returns:

Type Description
AsyncPaginatedList[AsyncTransaction]

A paginated list of the transactions.

webhooks(*, limit=None, page_size=DEFAULT_PAGE_SIZE) async #

Retrieves a list of the users webhooks.

Parameters:

Name Type Description Default
limit int

The maximum number of records to return.

None
page_size int

The number of records to return in each page. (max appears to be 100)

DEFAULT_PAGE_SIZE

Returns:

Type Description
AsyncPaginatedList[AsyncWebhook]

A paginated list of the webhooks.

upbankapi.client.AsyncWebhookAdapter #

Bases: WebhookAdapterBase

__call__(webhook_id) #

Retrieve a single webhook by its unique id.

Parameters:

Name Type Description Default
webhook_id str

The unique identifier for a webhook.

required

Returns:

Type Description
Coroutine[Any, Any, AsyncWebhook]

The specified webhook.

get(webhook_id) async #

Retrieve a single webhook by its unique id.

Parameters:

Name Type Description Default
webhook_id str

The unique identifier for a webhook.

required

Returns:

Type Description
AsyncWebhook

The specified webhook.

create(url, description=None) async #

Registers and returns a new webhook.

Parameters:

Name Type Description Default
url str

The URL that this webhook should post events to.

required
description str

An optional description for this webhook, up to 64 characters in length.

None

Returns:

Type Description
AsyncWebhook

The newly created webhook.

ping(webhook) async #

Pings a webhook by its unique id.

Parameters:

Name Type Description Default
webhook Union[str, Webhook]

The webhook or webhook id to ping.

required

Returns:

Type Description
AsyncWebhookEvent

The ping event response.

logs(webhook, *, limit=None, page_size=DEFAULT_PAGE_SIZE) async #

Retrieves the logs from a webhook by id.

Parameters:

Name Type Description Default
webhook Union[str, Webhook]

The webhook or webhook id to fetch logs from.

required
limit int

The maximum number of records to return.

None
page_size int

The number of records to return in each page. (max appears to be 100)

DEFAULT_PAGE_SIZE

Returns:

Type Description
AsyncPaginatedList[AsyncWebhookLog]

A paginated list of the webhook logs.

delete(webhook) async #

Deletes a webhook by its unique id.

Parameters:

Name Type Description Default
webhook Union[str, Webhook]

The webhook or webhook id to delete.

required

Returns:

Type Description
bool

True if successful, otherwise raises exception.