Client
upbankapi.Client
#
Bases: ClientBase
Synchronous client for interacting with Up's API
rate_limit: RateLimit
class-attribute
#
The information regarding the current rate limiting status.
webhook = WebhookAdapter(self)
instance-attribute
#
Property for accessing webhook methods.
ping()
#
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)
#
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 |
---|---|
Account
|
The specified account. |
accounts(type=None, ownership_type=None, *, limit=None, page_size=DEFAULT_PAGE_SIZE)
#
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 |
---|---|
PaginatedList[Account]
|
A paginated list of the accounts. |
category(category_id)
#
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 |
---|---|
Category
|
The specified category. |
categories(parent=None)
#
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[Category]
|
A list of the categories. |
categorize(transaction, category)
#
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 |
required |
category |
Optional[Union[str, PartialCategory]]
|
The category to assign to the transaction.
Setting this to |
required |
Returns:
Type | Description |
---|---|
bool
|
|
Raises:
Type | Description |
---|---|
ValueError
|
If the transaction is not |
tags(*, limit=None, page_size=DEFAULT_PAGE_SIZE)
#
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 |
---|---|
PaginatedList[Tag]
|
A paginated list of the tags. |
add_tags(transaction, *tags)
#
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
|
|
remove_tags(transaction, *tags)
#
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
|
|
transaction(transaction_id)
#
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 |
---|---|
Transaction
|
The specified transaction. |
transactions(account=None, *, status=None, since=None, until=None, category=None, tag=None, limit=None, page_size=DEFAULT_PAGE_SIZE)
#
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
|
status |
TransactionStatus
|
The transaction status for which to return records. |
None
|
since |
datetime
|
The start |
None
|
until |
datetime
|
The end |
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 |
---|---|
PaginatedList[Transaction]
|
A paginated list of the transactions. |
webhooks(*, limit=None, page_size=DEFAULT_PAGE_SIZE)
#
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 |
---|---|
PaginatedList[Webhook]
|
A paginated list of the webhooks. |
upbankapi.client.WebhookAdapter
#
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 |
---|---|
Webhook
|
The specified webhook. |
get(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 |
---|---|
Webhook
|
The specified webhook. |
create(url, description=None)
#
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 |
---|---|
Webhook
|
The newly created webhook. |
ping(webhook)
#
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 |
---|---|
WebhookEvent
|
The ping event response. |
logs(webhook, *, limit=None, page_size=DEFAULT_PAGE_SIZE)
#
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 |
---|---|
PaginatedList[WebhookLog]
|
A paginated list of the webhook logs. |