├── deploy.sh ├── simplifiapi ├── __init__.py ├── __main__.py ├── cli.py └── client.py ├── pyproject.toml ├── setup.cfg ├── LICENSE ├── README.md └── .gitignore /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | rm -rf dist && python3 -m build 3 | python3 -m twine upload dist/* -------------------------------------------------------------------------------- /simplifiapi/__init__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logging.getLogger("simplifiapi").setLevel(logging.INFO) -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /simplifiapi/__main__.py: -------------------------------------------------------------------------------- 1 | from simplifiapi.cli import main 2 | 3 | import logging 4 | 5 | logging.getLogger("simplifiapi").setLevel(logging.INFO) 6 | 7 | if __name__ == "__main__": 8 | main() 9 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = setuptools 3 | version = 0.0.1 4 | 5 | [options] 6 | install_requires = 7 | configargparse 8 | pandas 9 | requests 10 | packages = find: 11 | 12 | [options.entry_points] 13 | console_scripts = 14 | simplifiapi = simplifiapi.cli:main 15 | 16 | [options.packages.find] 17 | exclude = 18 | tests -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Rijn Bian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # simplifiapi 2 | An unofficial API for Quicken Simplifi 3 | 4 | ## Install 5 | 6 | PyPI is temporarily down. Install with pip from GitHub directly 7 | 8 | ```shell 9 | pip3 install git+https://github.com/rijn/simplifiapi 10 | ``` 11 | 12 | ## CLI 13 | 14 | This package provides a command-line tool that could access and save data to local files. 15 | 16 | ```shell 17 | usage: simplifiapi [-h] [--email [EMAIL]] [--password [PASSWORD]] [--token [TOKEN]] [--accounts] [--transactions] [--tags] [--categories] [--filename FILENAME] [--format {json,csv}] 18 | 19 | optional arguments: 20 | -h, --help show this help message and exit 21 | --email [EMAIL] The e-mail address for your Quicken Simplifi account 22 | --password [PASSWORD] 23 | The password for your Quicken Simplifi account 24 | --token [TOKEN] Use existing token to bypass MFA check 25 | --accounts Retrieve accounts 26 | --transactions Retrieve transactions 27 | --tags Retrieve tags 28 | --categories Retrieve categories 29 | --filename FILENAME Write results to file this prefix 30 | --format {json,csv} The format used to return data. 31 | 32 | examples: 33 | > simplifiapi --token="..." --transactions 34 | > simplifiapi --token="..." --transactions --filename=20231125 --format=csv 35 | ``` 36 | 37 | ## Python API 38 | 39 | The `Client` class allows accessing from python script and making custom analysis. 40 | 41 | ```python 42 | from simplifiapi.client import Client 43 | 44 | client = Client() 45 | 46 | # Provide either token or email/password 47 | token = "..." 48 | token = client.get_token(email=options.email, password=options.password) 49 | 50 | assert client.verify_token(token) 51 | 52 | # Datasets own transactions and accounts 53 | datasets = client.get_datasets() 54 | datasetId = datasets[0]["id"] 55 | 56 | # Access transactions 57 | transactions = client.get_transactions(datasetId) 58 | ``` 59 | 60 | ## Thanks 61 | 62 | This library is heavily inspired by [mintapi](https://github.com/mintapi/mintapi). -------------------------------------------------------------------------------- /simplifiapi/cli.py: -------------------------------------------------------------------------------- 1 | import json 2 | import logging 3 | import sys 4 | 5 | import configargparse 6 | from pandas import json_normalize 7 | 8 | from simplifiapi.client import Client 9 | 10 | logger = logging.getLogger("simplifiapi") 11 | 12 | JSON_FORMAT = "json" 13 | CSV_FORMAT = "csv" 14 | 15 | 16 | def parse_arguments(args): 17 | parser = configargparse.ArgumentParser() 18 | 19 | # Credential 20 | parser.add_argument('--email', 21 | nargs="?", 22 | default=None, 23 | help="The e-mail address for your Quicken Simplifi account") 24 | parser.add_argument('--password', 25 | nargs="?", 26 | default=None, 27 | help="The password for your Quicken Simplifi account") 28 | parser.add_argument('--token', 29 | nargs="?", 30 | default=None, 31 | help="Use existing token to bypass MFA check") 32 | 33 | # Datasets 34 | parser.add_argument('--accounts', 35 | action="store_true", 36 | default=False, 37 | help="Retrieve accounts") 38 | parser.add_argument('--transactions', 39 | action="store_true", 40 | default=False, 41 | help="Retrieve transactions") 42 | parser.add_argument('--tags', 43 | action="store_true", 44 | default=False, 45 | help="Retrieve tags") 46 | parser.add_argument('--categories', 47 | action="store_true", 48 | default=False, 49 | help="Retrieve categories") 50 | 51 | # Export 52 | parser.add_argument('--filename', 53 | default="output", 54 | help="Write results to file this prefix") 55 | parser.add_argument('--format', 56 | choices=[JSON_FORMAT, CSV_FORMAT], 57 | default=JSON_FORMAT, 58 | help="The format used to return data.") 59 | 60 | return parser.parse_args(args) 61 | 62 | 63 | def write_data(options, data, name): 64 | filename = "{}_{}.{}".format(options.filename, name, options.format) 65 | logger.warn("Saving {} to {}".format(name, filename)) 66 | if options.format == CSV_FORMAT: 67 | json_normalize(data).to_csv(filename, index=False) 68 | elif options.format == JSON_FORMAT: 69 | with open(filename, "w+") as f: 70 | json.dump(data, f, indent=2) 71 | 72 | 73 | def main(): 74 | options = parse_arguments(sys.argv[1:]) 75 | 76 | client = Client() 77 | 78 | token = options.token 79 | if (not token): 80 | token = client.get_token( 81 | email=options.email, password=options.password) 82 | 83 | if (client.verify_token(token) == False): 84 | logger.error("Unable to log in simplifi.") 85 | return 86 | 87 | # Retrieve first dataset 88 | # TODO: Support multiple datasets 89 | datasets = client.get_datasets() 90 | datasetId = datasets[0]["id"] 91 | 92 | if (options.accounts): 93 | accounts = client.get_accounts(datasetId) 94 | write_data(options, accounts, "accounts") 95 | 96 | if (options.transactions): 97 | transactions = client.get_transactions(datasetId) 98 | write_data(options, transactions, "transactions") 99 | 100 | if (options.tags): 101 | tags = client.get_tags(datasetId) 102 | write_data(options, tags, "tags") 103 | 104 | if (options.categories): 105 | categories = client.get_categories(datasetId) 106 | write_data(options, categories, "categories") 107 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /simplifiapi/client.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import requests 3 | import uuid 4 | from urllib.parse import urljoin 5 | 6 | logger = logging.getLogger("simplifiapi") 7 | 8 | SIMPLIFI_ENDPOINT = "https://services.quicken.com" 9 | 10 | 11 | class Client(): 12 | 13 | def __init__(self): 14 | self.session = requests.Session() 15 | 16 | def get_token(self, email, password): 17 | # Step 1: Oauth authorize 18 | body = { 19 | "clientId": "acme_web", 20 | "mfaChannel": None, 21 | "mfaCode": None, 22 | "password": password, 23 | "redirectUri": "https://app.simplifimoney.com/login", 24 | "responseType": "code", 25 | "threatMetrixRequestId": None, 26 | "threatMetrixSessionId": str(uuid.uuid4()), 27 | "username": email, 28 | } 29 | r = self.session.post( 30 | url="https://services.quicken.com/oauth/authorize", json=body) 31 | data = r.json() 32 | status = data.get("status") 33 | if (status == "MFA code sent"): 34 | mfaChannel = data.get("mfaChannel") 35 | logger.warning("MFA Channel: {}".format(mfaChannel)) 36 | mfaCode = input("MFA Code: ") 37 | body["mfaChannel"] = mfaChannel 38 | body["mfaCode"] = mfaCode 39 | r = requests.post( 40 | url="https://services.quicken.com/oauth/authorize", json=body) 41 | r.raise_for_status() 42 | data = r.json() 43 | status = data.get("status") 44 | if (status != "User passed MFA"): 45 | logger.error("Login failed.") 46 | logger.error(r.json()) 47 | return 48 | code = r.json().get("code") 49 | 50 | # Step 2: Get token 51 | r = self.session.post(url="https://services.quicken.com/oauth/token", 52 | json={ 53 | "clientId": "acme_web", 54 | "clientSecret": "BCDCxXwdWYcj@bK6", 55 | "grantType": "authorization_code", 56 | "code": code, 57 | "redirectUri": "https://app.simplifimoney.com/login" 58 | }) 59 | r.raise_for_status() 60 | token = r.json().get("accessToken") 61 | 62 | logger.warn("Retrieved token {}".format(token)) 63 | 64 | return token 65 | 66 | def verify_token(self, token) -> bool: 67 | headers = {"Authorization": "Bearer {}".format(token)} 68 | 69 | r = self.session.get(url="https://services.quicken.com/userprofiles/me", 70 | headers=headers) 71 | if (r.status_code != 200): 72 | logger.error("Error code: {}".format(r.status_code)) 73 | logger.error(r.json()) 74 | return False 75 | data = r.json() 76 | userId = data.get("id") 77 | logger.warn("User {} logged in.".format(userId)) 78 | 79 | # Update session 80 | self.session.headers.update(headers) 81 | 82 | return True 83 | 84 | def _unpaginate(self, path: str, **kargs): 85 | nextLink = path 86 | data = [] 87 | while nextLink: 88 | logger.warn("Fetching {}".format(nextLink)) 89 | r = self.session.get(url=urljoin( 90 | SIMPLIFI_ENDPOINT, nextLink), **kargs) 91 | r.raise_for_status() 92 | data.extend(r.json()["resources"]) 93 | nextLink = r.json().get("metaData").get("nextLink") 94 | return data 95 | 96 | def get_datasets(self, limit: int = 1000): 97 | return self._unpaginate(path="/datasets", 98 | params={ 99 | limit: limit, 100 | }) 101 | 102 | def get_accounts(self, datasetId: str): 103 | return self._unpaginate(path="/accounts", 104 | headers={ 105 | "Qcs-Dataset-Id": datasetId, 106 | }, 107 | params={ 108 | "limit": 1000, 109 | }) 110 | 111 | def get_transactions(self, datasetId: str): 112 | return self._unpaginate(path="/transactions", 113 | headers={ 114 | "Qcs-Dataset-Id": datasetId, 115 | }, 116 | params={ 117 | "limit": 1000, 118 | }) 119 | 120 | def get_tags(self, datasetId: str): 121 | return self._unpaginate(path="/tags", 122 | headers={ 123 | "Qcs-Dataset-Id": datasetId, 124 | }, 125 | params={ 126 | "limit": 1000, 127 | }) 128 | 129 | def get_categories(self, datasetId: str): 130 | return self._unpaginate(path="/categories", 131 | headers={ 132 | "Qcs-Dataset-Id": datasetId, 133 | }, 134 | params={ 135 | "limit": 1000, 136 | }) 137 | --------------------------------------------------------------------------------