Package: dkb-robo
dkb-robodkb-robo is a python library to access the internet banking area of"Deutsche Kreditbank"to fetchaccount information and current balancestransactions from creditcards and checking accounts (Girokonten)query the content of "DKB Postbox"get standing orders (Dauerauftrag)get information about credit limits and exemption orders (Freistellungsauftrag)Starting from version 0.9 dkb-robo can handle the 2nd factor DKB introduced to fulfill thePSD2 obligations. Starting from September 2019 logins must be confirmed by eitherthe blueDKB-Banking appInsertion of a TAN created by theDKB TAN2Go appThe introduction of a 2nd factor does limit the usage of dkb-robo for automation purposes. DKB is unfortunatelynot willing/ not ablenot allowed to open their PSD2-API for non-Fintechs. I discussed this with them for weeks at some point they stopped responding to my emails so I gave up.DKB introduced a new web-frontend in July 2023 which is using a REST-API as backend. The migration to the new REST endpoints started with v0.22, will take a certain amount of time and gets spread across different releases. We are trying to keep backwards compatibility as much as we can. However, there are certain breaking changes you need to be aware when upgrading from a release prior to v0.22.Migration status and a list of breaking changescan be found in theissue sectionof this repo.Getting StartedThese instructions will get you a copy of the project up and running on your local machine.PrerequisitesTo run dkb-robo on your system you needPythonmechanicalsoup- Stateful programmatic web browsing librarycookielib- library for Cookie handling for HTTP clientsBeautiful Soup- a Python library for pulling data out of HTML and XML files.Please make sure python and all the above modules had been installed successfully before you start any kind of testing.Installingvia Pypi>pipinstalldkb_robomanually for all usersdownload the archive and unpack itenter the directory and run the setup script>pythonsetup.pyinstallmanually for a single userdownload the archive and unpack itmove the "dkb_robo" subfolder into the directory your script is locatedSBOMA bill of materialof the packages coming along wihtdkb-robowill be automatically created during build process and stored inmy SBOM respositoryUsageyou need to import dkb-robo into your script>fromdkb_roboimportDKBRobocreate a new DKBRobo context handler and login to DKB portal>withDKBRobo(dkb_user=<loginusername>,dkb_password=<password>,tan_insert=True|False,legacy_login=True|False,mfa_device=<m|int>,debug=True|False)asdkb:dbk_user: username to access the dkb portaldkb_password: corresponding login passwordtan_insert: (True/False) TAN usage - dbk-robo will ask for a TAN (generated by either ChipTan or TAN2go) during loginlegacy_login: (True/False) optional - set to "True" to use the legacy DKB banking pagemfa_device: ('m'/Integer) optional (not supported in legacy mode) - preselect MFA device to be used for 2nd factor - 'm' - main device, otherwise number from device-listdebug: (True/False) Debug modeAfter login you can return thethe last login dateprint(dkb.last_login)14.03.2019,13:19Uhra dictionary containing a list of your accounts, the actual balance and a link to fetch the transactionsfrompprintimportpprintpprint(dkb.account_dic){0:{'amount':'1458.00','currencycode':'EUR','date':'22.01.2023','holdername':'Firstname Lastname','iban':'DEXXXXXXXXXXXXXXXXXXXXX','id':'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx','limit':'2500.00','name':'Girokonto','productgroup':'Meine Konten','transactions':'https://banking.dkb.de/api/accounts/accounts/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/transactions','type':'account'},1:{'amount':-1000.23,'currencycode':'EUR','date':'22.01.2023','holdername':'Firstname Lastname','id':'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx','limit':'2000.00','maskedpan':'1234XXXXXXXX5678','name':'Visa CC','productgroup':'Meine Konten','transactions':'https://banking.dkb.de/api/credit-card/cards/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/transactions','type':'creditcard'},2:{'amount':100000.23,'currencycode':'EUR','date':'22.01.2023','holdername':'Firstname lastname','id':'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx','limit':'0.00','maskedpan':'5678XXXXXXXX1234','name':'Another Visa','productgroup':'Meine Konten','transactions':'https://banking.dkb.de/api/credit-card/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/transactions','type':'creditcard'},3:{'amount':'123456,79','currencycode':'EUR','holdername':'Firstname Lastname','id':'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx','name':'Mein Depot','productgroup':'Meine Konten','transactions':'https://banking.dkb.de/api/broker/brokerage-accounts/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(positions?include=instrument%2Cquote','type':'depot'}}to get the list of transactions for a certain checking account or a credit card use the following methodtlist=dkb.get_transactions(link,type,date_from,date_to)link - link to get transactions for a specific account - see former step if you do not know how to get ittype - account type (either "account" or "creditcard") - see former step if you do not know how to get itdate_from - start date in European notation (DD.MM.YYYY)date_to - end date in European notation (DD.MM.YYYY)transaction_type - optional: "booked" (default if not specified) or "pending" ("vorgemerkt")this method returns a list of transactions.A list of transactions for a regular checking account follows the below format.frompprintimportpprintpprint(tlist)[{'amount':-44.98,'bdate':'2023-01-22','currencycode':'EUR','customerreferenz':'XXXXXX','peer':'PayPal Europe S.a.r.l. et Cie S.C.A','peeraccount':'XXXXXXXXX','peerbic':'XXXXXXXXX','peerid':'XXXXXXXXXXX','postingtext':'FOLGELASTSCHRIFT','reasonforpayment':'XXXXXX PP.XXXXX.PP . Foo-bar AG, Ihr Einkauf bei ''Foo-bar AG','vdate':'2023-01-22'},{'amount':-70.05,'bdate':'2023-01-22','currencycode':'EUR','customerreferenz':'68251782022947180823144926','peer':'FEFASE GmbH','peeraccount':'XXXXXXXXX','peerbic':'XXXXXXXXX','peerid':'XXXXXXXXX','postingtext':'SEPA-ELV-LASTSCHRIFT','reasonforpayment':'ELV68251782 18.08 14.49 MEFAS ','vdate':'2023-01-22'},{'amount':-7.49,'bdate':'2023-01-22','currencycode':'EUR','customerreferenz':'3REFeSERENC','peer':'PEER','peeraccount':'XXXXXXXXX','peerbic':'XXXXXXXXX','peerid':'XXXXXXXXX','postingtext':'FOLGELASTSCHRIFT','reasonforpayment':'VIELEN DANK VON BAR-FOO GMBH','vdate':'2023-01-22'}]The list of transactions from a creditcard will look as below:[{'amount':500.0,'bdate':'2023-08-18','currencycode':'EUR','text':'Berliner Sparkasse','vdate':'2023-08-18'},{'amount':125.95,'bdate':'2023-08-14','currencycode':'EUR','text':'Zara Deutschland 3742','vdate':'2023-08-14'},{'amount':500.0,'bdate':'2023-08-14','currencycode':'EUR','text':'Commerzbank Berlin','vdate':'2023-08-14'}]A brokerage account (depot) will not show the list of transactions but rather a list of positions:[{'currencycode':'EUR','isin_wkn':'DE0005140008','lastorderdate':'2017-01-01','market':'Frankfurt','price':9.872,'price_euro':'39488.00','quantity':4000.0,'shares_unit':'pieces','text':'DEUTSCHE BANK AG NA O.N.'},{'currencycode':'EUR','isin_wkn':'DE0005557508','lastorderdate':'2017-10-01','market':'Frankfurt','price':19.108,'price_euro':'28.662.00','quantity':1500.0,'shares_unit':'pieces','text':'DT.TELEKOM AG NA'}]to get the credit limits per account or credit-card the method get_credit_limits() must be used>c_list=dkb.get_credit_limits()This method returns a dictionary of all identified accounts including the credit limit per account{u'XXXX********XXXX':100.00,u'4748********XXXX':10000.00,u'XXXX********XXXX':10000.00,u'DEXX XXXX XXXX XXXX XXXX XX':200.00,u'DEXX XXXX XXXX XXXX XXXX XX':2000.00}A list of standing orders (Daueraufträge) can be obtained by calling get_standing_orders() method>so=dkb.get_standing_orders(account_id)account_id - 'id' field from account dictionary (dkb.account_dic[x]['id'])A list of standing orders will be returned containing a dictionary per standing order>pprint(so)[{'amount':30.0,'creditoraccount':{'bic':'BIC-1','iban':'IBAN-1'},'currencycode':'EUR','interval':{'frequency':'monthly','from':'2019-01-05','holidayExecutionStrategy':'following','nextExecutionAt':'2023-10-01','until':'2025-12-01'},'purpose':'Purpose-1','recpipient':'Recipient-1'},{'amount':58.0,'creditoraccount':{'bic':'BIC-2','iban':'IBAN-2'},'currencycode':'EUR','interval':{'frequency':'monthly','from':'2022-12-30','holidayExecutionStrategy':'following','nextExecutionAt':'2023-12-01'},'purpose':'Purpose-2','recpipient':'Recipient-2'},]The method get_exemption_order() can be used to get the exemption orders (Freistellungsaufträge)>exo=dkb.get_exemption_order()A dictionary similar to the one below will be returned>pprint(exo){1:{'amount':1602.0,'available':1602.0,'description':u'Gemeinsam mit XXXX XXXX','used':0.0,'validity':u'01.01.2017  unbefristet'}}To get the amount of dkb points the below method can be used>points_dic=dkb.get_points()A dictionary similar to the below will be returned>pprint(points_dic){u'DKB-Punkte':99999,u'davon verfallen zum  31.12.2018':999}To scan the DKB postbox for documents  the below method can be used>document_dic=dkb.scan_postbox(path,download_all,archive,prepend_date)path - optional argument. If specified, documents will be downloaded and storeddowload_all (True/False) - optional argument. By default only unread documents from DKB postbox will get downloaded and marked as "read". By setting this parameter all documents will be downloadedarchive (True/False) - optional argument. When set toTruethe "Archiv" folder in the Postbox will be scanned and documents will be downloaded if apathvariable is specificed.Handle this parameter with care as the amount of documents to be downloaded can be huge.prepend_date (True/False) - optional argument. Prepend document date inYYYY-MM-DD_format to each document to allow easy sorting of downloaded filesThe method will return a dictionary containing the different postbox folders and links to download the corresponding documentsCheck the scriptsdkb_example.pyanddkb_docdownload.pyfor further examples.dkb_robo command line interface (CLI)Starting with v0.20 dkb_robo comes with a CLI tool$dkb--help
Usage:dkb[OPTIONS]COMMAND[ARGS]...

Options:-d,--debugShowadditionaldebugging-t,--use-tandbk-robowillaskforaTAN(generatedbyeitherChipTanorTAN2go)duringlogin-u,--usernameTEXTusernametoaccessthedkbportal[required]-p,--passwordTEXTcorrespondingloginpassword--format[pprint|table|csv|json]outputformattouse--helpShowthismessageandexit.

Commands:accountscredit-limitslast-loginstanding-orderstransactionsExample command to fetch account listpydkb-u<user>-p<password>accountsExample commands to fetch transactions via CLI toolpydkb-u<user>-p<password>transactions--nameGirokonto
pydkb-u<user>-p<password>transactions--account"DE75xxxxxxxxxxxxxxxxxxx"pydkb-u<user>-p<password>transactions--account"DE75xxxxxxxxxxxxxxxxxxx"--date-from2023-08-01--date-to2023-08-15"Further documentationplease check thedocfolder of the project. You will find further documentation and an example scripts of all dkb-robo methods there.ContributingPlease readCONTRIBUTING.mdfor details on my code of conduct, and the process for submitting pull requests.
Please note that I have a life besides programming. Thus, expect a delay in answering.VersioningI useSemVerfor versioning. For the versions available, see thetags on this repository.LicenseThis project is licensed under the GPLv3 - see theLICENSE.mdfile for details