A minimalistic library designed to provide native access to YNAB data from Python

Overview

pYNAB

A minimalistic library designed to provide native access to YNAB data from Python.

Install

The simplest way is to install the latest version from PyPI index:

> pip install -U pynab

or install from the latest source:

git clone https://github.com/aldanor/pynab.git
cd pynab
python setup.py install

Examples

Load the shared YNAB budget:

>>> from ynab import YNAB
>>> ynab = YNAB('~/Dropbox/YNAB', 'MyBudget')

Get the list of accounts:

>>> ynab.accounts
[<Account: Cash>, <Account: Checking>]

Query the balance, the cleared balance and the reconciled balance for cash account:

>>> cash = ynab.accounts['Cash']
>>> cash.balance, cash.cleared_balance, cash.reconciled_balance
(15.38, 24.38, 41.88)

Find the total of all reconciled cash transactions starting 2 weeks ago:

>>> cash = ynab.accounts['Cash']
>>> sum(cash.transactions.since('2 weeks ago').filter('reconciled').amount)
-22.0

Find the average amount of all Starbucks purchases in 2015:

>>> starbucks = ynab.payees['Starbucks']
>>> starbucks.transactions.between('2015-01-01', '2015-12-31').amount.mean()
-27.31176470588235
Comments
  • Add monthly budgets to the models

    Add monthly budgets to the models

    The monthly budgets are useful to see how much you're putting aside each month in each category. This PR add access though the ynab library to this data.

    opened by intiocean 5
  • Unicode characters in category names

    Unicode characters in category names

    £ sign in category names is causing an error in category handling. Removing the £ sign from category names is a workaround.

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib64/python2.7/site-packages/ynab/models.py", line 326, in __str__
        return str(self._elements)
      File "/usr/lib64/python2.7/site-packages/ynab/models.py", line 248, in __repr__
        info += ' ({})'.format(self.category.name)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 16: ordinal not in range(128)
    
    opened by rob-carruthers 2
  • Initial go at adding some functional (integration) tests

    Initial go at adding some functional (integration) tests

    I expect I don't need all the .ydiff files but for simplicity & as I don't fully understand the internal structure I just copied a budget folder across.

    Depends on #5

    opened by intiocean 1
  • Quick and dirty patch for getting transactions from a category

    Quick and dirty patch for getting transactions from a category

    Hi, didn't think it was worth branching just for this. Very quick patch for another bit of functionality, just made it by poking around. See what you think. The methods of Transaction work too. Thanks

    diff --git a/ynab/models.py b/ynab/models.py
    index 1e0b3b4..4f9bf53 100644
    --- a/ynab/models.py
    +++ b/ynab/models.py
    @@ -182,6 +182,10 @@ class Category(CategoryModel):
         def full_name(self):
             return '{}/{}'.format(self.master_category.name, self.name)
    
    +    @property
    +    def transactions(self):
    +        return self._ynab.transactions.filter('category', self)
    +
    
     class MasterCategory(CategoryModel):
         _entity_type = schema.MasterCategory
    
    opened by rob-carruthers 1
  • Fix for line of credit

    Fix for line of credit

    The line of credit account type is mis-capitalized in the AccountType class. Here's a fix:

    diff --git a/ynab/models.py b/ynab/models.py
    index 6013a3e..9ab79b0 100644
    --- a/ynab/models.py
    +++ b/ynab/models.py
    @@ -17,7 +17,7 @@ class AccountType(Enum):
         SAVINGS = 'Savings'
         CREDIT_CARD = 'CreditCard'
         CASH = 'Cash'
    -    LINE_OF_CREDIT = 'LineOfCredit'
    +    LINE_OF_CREDIT = 'LineofCredit'
         PAYPAL = 'Paypal'
         MERCHANT_ACCOUNT = 'MerchantAccount'
         INVESTMENT_ACCOUNT = 'InvestmentAccount'
    
    opened by WoodWireAndFood 0
  • nYNAB

    nYNAB

    The new YNAB (aka YNAB 5, release imminent) is going to be web-based, with all the data hosted on their servers. Do you have any idea whether this will work with nYNAB?

    opened by mjpost 1
  • Its confusing that you can find transactions that aren't in any category

    Its confusing that you can find transactions that aren't in any category

    I realise this is an artefact of the way the data is structured but it would be good to have a note in the docs to make people aware of this. IMHO it would be even nicer if when iterating over transactions in a category (or even always) the sub-transactions relevant to said category also appeared in the list just as any other normal transaction.

    >>> t = budget.transactions.filter('date', date(2014, 10, 28))[-2]
    >>> # t in this case is a transaction with sub transactions (in my budget file)
    
    >>> # t is not in any of the transactions when iterating by category
    >>> print any([t in c.transactions for c in budget.categories])
    False
    
    >>> print t.category
    None
    
    >>> print len(t.sub_transactions)
    7
    
    opened by intiocean 0
Releases(v0.6.8)
Owner
Ivan Smirnov
Musician. Coder. Quant.
Ivan Smirnov
A Discord webhook spammer made in Python

A Python made Discord webhook spammer usually used for token loggers to spam them/delete them original by cattyn changes listed below.

2 Jan 12, 2022
OpenSea-Python-Bot - OpenSea Python Bot can be used in 2 modes

OpenSea-Python-Bot OpenSea Python Bot can be used in 2 modes. When --nft paramet

49 Feb 10, 2022
A Pythonic wrapper for the Wikipedia API

Wikipedia Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. Search Wikipedia, get article summaries, get data

Jonathan Goldsmith 2.5k Dec 28, 2022
Deleting someone else's Instagram account, repeat until the target account is blocked.

Program Features 📌 Instagram report V4. 📌 Coded with the latest version of Python. 📌 Has automatic scheduling. 📌 Full account report. 📌 Report a

hack4lx 16 Oct 25, 2022
Python client library for Google Maps API Web Services

Python Client for Google Maps Services Description Use Python? Want to geocode something? Looking for directions? Maybe matrices of directions? This l

Google Maps 3.8k Jan 01, 2023
pyhakuna is a client to access the API of the time keeping service hakuna.ch.

pyhakuna pyhakuna is a client to access the API of the time keeping service hakuna.ch. The Hakuna API is – unfortunately – personal and currently does

Christian Mäder 1 Feb 15, 2022
⚡ ʑɠ ცơɬ Is One Of The Fastest & Smoothest Bot On Telegram Based on Telethon ⚡

『ʑɠ ცơɬ』 ⚡ ʑɠ ცơɬ Is One Of The Fastest & Smoothest Bot On Telegram Based on Telethon ⚡ Status Of Bot Telegram 🏪 Dєρℓογ το нєяοκυ Variables APP_ID =

ʑɑʑɓɦɑɪ 0 Feb 12, 2022
WhatsApp Multi Device Client

WhatsApp Multi Device Client

23 Nov 18, 2022
Follow pixiv account from twitter profile

Follow pixiv account from twitter profile

Genshi 7 Apr 11, 2022
Paid Udemy Courses with Coupons

Freedemy Paid Udemy Courses with Coupons Steps to run pip3 install -r requirements.txt python3 free-courses.py Then you can click the Enroll Link and

GOKUL A.P 23 Dec 14, 2022
An open source API to validate the EU Covid Certificates / Green Certificates

Open Covid Certificate Validator This an open source API to validate EU Digital COVID Certificates. It receives a COVID certificate and validates it u

Merlin Schumacher 47 May 30, 2022
This is a small package to interact with the OpenLigaDB API.

OpenLigaDB This is a small package to interact with the OpenLigaDB API. Installation Run the following to install: pip install openligadb Usage from o

1 Dec 31, 2021
Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of Scratch2py

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of Scratch2py Installation Run this command i

2 Jan 13, 2022
Prabashwara's Pm Bot repository. You can deploy and edit this repository.

Tᴇʟᴇɢʀᴀᴍ Pᴍ Bᴏᴛ | Prabashwara's PM Bot Unmaintained. The new repo of @Pm-Bot is private. (It is no longer based on this source code. The completely re

Rivibibu Prabshwara Ⓒ 2 Jul 05, 2022
An API wrapper for Discord written in Python.

HCord A fork of discord.py project. HCord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Featu

HCord 0 Jul 30, 2022
Download nitro generator that generates free nitro code that you can use for Discord

Download nitro generator that generates free nitro code that you can use for Discord, run it and wait for free nitro to come

Umut Bayraktar 154 Jan 05, 2023
Tiktok-bot - A Simple Tiktok bot With Python

Install the requirements pip install selenium pip install pyfiglet==0.7.5 How ca

Muchlis Faroqi 5 Aug 23, 2022
Google scholar share - Simple python script to pull Google Scholar data from an author's profile

google_scholar_share Simple python script to pull Google Scholar data from an au

Paul Goldsmith-Pinkham 9 Sep 15, 2022
Dashbot is an application for showing the trade in U.S. Trade Market

Dashbot is an application for showing the trade in U.S. Trade Market (e.g., 4:00am to 8:00pm Eastern Time for the US market using Intraday data using Mercury..

Ahmed Nabil 2 Jan 27, 2022
Ethereum Gas Fee for the MacBook Pro touchbar (using BetterTouchTool)

Gasbar Ethereum Gas Fee for the MacBook Pro touchbar (using BetterTouchTool) Worried about Ethereum gas fees? Me too. I'd like to keep an eye on them

TSS 51 Nov 14, 2022