Metadata-Version: 2.1
Name: dbs-statement-downloader
Version: 0.2.0
Summary: Python library that downloads e-statements from DBS
Home-page: https://github.com/benjamin-awd/dbs-statement-downloader
License: MIT
Author: Benjamin Dornel
Author-email: benjamindornel@gmail.com
Requires-Python: >=3.11,<3.12
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: google-api-python-client (>=2.111.0,<3.0.0)
Requires-Dist: google-auth (>=2.26.0,<3.0.0)
Requires-Dist: google-auth-oauthlib (>=1.2.0,<2.0.0)
Requires-Dist: google-cloud-secret-manager (>=2.17.0,<3.0.0)
Requires-Dist: google-cloud-storage (>=2.14.0,<3.0.0)
Requires-Dist: pydantic (>=2.5.3,<3.0.0)
Requires-Dist: pydantic-settings (>=2.1.0,<3.0.0)
Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
Requires-Dist: selenium (>=4.16.0,<5.0.0)
Project-URL: Repository, https://github.com/benjamin-awd/dbs-statement-downloader
Description-Content-Type: text/markdown

# DBS Statement Downloader
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Linting: pylint](https://img.shields.io/badge/linting-pylint-orange)](https://github.com/pylint-dev/pylint)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Python library that logs into the DBS iBanking frontend and download estatements using Selenium.

![](https://raw.githubusercontent.com/benjamin-awd/dbs-statement-downloader/main/docs/logs.png)

Since logging into the frontend requires an OTP, text-forwarding (independent of this repository) is used to send the contents of the SMS to a Gmail service account. This OTP is then passed to the Selenium browser.

Requests are then made to the undocumented DBS backend API (https://internet-banking.dbs.com.sg/api/v3/channels/estatements) to retrieve the relevant bank statements.

## Install
Clone the repo
```bash
git clone https://github.com/benjamin-awd/dbs-statement-downloader.git
```

Install dependencies using [Homebrew](https://brew.sh/) and `poetry`
```bash
brew install poetry
poetry env use 3.11
poetry shell
poetry install
```

Create .env file and update values
```bash
cp .env.template .env
```

See [Prerequsites](##Prerequisites) for information on Google Cloud/Gmail setup

## Usage
The downloader can be run directly:
```bash
python3 src/dbs/main.py
```

or with Docker compose:
```bash
docker-compose build && docker-compose up
```

## Prerequisites
- Text-forwarding from iPhone/Android to an email account. On iOS, one possible method is to use an [automation](https://www.reddit.com/r/shortcuts/comments/10hnn94/autoforward_text_messages_with_shortcuts_is_it/) to forward SMS messages from DBS to an email account.
- Google Cloud account, with the Gmail API enabled (see Google Cloud [docs](https://cloud.google.com/endpoints/docs/openapi/enable-api))
- Authorized Gmail account (see Gmail API [docs](https://developers.google.com/gmail/api/quickstart/python))
- Secret stored on Google Secret Manager, which is defined in the .env file as `SECRET_ID`. The secret should be the contents of the `token.json` file generated by running the `quickstart.py` script in this repository. This allows the OTP to be retrieved from Gmail.

  *Note: `quickstart.py` requires a `credentials.json` file to generate the Gmail access token, which can be generated with these [steps](https://stackoverflow.com/a/58468671/14232711).*

