Code Monkey home page Code Monkey logo

monzoexport's Introduction

Tool to export your Monzo transactions

Setting up

  1. The easiest way is pip3 install --user git+https://github.com/karlicoss/monzoexport.

    Alternatively, use git clone --recursive, or git pull && git submodule update --init. After that, you can use pip3 install --editable.

  2. Create a new oauth client on monzo website.
    • pick confidentiality to be “confidential”
    • redirect uri should be https://github.com (it’s currently hardcoded in the export script)

    After creating the client, click on it in the oauth clients list.

    • add your own user id to “collaborators”, your User ID will be the same as app “Owner ID”. You might need to refresh the page to see changes.
    • take note of “Client ID” and “Client secret”, you’ll need them on the next step
  3. Log in and do an initial export

    The --first-time parameter will walk you through the login procedure:

    python3 -m monzoexport.export --token-path token.json --first-time /path/to/first-export.json
        

    After a successful export, move token.json somewhere safe, and pass it as token-path later. You won’t need to pass --first-time anymore.

    Note that after 5 minutes after login, api can only sync the last 90 days of transactions (see https://docs.monzo.com/#list-transactions for more information). Because of that it’s important to do at least one export immediately once you received the token.

Exporting

Usage:

Recommended: create secrets.py keeping your api parameters, e.g.:

token-path = "TOKEN-PATH"

After that, use:

python3 -m monzoexport.export --secrets /path/to/secrets.py

That way you type less and have control over where you keep your plaintext secrets.

Alternatively, you can pass parameters directly, e.g.

python3 -m monzoexport.export --token-path <token-path>

However, this is verbose and prone to leaking your keys/tokens/passwords in shell history.

You can also import export.py as a module and call get_json function directly to get raw JSON.

I highly recommend checking exported files at least once just to make sure they contain everything you expect from your export. If not, please feel free to ask or raise an issue!

Using data

You can use monzoexport.dal (stands for “Data Access/Abstraction Layer”) to access your exported data, even offline. I elaborate on motivation behind it here.

  • main usecase is to be imported as python module to allow for programmatic access to your data.

    You can find some inspiration in =my.= package that I’m using as an API to all my personal data.

  • to test it against your export, simply run: python3 -m monzoexport.dal --source /path/to/export
  • you can also try it interactively: python3 -m monzoexport.dal --source /path/to/export --interactive

monzoexport's People

Contributors

karlicoss avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

monzoexport's Issues

Something went wrong

The export starts but fails after around 10 minutes, I feel like there's some sort of timeout going on. The first-time json isn't being generated.

Token should be saved on disk now (you won't need to relogin anymore)
Traceback (most recent call last):
File "./export.py", line 150, in
main()
File "./export.py", line 141, in main
j = get_json(params, first_time=first_time)
File "./export.py", line 61, in get_json
return Exporter(params).export_json()
File "./export.py", line 55, in export_json
adata['data'] = self._get_account_data(account_id=aid)
File "./export.py", line 36, in _get_account_data
'since' : since,
File "/usr/local/lib/python3.7/site-packages/pymonzo/monzo_api.py", line 226, in _get_response
"Something went wrong: {}".format(response.json())
pymonzo.exceptions.MonzoAPIError: Something went wrong: {'code': 'forbidden.verification_required', 'message': 'Verification required', 'params': {'account_id': '*******', 'auth_session_id': '
', 'client_id': '', 'end_time': '', 'start_time': '', 'user_id': '*'}}

Cant run exporter.py

Running Python3.7.

Exporter.py gives me: 'Namespace' object has no attribute 'params'
LINE 111

workaround transient retryable error

Happened once, but perhaps would be nice to fix

  File "/usr/local/lib/python3.9/site-packages/pymonzo/monzo_api.py", line 225, in _get_response
    raise MonzoAPIError(
pymonzo.exceptions.MonzoAPIError: Something went wrong: {'code': 'internal_service', 'message': 'An error occurred processing the request', 'retryable': {'value': True}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.