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
Information about the weather in a city written using Python

Information about the weather in a city Enter the desired city Climate information of the target city This program is written using Python programming

Amir Hussein Sharifnezhad 4 Nov 17, 2021
WhatsApp Multi Device Client

WhatsApp Multi Device Client

23 Nov 18, 2022
Discord Token Checker

Discord-Token-Checker Optimizations Asynchronous Fast & Efficient Multi Tasked Proxy support (socks4/socks5/http) Usage Put tasks depending on your PC

scripted 6 May 05, 2022
A custom Discord Rich Presence to display when you're studying so you're stupid friends won't disturb you when you're studying.

Studying RPC Description A custom Discord Rich Presence to display when you're studying so you're stupid friends won't disturb you when you're studyin

John Edmerson Pizarra 4 Nov 19, 2022
A telegram to pyrogram json bot

Pyrogram-Json-Bot A telegram to pyrogram json bot Please fork this repository don't import code Made with Python3 (C) @FayasNoushad Copyright permissi

Fayas Noushad 11 Dec 20, 2022
A multi-tenant multi-client scalable product categorising demo stack

Better Categories 4All: A multi-tenant multi-client product categorising stack The steps to reproduce training and inference are in the end of this fi

7 Feb 15, 2022
Kyura-Userbot: a modular Telegram userbot that runs in Python3 with a sqlalchemy database

Kyura-Userbot Telegram Kyura-Userbot adalah userbot Telegram modular yang berjal

Kyura 17 Oct 29, 2022
A simple Python wrapper for the archive.is capturing service

archiveis A simple Python wrapper for the archive.is capturing service. Installation pipenv install archiveis Python Usage Import it. import archi

PastPages 157 Dec 28, 2022
Want to get your driver's license? Can't get a appointment because of COVID? Well I got a solution for you.

NJDMV-appoitment-alert Want to get your driver's license? Can't get a appointment because of COVID? Well I got a solution for you. We'll get you one i

Harris Spahic 3 Feb 04, 2022
A python bot that stops muck chains

muck-chains-stopper-bot a bot that stops muck chains this is the source code of u/DaniDevChainBreaker (the main r/DaniDev muck chains breaker) guys th

24 Jan 04, 2023
A Python API to retrieve and read MLB GameDay data

mlbgame mlbgame is a Python API to retrieve and read MLB GameDay data. mlbgame works with real time data, getting information as games are being playe

Zach Panzarino 493 Dec 13, 2022
A template that help you getting started with Pycord.

A Pycord Template with some example! Getting Started: Clone this repository using git clone https://github.com/AungS8430/pycord-template.git If you ha

2 Feb 10, 2022
Zero2 Discord bot is written with Discord.py using Python.

Zero2 Discord bot is written with Discord.py using Python.

Siva Avanish 4 Nov 08, 2021
This is a crypto trading bot that scans the Binance Annoucements page for new coins, and places trades on Gateio

gateio-trading-bot-binance-announcements This Gateio x Binance cryptocurrency trading bot scans the Binance Announcements page and picks up on new coi

Andrei 1.2k Jan 01, 2023
Messing around with GitHub API to look at omicron build times

gh-workflow-runs This is a very simple tool to dump out basic information about workflow runs for a GitHub repo. The structure is based on gh-subscrip

David Pacheco 1 Nov 30, 2021
Tickergram is a Telegram bot to look up quotes, charts, general market sentiment and more.

Tickergram is a Telegram bot to look up quotes, charts, general market sentiment and more.

Alberto Ortega 25 Nov 26, 2022
Client library for accessing IQM quantum computers

IQM Client Client-side library for connecting to an IQM quantum computer. Installation IQM client is not intended to be used directly by human users.

IQM 10 Dec 21, 2022
Sniper for Anigame and Izzi discord bots!

Anigame Sniper Gen-3 Features Inbuilt Spammer Responds to your messages in discord (on/off) Snipes only where you want it to Set latency so that the b

22 Nov 13, 2022
StudyLion is a Discord bot that tracks members' study and work time while offering members to view their statistics and use productivity tools such as: To-do lists, Pomodoro timers, reminders, and much more.

StudyLion - Discord Productivity Bot StudyLion is a Discord bot that tracks members' study and work time while offering members the ability to view th

45 Dec 26, 2022
Event-driven-model-serving - Unified API of Apache Kafka and Google PubSub

event-driven-model-serving Unified API of Apache Kafka and Google PubSub 1. Proj

Danny Toeun Kim 4 Sep 23, 2022