pub struct AkahuClient { /* private fields */ }Expand description
The main Akahu API client.
Use the builder pattern to construct a new client.
Implementations§
Source§impl AkahuClient
impl AkahuClient
Sourcepub async fn get_accounts(
&self,
user_token: &UserToken,
) -> Result<ListResponse<Account>, AkahuError>
pub async fn get_accounts( &self, user_token: &UserToken, ) -> Result<ListResponse<Account>, AkahuError>
Get a list of all accounts that the user has connected to your application.
§Arguments
user_token- The user’s access token obtained through OAuth
§Returns
A response containing all accounts the user has connected to your application.
The returned account data depends on the permissions your application has been granted.
Access the accounts via the .items field.
Sourcepub async fn get_account(
&self,
user_token: &UserToken,
account_id: &AccountId,
) -> Result<ItemResponse<Account>, AkahuError>
pub async fn get_account( &self, user_token: &UserToken, account_id: &AccountId, ) -> Result<ItemResponse<Account>, AkahuError>
Get a specific account by its ID.
§Arguments
user_token- The user’s access token obtained through OAuthaccount_id- The unique identifier for the account (prefixed withacc_)
§Returns
A response containing the account details for the specified account.
The returned account data depends on the permissions your application has been granted.
Access the account via the .item field.
Sourcepub async fn revoke_account_access(
&self,
user_token: &UserToken,
account_id: &AccountId,
) -> Result<(), AkahuError>
👎Deprecated: This endpoint is deprecated for accounts with official open banking connections. Use the Revoke Access To Authorisation endpoint instead.
pub async fn revoke_account_access( &self, user_token: &UserToken, account_id: &AccountId, ) -> Result<(), AkahuError>
Revoke your application’s access to a specific account.
Note: This endpoint is deprecated for accounts with official open banking connections. Accounts connected via official open banking cannot be revoked on an individual basis. Instead, you must either:
- Direct users through the OAuth flow to adjust permissions with their bank
- Use the Revoke Access To Authorisation endpoint to revoke the entire authorization
§Arguments
user_token- The user’s access token obtained through OAuthaccount_id- The unique identifier for the account to revoke access from
§Returns
Returns Ok(()) on successful revocation.
Returns an error (400) when attempting to revoke accounts with connection_type of “official”.
Source§impl AkahuClient
impl AkahuClient
Sourcepub async fn get_me(&self, user_token: &UserToken) -> Result<User, AkahuError>
pub async fn get_me(&self, user_token: &UserToken) -> Result<User, AkahuError>
Get the authenticated user’s profile information.
This endpoint retrieves information about the user who authorized your application, including their unique identifier and basic profile data. The visibility of certain fields depends on the permissions granted to your application.
§Arguments
user_token- The user’s access token obtained through OAuth
§Returns
The user’s profile information, including:
- User ID
- Account creation timestamp
- First name (if available)
- Last name (if available)
- Email address (requires
AKAHUscope) - Access granted timestamp (when the user authorized your app)
§Scopes
This endpoint requires user-scoped authentication. The AKAHU scope is needed
to access the user’s email address and other profile information.
Source§impl AkahuClient
impl AkahuClient
Sourcepub async fn refresh_all_accounts(
&self,
user_token: &UserToken,
) -> Result<(), AkahuError>
pub async fn refresh_all_accounts( &self, user_token: &UserToken, ) -> Result<(), AkahuError>
Refresh all accounts connected to your application.
This endpoint initiates an on-demand data refresh across all accounts. Account data such as balance and transactions are periodically refreshed by Akahu and enriched asynchronously, providing clean and consistent data across financial institutions.
Note: Data enrichment occurs asynchronously after the refresh request.
§Arguments
user_token- The user’s access token obtained through OAuth
§Returns
Returns Ok(()) on successful refresh initiation.
Sourcepub async fn refresh_account_or_connection<Id: AsRef<str>>(
&self,
user_token: &UserToken,
id: Id,
) -> Result<(), AkahuError>
pub async fn refresh_account_or_connection<Id: AsRef<str>>( &self, user_token: &UserToken, id: Id, ) -> Result<(), AkahuError>
Refresh a specific account or connection.
This endpoint initiates a data refresh for either a specific financial institution connection or individual account.
ID Type Behavior:
- Connection ID: Triggers a refresh for all accounts held at that financial institution
- Account ID: Refreshes that specific account plus any other accounts sharing the same login credentials. For example, if the user has three ASB accounts from a single set of login credentials and you request a refresh for one, the other two accounts will also be refreshed.
Note: Data enrichment occurs asynchronously after the refresh request.
§Arguments
user_token- The user’s access token obtained through OAuthid- Either a Connection ID or Account ID
§Returns
Returns Ok(()) on successful refresh initiation.
Source§impl AkahuClient
impl AkahuClient
Sourcepub async fn get_transactions(
&self,
user_token: &UserToken,
start: Option<DateTime<Utc>>,
end: Option<DateTime<Utc>>,
cursor: Option<Cursor>,
) -> Result<PaginatedResponse<Transaction>, AkahuError>
pub async fn get_transactions( &self, user_token: &UserToken, start: Option<DateTime<Utc>>, end: Option<DateTime<Utc>>, cursor: Option<Cursor>, ) -> Result<PaginatedResponse<Transaction>, AkahuError>
Get a list of the user’s settled transactions within a specified time range.
This endpoint returns settled transactions for all accounts that the user has connected
to your application. The response is paginated - use the cursor.next value to fetch
subsequent pages.
Important Notes:
- Time range defaults to the entire range accessible to your app if not specified
- Transactions will look different depending on your app’s permissions
- All transaction timestamps are in UTC
- The start query parameter is exclusive (transactions after this timestamp)
- The end query parameter is inclusive (transactions through this timestamp)
- All Akahu timestamps use millisecond resolution (e.g. 2025-01-01T11:59:59.999Z)
- Each page contains a maximum of 100 transactions
- When querying multiple pages, use the same start/end parameters with the cursor
§Arguments
user_token- The user’s access token obtained through OAuthquery- Optional query parameters to filter by date range and paginate
§Returns
A paginated response containing transactions and a cursor for fetching more pages.
Sourcepub async fn get_pending_transactions(
&self,
user_token: &UserToken,
) -> Result<Vec<PendingTransaction>, AkahuError>
pub async fn get_pending_transactions( &self, user_token: &UserToken, ) -> Result<Vec<PendingTransaction>, AkahuError>
Get a list of the user’s pending transactions.
This endpoint returns pending transactions for all accounts that the user has connected to your application. Pending transactions are not stable - the date or description may change due to the unreliable nature of underlying NZ bank data. They are not assigned unique identifiers and are not enriched by Akahu.
Important Notes:
- Pending transactions may change before they settle
- They do not have unique IDs
- They are not enriched with merchant/category data
- All timestamps are in UTC
- The
updated_atfield indicates when the transaction was last fetched - This endpoint is not paginated and returns all pending transactions
§Arguments
user_token- The user’s access token obtained through OAuth
§Returns
A vector containing all pending transactions.
[https://developers.akahu.nz/reference/get_transactions-pending]
Sourcepub async fn get_account_transactions(
&self,
user_token: &UserToken,
account_id: &AccountId,
start: Option<DateTime<Utc>>,
end: Option<DateTime<Utc>>,
cursor: Option<Cursor>,
) -> Result<PaginatedResponse<Transaction>, AkahuError>
pub async fn get_account_transactions( &self, user_token: &UserToken, account_id: &AccountId, start: Option<DateTime<Utc>>, end: Option<DateTime<Utc>>, cursor: Option<Cursor>, ) -> Result<PaginatedResponse<Transaction>, AkahuError>
Get settled transactions for a specific account within a specified time range.
This endpoint returns settled transactions for a specific connected account.
The response is paginated - use the cursor.next value to fetch subsequent pages.
Important Notes:
- Time range defaults to the entire range accessible to your app if not specified
- All transaction timestamps are in UTC
- The start query parameter is exclusive (transactions after this timestamp)
- The end query parameter is inclusive (transactions through this timestamp)
- All Akahu timestamps use millisecond resolution
- Each page contains a maximum of 100 transactions
- When querying multiple pages, use the same start/end parameters with the cursor
§Arguments
user_token- The user’s access token obtained through OAuthaccount_id- The unique identifier for the account (prefixed withacc_)query- Optional query parameters to filter by date range and paginate
§Returns
A paginated response containing transactions and a cursor for fetching more pages.
[https://developers.akahu.nz/reference/get_accounts-id-transactions]
Sourcepub async fn get_account_pending_transactions(
&self,
user_token: &UserToken,
account_id: &AccountId,
) -> Result<Vec<PendingTransaction>, AkahuError>
pub async fn get_account_pending_transactions( &self, user_token: &UserToken, account_id: &AccountId, ) -> Result<Vec<PendingTransaction>, AkahuError>
Get pending transactions for a specific account.
This endpoint returns pending transactions for a specific connected account. Pending transactions are not stable - the date or description may change due to the unreliable nature of underlying NZ bank data. They are not assigned unique identifiers and are not enriched by Akahu.
Important Notes:
- Pending transactions may change before they settle
- They do not have unique IDs
- They are not enriched with merchant/category data
- All timestamps are in UTC
- The
updated_atfield indicates when the transaction was last fetched - This endpoint is not paginated and returns all pending transactions
§Arguments
user_token- The user’s access token obtained through OAuthaccount_id- The unique identifier for the account (prefixed withacc_)
§Returns
A vector containing all pending transactions for the account.
[https://developers.akahu.nz/reference/get_accounts-id-transactions-pending]
Source§impl AkahuClient
impl AkahuClient
Sourcepub fn new<T: Into<AppToken>>(
client: Client,
app_id_token: T,
base_url: Option<String>,
) -> Self
pub fn new<T: Into<AppToken>>( client: Client, app_id_token: T, base_url: Option<String>, ) -> Self
Create a new Akahu client.
§Arguments
client- The HTTP client to use for requestsapp_id_token- Your Akahu application ID tokenbase_url- Optional custom base URL (defaults tohttps://api.akahu.io/v1)
Sourcepub fn with_app_secret<T: Into<AppSecret>>(self, app_secret: T) -> Self
pub fn with_app_secret<T: Into<AppSecret>>(self, app_secret: T) -> Self
Set the app secret for app-scoped endpoints.
The app secret is required for app-scoped endpoints like Categories. These endpoints use HTTP Basic Authentication with app_id_token:app_secret.