lasconic/finary_uapi

Fetch checking account transactions

MadeInPierre opened this issue · 5 comments

Hello!

J'aurais préféré t'envoyer une PR directement, mais looks like I'm stuck...

J'aimerais récupérer les nouvelles transactions dispo sur Finary, mon navigateur utilise l'URL suivante :

https://api.finary.com/organizations/***/users/***/portfolio/checking_accounts/transactions?page=1&per_page=50&institution_id=***

J'ai donc essayé de créer un nouveau fichier user_transactions.py dans finary_uapi en prenant les valeurs utilisées par le call dans le navigateur :

import json
import logging
import requests

from .constants import API_ROOT

def get_transactions_from_account_id(
        session: requests.Session, 
        organization_id: str, 
        user_id: str, 
        institution_id: str, 
        page: int = 1, 
        per_page: int = 50,
    ):
    url = f"{API_ROOT}/organizations/{organization_id}/users/{user_id}/portfolio/checking_accounts/transactions?{page=}&{per_page=}&{institution_id=}"
    x = session.get(url, params={})
    logging.debug(json.dumps(x.json(), indent=4))
    return x.json()

Mais je récupère une réponse vide, alors que le navigateur reçoit bien la liste de transactions :

{'result': [], 'message': 'OK', 'error': None}

J'ai une session valide juste avant le call. Any ideas? 🙏

I'll have a look. I didn't know about this new feature. Neat. Hope it stills work with the /me URLs scheme...

I tried it without luck, hopefully you'll find something

Here's the news: https://community.finary.com/t/exploration-gestion-du-cash-flow-budget/2958/154?u=madeinjack

It does work with /users/me and it could be that you forgot the page and per_page param ? if I remove them I have a empty answer. Give me some more minutes and I will push an (untested) update

It's in in version 0.1.6 on pypi and it should be working. The command line tool in main doesn't expose all the options but the function in user_portfolio.py supports page, per_page, query (to filter transactions) and institution_id (to filter by banks)

Note: I don't have a credit card in finary. So it works only for checking_accounts so far. If there are other calls, feel free to open an other issue and create another PR.