starling-beancount


Namestarling-beancount JSON
Version 1.3.1 PyPI version JSON
download
home_page
SummaryImport Starling Bank transactions in Beancount
upload_time2024-01-26 19:40:27
maintainer
docs_urlNone
author
requires_python>=3.9
licenseMIT License Copyright (c) 2021 Chris Arderne Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords accounting cli beancount banking
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # starling-beancount
## What is this
Use a [Starling Developer](https://developer.starlingbank.com/get-started) account to programatically export your bank transactions to [beancount](https://beancount.github.io/) files.

There are two main scripts:
1. [starling_beancount/extractor.py](./starling_beancount/extractor.py) converts Starling API JSON to beancount Transactions and Balances.
2. [starling_beancount/importer.py](./starling_beancount/importer.py) contains the configuration for `bean-extract` to parse that.

## Setup
Get a [Starling Personal Access Token](https://developer.starlingbank.com/personal/token) with the following scopes:
```
account:read
balance:read
transaction:read
space:read
```

Save the provided token text in a file somewhere useful (near your beancount files probably).

Install this library:
```bash
pip install starling-beancount smart_importer
```

## Configuration
Make a copy of [config.yml](./config.yml) and edit it to suit your needs.
- The `jointAccs` and `userIds` fields are only needed if you have a joint account and you want to add metadata about which user made a transaction.

## 💪 Running the script

Then run the script:
```
Usage: starling [OPTIONS] ACC

Options:
  --fr TEXT
  --to TEXT                       [default: today]
  --balance / --no-balance        [default: no-balance]
```

Example to get the transactions from `assets_starling` (or whatever you called your `token` file) from a date until today:
```
starling assets_starling --fr=2021-01-01
```

Print the balance:
```
starling assets_starling --balance
```

## 🧠 As a beancount importer
You will need to add something like the following to your `bean-extract` configuration (eg `config.py`):
```python
from starling_beancount.importer import StarlingImporter
from smart_importer import apply_hooks, PredictPostings
from smart_importer.detector import DuplicateDetector

CONFIG = [
    ...,
    apply_hooks(StarlingImporter(
        config_path="path/to/config.yml",
        acc="assets_starling",
        token_path="path/to/token.txt",
        bean_path="path/to/ledger.bean",
    ), [DuplicateDetector(), PredictPostings()])
]
```

Then add a `Note` to your ledger, specifying the earliest date you would like `starling-beancount` to extract from.
**It must have the text "bean-extract" somewhere in it.**
A new note will be added each time you run the script, so that you don't have to deal with too many duplicates.
```beancount
2022-03-01 note Assets:Starling "bean-extract"
```

Last thing! You must create the "target" file that `bean-extract` will look for.
Since we don't actually need a file (it all comes from the API), just add a file to wherever you would normally place them.

👉 Make sure to name this the same as the `acc=` argument to `StarlingImporter` above.

```bash
touch ./raw/assets_starling
```

So long as this file is there, `bean-extract` (and, by extension, the Fava importing tool) will find it and offer you to import that account.

Then run the following:
```bash
bean-extract config.py raw/assets_starling
```

## Prior art
[jorgeml/starlingbank](https://github.com/jorgeml/starlingbank) does a similar thing, albeit more simply (probably for the better).

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "starling-beancount",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "accounting,cli,beancount,banking",
    "author": "",
    "author_email": "Chris Arderne <chris@rdrn.me>",
    "download_url": "https://files.pythonhosted.org/packages/91/7d/7b6f39626e6075796f1a1e09c546e3240985602501c2fbf2d1665eb61da4/starling-beancount-1.3.1.tar.gz",
    "platform": null,
    "description": "# starling-beancount\n## What is this\nUse a [Starling Developer](https://developer.starlingbank.com/get-started) account to programatically export your bank transactions to [beancount](https://beancount.github.io/) files.\n\nThere are two main scripts:\n1. [starling_beancount/extractor.py](./starling_beancount/extractor.py) converts Starling API JSON to beancount Transactions and Balances.\n2. [starling_beancount/importer.py](./starling_beancount/importer.py) contains the configuration for `bean-extract` to parse that.\n\n## Setup\nGet a [Starling Personal Access Token](https://developer.starlingbank.com/personal/token) with the following scopes:\n```\naccount:read\nbalance:read\ntransaction:read\nspace:read\n```\n\nSave the provided token text in a file somewhere useful (near your beancount files probably).\n\nInstall this library:\n```bash\npip install starling-beancount smart_importer\n```\n\n## Configuration\nMake a copy of [config.yml](./config.yml) and edit it to suit your needs.\n- The `jointAccs` and `userIds` fields are only needed if you have a joint account and you want to add metadata about which user made a transaction.\n\n## \ud83d\udcaa Running the script\n\nThen run the script:\n```\nUsage: starling [OPTIONS] ACC\n\nOptions:\n  --fr TEXT\n  --to TEXT                       [default: today]\n  --balance / --no-balance        [default: no-balance]\n```\n\nExample to get the transactions from `assets_starling` (or whatever you called your `token` file) from a date until today:\n```\nstarling assets_starling --fr=2021-01-01\n```\n\nPrint the balance:\n```\nstarling assets_starling --balance\n```\n\n## \ud83e\udde0 As a beancount importer\nYou will need to add something like the following to your `bean-extract` configuration (eg `config.py`):\n```python\nfrom starling_beancount.importer import StarlingImporter\nfrom smart_importer import apply_hooks, PredictPostings\nfrom smart_importer.detector import DuplicateDetector\n\nCONFIG = [\n    ...,\n    apply_hooks(StarlingImporter(\n        config_path=\"path/to/config.yml\",\n        acc=\"assets_starling\",\n        token_path=\"path/to/token.txt\",\n        bean_path=\"path/to/ledger.bean\",\n    ), [DuplicateDetector(), PredictPostings()])\n]\n```\n\nThen add a `Note` to your ledger, specifying the earliest date you would like `starling-beancount` to extract from.\n**It must have the text \"bean-extract\" somewhere in it.**\nA new note will be added each time you run the script, so that you don't have to deal with too many duplicates.\n```beancount\n2022-03-01 note Assets:Starling \"bean-extract\"\n```\n\nLast thing! You must create the \"target\" file that `bean-extract` will look for.\nSince we don't actually need a file (it all comes from the API), just add a file to wherever you would normally place them.\n\n\ud83d\udc49 Make sure to name this the same as the `acc=` argument to `StarlingImporter` above.\n\n```bash\ntouch ./raw/assets_starling\n```\n\nSo long as this file is there, `bean-extract` (and, by extension, the Fava importing tool) will find it and offer you to import that account.\n\nThen run the following:\n```bash\nbean-extract config.py raw/assets_starling\n```\n\n## Prior art\n[jorgeml/starlingbank](https://github.com/jorgeml/starlingbank) does a similar thing, albeit more simply (probably for the better).\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2021 Chris Arderne  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Import Starling Bank transactions in Beancount",
    "version": "1.3.1",
    "project_urls": {
        "homepage": "https://github.com/carderne/starling-beancount"
    },
    "split_keywords": [
        "accounting",
        "cli",
        "beancount",
        "banking"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5ce45c579ec8c5f40585dfceb2e78ff85d5b8fbae4da1f47e08ec863b73741e",
                "md5": "e1e3ce73c477cded12049a0140fa0f2c",
                "sha256": "d5489f637bf9870983ac5af2e6caf28c7d12c7424e196d575868ec3ea7a49d10"
            },
            "downloads": -1,
            "filename": "starling_beancount-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1e3ce73c477cded12049a0140fa0f2c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 8301,
            "upload_time": "2024-01-26T19:40:26",
            "upload_time_iso_8601": "2024-01-26T19:40:26.106253Z",
            "url": "https://files.pythonhosted.org/packages/f5/ce/45c579ec8c5f40585dfceb2e78ff85d5b8fbae4da1f47e08ec863b73741e/starling_beancount-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "917d7b6f39626e6075796f1a1e09c546e3240985602501c2fbf2d1665eb61da4",
                "md5": "da858bb4e1a8bea0b2be7261c8c424e0",
                "sha256": "ca33ee95d82f902299b1e9396b8d142f6f7ead3440ac191501995c53061c837a"
            },
            "downloads": -1,
            "filename": "starling-beancount-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "da858bb4e1a8bea0b2be7261c8c424e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 10694,
            "upload_time": "2024-01-26T19:40:27",
            "upload_time_iso_8601": "2024-01-26T19:40:27.651478Z",
            "url": "https://files.pythonhosted.org/packages/91/7d/7b6f39626e6075796f1a1e09c546e3240985602501c2fbf2d1665eb61da4/starling-beancount-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-26 19:40:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "carderne",
    "github_project": "starling-beancount",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "starling-beancount"
}
        
Elapsed time: 0.17595s