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
Provide fine-grained push access to GitHub from a JupyterHub

github-app-user-auth Provide fine-grained push access to GitHub from a JupyterHub. Goals Allow users on a JupyterHub to grant push access to only spec

Yuvi Panda 20 Sep 13, 2022
A minimalistic, modern Discord bot for roles and polls using dropdowns

DropBot A minimalistic, modern Discord bot for roles and polls using dropdowns Made by ThatOneCalculator Technologies used Instructions Type /, and na

ModernBots 1 Jun 27, 2022
Cloud-native, data onboarding architecture for the Google Cloud Public Datasets program

Public Datasets Pipelines Cloud-native, data pipeline architecture for onboarding datasets to the Google Cloud Public Datasets Program. Overview Requi

Google Cloud Platform 109 Dec 30, 2022
Work with the AWS IP address ranges in native Python.

Amazon Web Services (AWS) publishes its current IP address ranges in JSON format. Python v3 provides an ipaddress module in the standard library that allows you to create, manipulate, and perform operations on IPv4 and IPv6 addresses and networks. Wouldn't it be nice if you could work with the AWS IP address ranges like native Python objects?

AWS Samples 9 Aug 25, 2022
Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and other financial information. This repository provides an SDK for developing applications to access the NCDS.

Nasdaq Cloud Data Service (NCDS) Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and ot

Nasdaq 8 Dec 1, 2022
PyMed is a Python library that provides access to PubMed.

IMPORTANT NOTE: I don't have time to maintain this library (as some of you might have noticed). The PubMed API is a little chaotic, without a clear do

Gijs Wobben 143 Dec 21, 2022
A Python library to access Instagram's private API.

Instagram Private API A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs. Overview I wr

null 2.6k Jan 5, 2023
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
An Open-Source Discord bot created to provide basic functionality which should be in every discord guild. We use this same bot with additional configurations for our guilds.

A Discord bot completely written to be taken from the source and built according to your own custom needs. This bot supports some core features and is

Tesseract Coding 14 Jan 11, 2022
Provide discord buttons feature for discord.py

dpy_buttons wrapper library for discord.py, providing discord buttons feature. Future of the library Will be merged into discord interaction api libra

Minjun Kim (Lapis0875) 17 Feb 2, 2022
This is a Discord script that will provide a QR Code to your scholars for Axie Infinity.

DiscordQRCodeBot This is a Discord script that will provide a QR Code to your Axie Infinity scholars. Setup Run Ubuntu on AWS ec2 instance Dowloads al

ZracheSs | xyZ 24 Oct 5, 2022
The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id

Bot Hadith-API on Telegram The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id Built With Python Asynchronous HTTP protocol client

xMan 12 Feb 19, 2022
A Twitch bot to provide information from the WebNowPlayingCompanion extension

WebNowPlayingTwitch A Twitch bot made using TwitchIO which displays information obtained from the WebNowPlaying Compaion browser extension. Image is o

NiceAesth 1 Mar 21, 2022
Telegram bot to provide links of different types of files you send

File To Link Bot - IDN-C-X Telegram bot to provide links of different types of files you send. WHAT CAN THIS BOT DO Is it a nuisance to send huge file

IDNCoderX 3 Oct 26, 2021
Picot - A discord bot made to fetch images from Pexels and unsplash API and provide raw images directly in channels

Picot A discord bot made to fetch images from Pexels and unsplash API and provid

Ayush Chandwani 5 Jan 12, 2022
Public API client for GETTR, a "non-bias [sic] social network," designed for data archival and analysis.

GoGettr GoGettr is an API client for GETTR, a "non-bias [sic] social network." (We will not reward their domain with a hyperlink.) GoGettr is built an

Stanford Internet Observatory 72 Dec 14, 2022
A solution designed to extract, transform and load Chicago crime data from an RDS instance to other services in AWS.

This project is intended to implement a solution designed to extract, transform and load Chicago crime data from an RDS instance to other services in AWS.

Yesaswi Avula 1 Feb 4, 2022