semvec/pypi-packages huggingface dataset:
dbs-statement-downloader 0.2.1
Python library that downloads e-statements from DBS
License: MIT
Requires Python: >=3.11,<3.12

# DBS Statement Downloader
[![Tests](https://github.com/benjamin-awd/dbs-statement-downloader/actions/workflows/tests.yaml/badge.svg?branch=main&event=push)](https://github.com/benjamin-awd/dbs-statement-downloader/actions/workflows/tests.yaml)
[![CI](https://github.com/benjamin-awd/dbs-statement-downloader/actions/workflows/ci.yaml/badge.svg?branch=main&event=push)](https://github.com/benjamin-awd/dbs-statement-downloader/actions/workflows/ci.yaml)
[![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).*