Skip to main content

Python module for comdirect REST api

Project description

comdirect-api-wrapper

Python uv

Comdirect Logo

This is a Python implementation of the new comdirect REST API. This API can be used to interact with the German bank comdirect and view your balances, transactions, and depot. The technical specification of the API (in German) is found here.

Features

Parts which are implemented and working:

  • OAuth 2-factor login process (Photo-TAN, Push-TAN, SMS-TAN)
  • ACCOUNT (balances & transactions)
  • DEPOT (positions & balances)
  • DOCUMENTS

Installation

This Python module is currently not on PyPI.

Using uv (Recommended)

To add this project to your uv managed project:

uv add git+https://github.com/mad4ms/comdirect-api-wrapper.git

Local Development

To install dependencies and set up the environment for development:

git clone https://github.com/mad4ms/comdirect-api-wrapper.git
cd comdirect-api-wrapper
uv sync

Usage

See examples/basic_example.py for a complete example of how to authenticate and fetch data.

Configuration

You need to provide your credentials. The example script uses a .env file (you can copy .env_EXAMPLE to .env).

cp .env_EXAMPLE .env
# Edit .env and add your USERNAME, PASSWORD, CLIENT_ID, and CLIENT_SECRET

⚠️⚠️⚠️ Warning: Make sure to keep your credentials secure and do not share them publicly. With great power comes great responsibility! ⚠️⚠️⚠️

Running the Example

You can run the example script using uv run:

uv run examples/basic_example.py

Basic Code Example

from comdirect_api.client import ComdirectClient
from comdirect_api.utils import default_photo_tan_callback, default_sms_tan_callback, default_push_tan_callback

# Creds dictionary
credentials = {
    "username": "YOUR_USERNAME",
    "password": "YOUR_PASSWORD",
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
}

# 2FA Callbacks
tan_handlers = {
    "photo_tan_cb": default_photo_tan_callback,
    "sms_tan_cb": default_sms_tan_callback,
    "push_tan_cb": default_push_tan_callback,
}

# Initialize and Login
client = ComdirectClient(credentials, tan_handlers)
client.login()

# Usage
# 1. Fetch Accounts
accounts = client.list_accounts()
for account in accounts:
    print(f"Account: {account.id}, Balance: {account.balance} {account.currency}")

# 2. Fetch Transactions (using iterator helper)
if accounts:
    print(f"Transactions for {accounts[0].id}:")
    for tx in client.iter_all_transactions(accounts[0].id):
        print(f" - {tx.booking_date}: {tx.amount} {tx.currency} | {tx.purpose}")

# 3. Fetch Depots & Positions
depots = client.list_depots()
for depot in depots:
    print(f"Depot: {depot.id}")
    balance, positions = client.get_depot_positions(depot.id)
    print(f"Value: {balance.current_value} {balance.current_value_currency}")
    for pos in positions:
        print(f" - {pos.quantity}x {pos.wkn}: {pos.current_value} {pos.current_value_currency}")

client.logout()

Usage Policy

  • Public API: Application code must only import ComdirectClient from comdirect_api.
  • Internal Implementation: OpenAPI-generated code (openapi_client) is an internal implementation detail and should not be imported or used directly. But i can't really force you to not do it.
  • Data Models: Use only the domain models provided by comdirect_api.domain.models. Generated OpenAPI models are not part of the public API.

Development

  • This project uses uv for dependency management.
  • Source code is in src/.
  • OpenAPI Generation: See openapi/GENERATION.md for instructions on updating the generated client code.
  • Run examples with uv run examples/basic_example.py.
  • Run tests (when available) with uv run pytest.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

comdirect_api_wrapper-0.1.tar.gz (67.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comdirect_api_wrapper-0.1-py3-none-any.whl (153.4 kB view details)

Uploaded Python 3

File details

Details for the file comdirect_api_wrapper-0.1.tar.gz.

File metadata

  • Download URL: comdirect_api_wrapper-0.1.tar.gz
  • Upload date:
  • Size: 67.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comdirect_api_wrapper-0.1.tar.gz
Algorithm Hash digest
SHA256 d83c87514e558d33a7de0eaa40931fb7e5df6b6f4dcd7817528daf6943866ce8
MD5 ced3964437c82021d1057307810b9336
BLAKE2b-256 29ba471a1f2fa68f50466b1706d37288108b3b12aee33215f19cc9fdc0960773

See more details on using hashes here.

Provenance

The following attestation bundles were made for comdirect_api_wrapper-0.1.tar.gz:

Publisher: publish.yml on mad4ms/comdirect-api-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comdirect_api_wrapper-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for comdirect_api_wrapper-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 732c21d842a584e65c3f7c0931ff5cc249ebb204de272062fc5b91f09e36c289
MD5 4c179aa8e17dccc07a20cfb9f9d1e816
BLAKE2b-256 16f619cbd755805b721a761d073cb7ab0e5cbcf2bfb47c6c035da001ad42ef95

See more details on using hashes here.

Provenance

The following attestation bundles were made for comdirect_api_wrapper-0.1-py3-none-any.whl:

Publisher: publish.yml on mad4ms/comdirect-api-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page