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
Throttle and debounce add-on for Pyrogram

pyrothrottle Throttle and debounce add-on for Pyrogram Quickstart implementation on decorators from pyrogram import Client, filters from pyrogram.type

7 Oct 01, 2022
Telegram music & video bot direct play music

⚡ NOINOI MUSIC PLAYER 🎵 SUPERFAST MUSIC BOT WHO CAN DIRECT PLAY SONG ON TELEGRAM VOICE CHAT ALSO CAN PLAY VIDEO ON VOICE CHATS ✨ Heroku Deploy YOU CA

noinoi-X 1 Dec 28, 2021
Unofficial Coinbase Python Library

Unofficial Coinbase Python Library Python Library for the Coinbase API for use with three legged oAuth2 and classic API key usage Version 0.3.0 Requir

George Sibble 104 Dec 01, 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
Dribble sign up screen built in python and kivy

Dribble sign up screen built in python and kivy contains Dribble icon with icon position and shadow animation.

1 Dec 06, 2021
Brute force instagram account / actonetor, 2021

Brute force instagram account / actonetor, 2021

actonetor 6 Nov 16, 2022
Asynchronous multi-platform robot framework written in Python

NoneBot ✨ 跨平台 Python 异步机器人框架 ✨ 文档 · 安装 · 开始使用 · 文档打不开? 简介 NoneBot2 是一个现代、跨平台、可扩展的 Python 聊天机器人框架,它基于 Python 的类型注解和异步特性,能够为你的需求实现提供便捷灵活的支持。

NoneBot 3.1k Jan 04, 2023
The first open-source PyTgCalls-based project.

Calls Music — Telegram bot + userbot for streaming audio in group calls ✍🏻 Requirements FFmpeg Python 3.7+ 🚀 Deployment 🛠 Configuration Copy exampl

Calls Music 74 Nov 19, 2022
Python based Spotify account generator.

Spotify Account Generator Python based Spotify account generator. Installation Download the latest release, open command prompt in the folder, run pip

polo 5 Dec 27, 2022
CRUD database for python discord bot developers that stores data on discord text channels

Discord Database A CRUD (Create Read Update Delete) database for python Discord bot developers. All data is stored in key-value pairs directly on disc

Ankush Singh 7 Oct 22, 2022
SUPPORTS 500 GROUPS NO NEED OF BOT 😉

LOVELY RADIO SUPPORTS 500 GROUPS NO NEED OF BOT 😉 Requirements Telegram API_ID , API_HASH and SESSION_NAME HEROKU Get YouTube live stream link instal

6 Nov 24, 2021
Discord Mass Edit is a unique, purging related Discord tool that differs from the regular mass delete.

Discord Mass Edit is a unique, purging related Discord tool that differs from the regular mass delete. This tool will automatically edit every message in a chosen channel and change it to a random st

c0mpt0 1 Jul 27, 2022
Changes the Telegram bio, profile picture, first and last name to the song that the user is currently listening to.

TGBIOFY - Telegram & Spotify integration Changes the Telegram bio, profile picture, first and last name to the song that the user is currently listeni

elpideus 26 Dec 07, 2022
A telegram bot writen in python for mirroring files on the internet to Google Drive

owner of this repo :- AYUSH contact me :- AYUSH Slam Mirror Bot This is a telegram bot writen in python for mirroring files on the internet to our bel

Thanusara Pasindu 1 Nov 21, 2021
Um painel de consultas completo, com metodos atualizados.

Meu pix para eu comprar um café :D "25ef499b-d184-4aa1-9797-0a294be40d83" Painel-de-Consultas Completo. Feito por JOESTAR-TEAM Painel de consultas Com

Dio brando 10 Nov 19, 2021
Generate direct m3u playlist for all the channels subscribed in the Tata Sky portal

Tata Sky IPTV Script generator A script to generate the m3u playlist containing direct streamable file (.mpd or MPEG-DASH or DASH) based on the channe

Gaurav Thakkar 250 Jan 01, 2023
Cookies is a project inspired by python cookiecutter but used for terraform generation.

Introduction Cookies is a project inspired by python cookiecutter but used for terraform generation. How to run your terraform After you download your

Digger 6 Mar 14, 2022
TwitterBot-ImageCollector - Twitter bot that collects images from likes saves the image

TwitterBot-ImageCollector Bot de Twitter que recolecta imagenes a partir de los

Gx3 Studios 4 Jun 01, 2022
Posts word definitions on Twitter daily

Word Of The Day bot Post daily word definitions on social media. Twitter account: https://twitter.com/WordOfTheDay_B Introduction The goal of this pro

Lucas Rijllart 1 Jan 08, 2022