Library to import bank transactions via API into You Need A Budget (YNAB)
Project description
ynab-api-import
This library enables importing YNAB transactions via the Gocardless Bank Account Data API (formerly Nordigen).
Preparations
Gocardless Bank Account API (formerly Nordigen)
- Check if your bank is supported by the API.
- Create an account with Gocardless for the Bank Account Data API (They have a separate Login for it which you can get to by clicking on 'Get API Keys' or clicking the link at the bottom of their standard login page)
- Go to Developers -> User Secrets and create a new pair of secret_id and secret_key
YNAB
- Create a personal access token for YNAB as described here
- Get your target budget & account IDs. You can find the IDs if you go to https://app.ynab.com/ and open the target account by clicking on the name on the left hand side menu. The URL does now contain both IDs https://app.ynab.com/<budget_id>/accounts/<account_id>
Usage
1. Install library from PyPI
pip install ynab-api-import
2. Initiate Library
from ynabapiimport import YnabApiImport
ynab_api_import = YnabApiImport(secret_id='<secret_id>', secret_key='<secret_key>', budget_id='<budget_id>', token='<token>')
Optionally you can initiate an object from a config.yaml
file. To do that create a YAML file with the following content:
secret_id: <secret_id>
secret_key: <secret_key>
token: <ynab_token>
budget_id: <budget_id>
Save the file and provide the path to the library when initializing
ynab_api_import = YnabApiImport.from_yaml('path/to/config.yaml')
2. Find the institution_id of your bank
Countrycode is ISO 3166 two-character country code.
ynab_api_import.fetch_institutions(countrycode='<countrycode>')
You get back a dictionary with all available banks in that country and their institution_ids. Find and save the institution_id of your bank.
[{'name': '<name>', 'institution_id': '<institution_id>'}]
3. Create Auth Link and authenticate with your bank
Provide a unique reference (e.g. 'mycheckingaccount'
) per bank account to identify the grant later on.
ynab_api_import.create_auth_link(institution_id='<institution_id', reference='<reference>')
You get back a link which you need to copy to your browser and go through authentication flow with your bank
4. Run import with your reference and YNAB account_id
ynab_api_import.import_transactions(reference='<reference>', account_id='<account_id')
Development
Read the CONTRIBUTING.md file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ynab_api_import-0.1.1.tar.gz
.
File metadata
- Download URL: ynab_api_import-0.1.1.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65293aedea0e85a23d3acf5ba22e7d4ec8cf3479cc5580945757fd75c754d359 |
|
MD5 | 548a4ab7b8b07deec3381c82e39af062 |
|
BLAKE2b-256 | 2b5fc7d8cf6ee1dfd8b0d0399d4af30ae225eb95335d7228dd8e918d29726511 |
File details
Details for the file ynab_api_import-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: ynab_api_import-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6591e747ab0c5f6168455a462e3ed3e30851be41d7b631357a78bb8c0d5bbf54 |
|
MD5 | c3f1643ea2ba43d6edf9a1625eacec2a |
|
BLAKE2b-256 | 74e6241ff2507ff5ebba17f4a4a557b487c824fcec78b13c6b7f1d9c64b3d312 |