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
:snake: A simple library to fetch data from the iTunes Store API made for Python >= 3.5

itunespy itunespy is a simple library to fetch data from the iTunes Store API made for Python 3.5 and beyond. Important: Since version 1.6 itunespy no

Fran González 56 Dec 22, 2022
A client that allows a user, specifiy their discord token, to send images remotely to discord

ImageBot_for_Discord A client that allows a user, specifiy their discord token, to send images remotely to discord. Can select images using a file dia

0 Aug 24, 2022
A liblary whre you can find helpful functions for your discord bot

DBotUtils A liblary whre you can find helpful functions for your discord bot Easy setup Setup is easily and flexible. Change anytime. After setup just

Kondek286 1 Nov 02, 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
radiant discord anti nuke src leaked lol.

radiant-anti-wizz-leaked radiant discord anti nuke src leaked lol, the whole anti sucks but idc. sucks to suck thats tuff bro LMAOOOOOO join my server

ok 15 Aug 06, 2022
An unofficial Python wrapper for the 'Binance exchange REST API'

Welcome to binex_f v0.1.0 many interfaces are heavily used by myself in product environment, the websocket is reliable (re)connected. Latest version:

DeepLn 2 Jan 05, 2022
📦 Opensource Python wrapper for Hiven's REST and WebSocket API

hiven.py 📦 Opensource Python wrapper for Hiven's REST and WebSocket API Installation pip install -U hiven.py Usage hiven.py is currently under devel

Kevin Thomas 3 Sep 03, 2021
Program that uses Python to monitor grade updates in the Genesis Platform

Genesis-Grade-Monitor Program that uses Python to monitor grade updates in the Genesis Platform Guide: Install by either cloning the repo or downloadi

Steven Gatanas 1 Feb 12, 2022
🖥️ Python - P1 Monitor API Asynchronous Python Client

🖥️ Asynchronous Python client for the P1 Monitor

Klaas Schoute 9 Dec 12, 2022
Chronocalc - Calculates the dates and times when the sun or moon is in a given position in the sky

Chronocalc I wrote this script after I was busy updating my article on chronoloc

16 Dec 13, 2022
A Telegram Video Watermark Adder Bot

Watermark-Bot A Telegram Video Watermark Adder Bot by @VideosWaterMarkRobot Features: Save Custom Watermark Image. Auto Resize Watermark According to

5 Jun 17, 2022
A Python interface module to the SAS System. It works with Linux, Windows, and mainframe SAS. It supports the sas_kernel project (a Jupyter Notebook kernel for SAS) or can be used on its own.

A Python interface to MVA SAS Overview This module creates a bridge between Python and SAS 9.4. This module enables a Python developer, familiar with

SAS Software 319 Dec 19, 2022
WhatsApp Api Python - This documentation aims to exemplify the use of Moorse Whatsapp API in Python

WhatsApp API Python ChatBot Este repositório contém uma aplicação que se utiliza

Moorse.io 3 Jan 08, 2022
Docker image for epicseven gvg qq chatbot based on Xunbot

XUN_Langskip XUN 是一个基于 NoneBot 和 酷Q 的功能型QQ机器人,目前提供了音乐点播、音乐推荐、天气查询、RSSHub订阅、使用帮助、识图、识番、搜番、上车、磁力搜索、地震速报、计算、日语词典、翻译、自我检查,权限等级功能,由于是为了完成自己在群里的承诺,一时兴起才做的,所

Xavier Xiong 2 Jun 08, 2022
Auto Liker, Auto Reaction, Auto Comment, Auto Follower Tool. RajeLiker Credit Hacker.

Auto Liker, Auto Reaction, Auto Comment, Auto Follower Tool. RajeLiker Credit Hacker. Unlimited RajeLiker Credit Hack. Thanks To RajeLiker.

Md. Mehedi Hasan 32 Dec 28, 2022
Telegram client written in GTK & Python

Meowgram GTK Telegram Client 🐱 Why Meogram? Meowgram = Meow + Gram :D Meow - Talking cats sound. It's a symbol of unique and user friendly UI of clie

Artem Prokop 71 May 04, 2022
A Pancakeswap and Uniswap trading client (and bot) with limit orders, marker orders, stop-loss, custom gas strategies, a GUI and much more.

Pancakeswap and Uniswap trading client Adam A A Pancakeswap and Uniswap trading client (and bot) with market orders, limit orders, stop-loss, custom g

570 Mar 09, 2022
A Discord Server Cloner Which Can Clone Any Discord Server In Just Few Minutes

A Discord Server Cloner Which Can Clone Any Discord Server In Just Few Minutes.

samet 4 Jul 23, 2022
A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.

Light Gradient Boosting Machine LightGBM is a gradient boosting framework that uses tree based learning algorithms. It is designed to be distributed a

Microsoft 14.5k Jan 08, 2023
Zalo AI challenge 2021 5K-Compliance

Zalo AI challenge 2021 5K-Compliance Prepare data: Dữ liệu của ban tổ chức cung

Nguyễn nhật hoàng 32 Nov 21, 2022