Skip to main content

Library to import bank transactions via API into You Need A Budget (YNAB)

Project description

ynab-api-import

GitHub Release

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)

  1. Check if your bank is supported by the API.
  2. 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)
  3. Go to Developers -> User Secrets and create a new pair of secret_id and secret_key

YNAB

  1. Create a personal access token for YNAB as described here

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>', 
                                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>

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 connection 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 identifiers

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>

ynab_api_import.import_transactions(reference='<reference>', 
                                    budget_id='<budget_id>', 
                                    account_id='<account_id')

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>',
                                    reference='<reference>', 
                                    budget_id='<budget_id>', 
                                    account_id='<account_id')

Development

Read the CONTRIBUTING.md file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ynab_api_import-0.3.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

ynab_api_import-0.3.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file ynab_api_import-0.3.0.tar.gz.

File metadata

  • Download URL: ynab_api_import-0.3.0.tar.gz
  • Upload date:
  • Size: 16.9 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

Hashes for ynab_api_import-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a762689ea5b3c84af21cd6fc5458c55a4fea1045d6a41a540312b37f2190ca80
MD5 d3747795c49c10e2720c80eebcf69928
BLAKE2b-256 43b1b6f3bdb3521d4da340affe4bc8eea7c7bccfc5d7def299ba7cc79e8a3875

See more details on using hashes here.

File details

Details for the file ynab_api_import-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ynab_api_import-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 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

Hashes for ynab_api_import-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25ec514ef89f4d7bb89bc940273e3db6f91c932f4e738db542ba16c09099cc6c
MD5 9e3352c99706311a10c3dfad10e1e06f
BLAKE2b-256 d9606033053b4a46215e99765a6936d2e6a483769820260ccd3a7fd378e978fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page