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). It can be helpful for cases in which your bank is not covered by YNABs native import functionality.
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
Usage
1. Install library from PyPI
pip install ynab-api-import
2. Initiate Library
Provide a unique reference (e.g. 'mycheckingaccount'
) per bank connection to identify the grant later on.
You can find the IDs of your budget and the account 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>
from ynabapiimport import YnabApiImport
ynab_api_import = YnabApiImport(secret_id='<secret_id>',
secret_key='<secret_key>',
reference='<reference>',
token='<ynab_token>',
budget_id='<budget_id>',
account_id='<account_id>')
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>
reference: <reference>
token: <ynab_token>
budget_id: <budget_id>
account_id: <account_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 the institution_id. You get back a link which you need to copy to your browser and go through authentication flow with your bank
ynab_api_import.create_auth_link(institution_id='<institution_id>')
4. Run import with your reference and YNAB identifiers
Optionally you can provide a startdate
argument in form of a datetime.date
object to only import transactions from a specific date onwards.
ynab_api_import.import_transactions()
Handling of multiple or no active accounts in your bank connection
The library assumes that you have one active account in your bank connection. It will raise an error if there are no active accounts in your connection or more than one. In the latter case you need to provide the correct resource_id
in your call. You can find the resource_id
by looking into the available options in the error message.
ynab_api_import.import_transactions(resource_id='<resource_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.4.1.tar.gz
.
File metadata
- Download URL: ynab_api_import-0.4.1.tar.gz
- Upload date:
- Size: 17.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 | 598f82b126c1b93e7cfc0c2d26e7b3a605f76c303470f206d956846435b88789 |
|
MD5 | 9837fd03286f294fbd3d7639bfef0b68 |
|
BLAKE2b-256 | 0ee6f96c045fa7c215f0497f281bb3c8dca5aa65117eb38146a7dae5ed162616 |
File details
Details for the file ynab_api_import-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: ynab_api_import-0.4.1-py3-none-any.whl
- Upload date:
- Size: 19.8 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 | 17dfade91fcb15e4083942f9ce86ae99a91e1d3e961f2d489453a35f51746ca8 |
|
MD5 | df54f9158029bde5a3a70f95e82ac073 |
|
BLAKE2b-256 | 844fe45ea560b9a7d48c0ad7c47a737f8f73129180f26e71d64782ec9ed88012 |