All Projects β†’ jcwillox β†’ up-bank-api

jcwillox / up-bank-api

Licence: MIT License
πŸ’Ž Typed python client for Up's banking API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to up-bank-api

promptpay
Thai QR PromptPay Generator
Stars: ✭ 24 (+20%)
Mutual labels:  bank, banking
open-psd2
An open source framework for using banking API's built for PSD2 regulation.
Stars: ✭ 20 (+0%)
Mutual labels:  bank, banking
Loan-calculator-bank-payment
Loan Calculator a small web application encoded in HTML, PHP, JS, and CSS. If you want to earn from BANK NICHE then you can use Loan Calculator script.
Stars: ✭ 32 (+60%)
Mutual labels:  bank, banking
persian-tools-rs
An anthology of a variety of tools for the Persian language in Rust
Stars: ✭ 17 (-15%)
Mutual labels:  bank, banking
pyitau
Unofficial client to access your ItaΓΊ bank data
Stars: ✭ 28 (+40%)
Mutual labels:  bank, banking
bian
The Banking Industry Architecture Network e.V. (BIAN) model in Archimate 3
Stars: ✭ 48 (+140%)
Mutual labels:  bank, banking
bunq2ifttt
bunq2IFTTT creates a self-hosted interface between the bunq banking API and IFTTT.
Stars: ✭ 20 (+0%)
Mutual labels:  bank, banking
gb banking
FiveM Extended Banking Script
Stars: ✭ 14 (-30%)
Mutual labels:  bank, banking
ebics-java-client
Java open source EBICS client - Support for French, German and Swiss banks
Stars: ✭ 30 (+50%)
Mutual labels:  bank, banking
wire
FedWire funds service file parser and writer. The HTTP server is available in a Docker image and the Go package is available.
Stars: ✭ 52 (+160%)
Mutual labels:  banking
jbanking
A Java banking API
Stars: ✭ 58 (+190%)
Mutual labels:  banking
discord-revolut
A Discord bot who monitor your Business Revolut account
Stars: ✭ 15 (-25%)
Mutual labels:  bank
SPStorkController
Now playing controller from Apple Music, Mail & Podcasts Apple's apps.
Stars: ✭ 2,515 (+12475%)
Mutual labels:  up
cyclos
Cyclos is a payment platform for large businesses and organisations
Stars: ✭ 15 (-25%)
Mutual labels:  banking
accounts
accounts - General Ledger and financial account service with an HTTP API
Stars: ✭ 39 (+95%)
Mutual labels:  banking
powerauth-crypto
PowerAuth - Open-source solution for authentication, secure data storage and transport security in mobile banking.
Stars: ✭ 48 (+140%)
Mutual labels:  banking
python-emv
EMV Smartcard Protocol Tool and Library
Stars: ✭ 72 (+260%)
Mutual labels:  banking
iran-sheba
Validate and Recognize IBAN in Iran
Stars: ✭ 23 (+15%)
Mutual labels:  bank
online-banking-system
Online banking system in PHP & MySQL accompanied by a beautiful website !
Stars: ✭ 59 (+195%)
Mutual labels:  banking
node-ebics-client
Node.js EBICS Client - compliant with ISO 20022
Stars: ✭ 46 (+130%)
Mutual labels:  bank

Up Bank API

Project version Supported python versions License CodeFactor Grade Code style

This is an unofficial python wrapper (client) for the australian bank Up's API.

Installation

$ pip install up-bank-api

Usage

The code is fully typed and documented so I'd recommend just having a look at the code, or letting syntax completion take the wheel. The files of interest are models.py and client.py.

This is not yet a complete client and is missing some features, also Up's API is still in beta so new features will likely still be added. You can track this libraries progress here.

To use this library you will need a personal access token which can be retrieved from https://developer.up.com.au. When using this library you can either provide the token directly or use the environment variable UP_TOKEN.

from upbankapi import Client, NotAuthorizedException

# use the environment variable UP_TOKEN
client = Client()

# or directly provide token
client = Client(token="MY_TOKEN")  

# optionally check the token is valid
try:
    user_id = client.ping()
    print("Authorized: " + user_id)
except NotAuthorizedException:
    print("The token is invalid")

Examples

Accounts

accounts = client.accounts()

# list accounts
for account in accounts:
    print(account)

    # list transactions for account
    for transaction in account.transactions():
        print(transaction)

>>> <Account 'Up Account' (TRANSACTIONAL): 1234.56 AUD>
>>> <Transaction SETTLED: -1.0 AUD [7-Eleven]>
>>> <Account 'πŸ’° Savings' (SAVER): 12345.67 AUD>
>>> <Transaction SETTLED: 10.0 AUD [Interest]>
# get the unique id of an account
accounts[1].id
>>> "d7cd1152-e78a-4ad7-8202-d27cddb02a28"

# get a specific account by its unique id
savings = client.account("d7cd1152-e78a-4ad7-8202-d27cddb02a28")
savings
>>> <Account 'πŸ’° Savings' (SAVER): 12345.67 AUD>
savings.balance
>>> 12345.67

Transactions

Get transactions across all accounts.

>>> list( client.transactions() )
[<Transaction SETTLED: -1.0 AUD [7-Eleven]>, <Transaction SETTLED: 10.0 AUD [Interest]>]

Get last 5 transactions for a given account id.

SAVINGS_ID = "d7cd1152-e78a-4ad7-8202-d27cddb02a28"

list( client.account(SAVINGS_ID).transactions(limit=5) )
>>> [<Transaction SETTLED: 10.0 AUD [Interest]>]

list( client.transactions(account_id=SAVINGS_ID, limit=5) )
>>> [<Transaction SETTLED: 10.0 AUD [Interest]>]

Get a specific transaction.

client.transaction("17c577f2-ae8e-4622-90a7-87d95094c2a9")
>>> <Transaction SETTLED: -1.0 AUD [7-Eleven]>

Pagination

Up's API uses pagination, this means methods in this library that return more than one record will return a PaginatedList. This is effectively just an iterator. Every page_size records the instance of PaginatedList will make a request for the next page_size records.

A limit can be used to limit the maximum number of records returned, when a limit is specified the iterator will never return more than limit but can return less. Using limit=None will return all records.

transactions = client.transactions(limit=5)

for transaction in transactions:
    print(transactions)

print(transactions)
>>> <upbankapi.PaginatedList.PaginatedList object at 0x05BCE670>

print(list( transactions ))
>>> [<Transaction SETTLED: -1.0 AUD [7-Eleven]>, <Transaction SETTLED: 10.0 AUD [Interest]>]

PaginatedList supports slicing, it still returns an iterator and will fetch the records as required.

transactions = client.transactions(limit=20)
list( transactions[10:20] )
>>> [<Transaction ...>, ...]

Note that while it may appear the slice [:limit] has the same effect as specifying a limit, it does not, when you specify a limit the code optimises the page size. For example, using the slice [:5] will fetch the first 20 records and return only 5, using limit=5 it will fetch and return the first 5 records. However, if you manually specify page_size=5 then both options have the same effect.

Webhooks

List users webhooks

list( client.webhooks() )
>>> [<Webhook '1c3a4fd4-6c57-4aa8-8481-cf31a46bc001': https://mywebhook.tld/c2f89ed40e26c936 (Hello World!)>]

Get a specific webhook

client.webhook("1c3a4fd4-6c57-4aa8-8481-cf31a46bc001")
# or equivalently
client.webhook.get("1c3a4fd4-6c57-4aa8-8481-cf31a46bc001")
>>> <Webhook '1c3a4fd4-6c57-4aa8-8481-cf31a46bc001': https://mywebhook.tld/c2f89ed40e26c936 (Hello World!)>

Create a webhook

client.webhook.create("https://mywebhook.tld/c2f89ed40e26c936", description="Hello World!")
>>> <Webhook '1c3a4fd4-6c57-4aa8-8481-cf31a46bc001': https://mywebhook.tld/c2f89ed40e26c936 (Hello World!)>

Interacting with a webhook

webhook = client.webhook("1c3a4fd4-6c57-4aa8-8481-cf31a46bc001")

# ping the webhook
webhook.ping()
>>> <WebhookEvent PING: webhook_id='1c3a4fd4-6c57-4aa8-8481-cf31a46bc001'>

# get the webhooks logs
list( webhook.logs() )
>>> [<WebhookLog BAD_RESPONSE_CODE: response_code=404>]

# get the event associated with a log entry
webhook.logs()[0].event
>>> <WebhookEvent PING: webhook_id='1c3a4fd4-6c57-4aa8-8481-cf31a46bc001'>

# delete the webhook
webhook.delete()

When interacting with with a specific webhook there are two options.

For example the two code blocks below have the same result (deleting the webhook), however, the first option uses 2 requests and the second option uses only 1 request. This is because option 1 will request the webhook details, and then send the delete request. Option 2 directly sends the delete request.

# Option 1
client.webhook("1c3a4fd4-6c57-4aa8-8481-cf31a46bc001").delete()
# Option 2
client.webhook.delete("1c3a4fd4-6c57-4aa8-8481-cf31a46bc001")

Each option can be useful depending on the use case. Option 2 is primarily useful when do not already have the Webhook object but have the id and only want to perform a single action.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].