joonis Logo

Documentation ebics.client

EBICS client module of the Python EBICS package.

This module defines the main EBICS client class.

class ebics.client.EbicsClient(keys, passphrase, url, hostid, partnerid, userid, systemid=None, keyversion='A006', version='H004')

Main EBICS client class.

Initializes the EBICS client instance.

Parameters:
  • keys – The path to a key file or a dictionary of keys. If the key file does not exist or the dictionary is empty, new keys (2048 bit) will be created.
  • passphrase – The passphrase by which all keys will be encrypted/decrypted.
  • url – The URL of the EBICS server.
  • hostid – The HostID of the bank.
  • partnerid – The assigned PartnerID (Kunden-ID).
  • userid – The assigned UserID (Teilnehmer-ID).
  • systemid – The assigned SystemID (usually unused).
  • keyversion – The key version of the electronic signature. Supported versions are A005 and A006 (default).
  • version – EBICS protocol version. At time the only supported version is 2.5 (H004).
C52(start=None, end=None, parsed=False)

Downloads Bank to Customer Account Reports (camt.52)

Parameters:
  • start – The start date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • end – The end date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • parsed – Flag if the received XML documents should be parsed and returned as objectified lxml objects or not. See the lxml.objectify API for further details.
Returns:

A dictionary of either raw or objectified XML documents.

C53(start=None, end=None, parsed=False)

Downloads Bank to Customer Statements (camt.53)

Parameters:
  • start – The start date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • end – The end date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • parsed – Flag if the received XML documents should be parsed and returned as objectified lxml objects or not. See the lxml.objectify API for further details.
Returns:

A dictionary of either raw or objectified XML documents.

C54(start=None, end=None, parsed=False)

Downloads Bank to Customer Debit Credit Notifications (camt.54)

Parameters:
  • start – The start date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • end – The end date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • parsed – Flag if the received XML documents should be parsed and returned as objectified lxml objects or not. See the lxml.objectify API for further details.
Returns:

A dictionary of either raw or objectified XML documents.

CCT(document)

Uploads a SEPA Credit Transfer document.

Parameters:document – The SEPA document to be uploaded either as a raw XML string or a ebics.sepa.SEPACreditTransfer object.
Returns:The id of the uploaded order (OrderID).
CD1(document)

Uploads a SEPA Direct Debit document of type COR1.

Parameters:document – The SEPA document to be uploaded either as a raw XML string or a ebics.sepa.SEPADirectDebit object.
Returns:The id of the uploaded order (OrderID).
CDB(document)

Uploads a SEPA Direct Debit document of type B2B.

Parameters:document – The SEPA document to be uploaded either as a raw XML string or a ebics.sepa.SEPADirectDebit object.
Returns:The id of the uploaded order (OrderID).
CDD(document)

Uploads a SEPA Direct Debit document of type CORE.

Parameters:document – The SEPA document to be uploaded either as a raw XML string or a ebics.sepa.SEPADirectDebit object.
Returns:The id of the uploaded order (OrderID).
CDZ(parsed=False)

Downloads Payment Status Report for Direct Debits.

Parameters:parsed – Flag if the received XML documents should be parsed and returned as objectified lxml objects or not. See the lxml.objectify API for further details.
Returns:A dictionary of either raw or objectified XML documents.
CRZ(parsed=False)

Downloads Payment Status Report for Credit Transfers.

Parameters:parsed – Flag if the received XML documents should be parsed and returned as objectified lxml objects or not. See the lxml.objectify API for further details.
Returns:A dictionary of either raw or objectified XML documents.
HAA(parsed=False)

Downloads the available order types.

Parameters:parsed – Flag if the received XML document should be parsed and returned as an objectified lxml object or not. See the lxml.objectify API for further details.
Returns:Either the raw or objectified XML document.
HAC(start=None, end=None, parsed=False)

Downloads the customer usage report in XML format.

Parameters:
  • start – The start date of requested processes. Can be a date object or an ISO8601 formatted string.
  • end – The end date of requested processes. Can be a date object or an ISO8601 formatted string.
  • parsed – Flag if the received XML document should be parsed and returned as an objectified lxml object or not. See the lxml.objectify API for further details.
Returns:

Either the raw or objectified XML document.

HEV()

Returns a dictionary of supported protocol versions.

HIA()

Sends the public authentication (X002) and encryption (E002) keys.

HKD(parsed=False)

Downloads the customer properties and settings.

Parameters:parsed – Flag if the received XML document should be parsed and returned as an objectified lxml object or not. See the lxml.objectify API for further details.
Returns:Either the raw or objectified XML document.
HPB()

Receives the public bank keys X002 and E002.

The keys are added to the key file and must be activated by calling the method activate_bank_keys.

Returns:The string representation of the keys.
HPD(parsed=False)

Downloads the available bank parameters.

Parameters:parsed – Flag if the received XML document should be parsed and returned as an objectified lxml object or not. See the lxml.objectify API for further details.
Returns:Either the raw or objectified XML document.
HTD(parsed=False)

Downloads the user properties and settings.

Parameters:parsed – Flag if the received XML document should be parsed and returned as an objectified lxml object or not. See the lxml.objectify API for further details.
Returns:Either the raw or objectified XML document.
INI()

Sends the public key of the electronic signature.

PTK(start=None, end=None)

Downloads the customer usage report in text format.

Parameters:
  • start – The start date of requested processes. Can be a date object or an ISO8601 formatted string.
  • end – The end date of requested processes. Can be a date object or an ISO8601 formatted string.
Returns:

The customer usage report.

SPR()

Locks the EBICS access of the current user.

STA(start=None, end=None, parsed=False)

Downloads the bank account statement in SWIFT format (MT940).

Parameters:
  • start – The start date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • end – The end date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • parsed – Flag if the received MT940 message should be parsed and returned as a dictionary or not. See function ebics.swift.parse_mt940().
Returns:

Either the raw data of the MT940 SWIFT message or the parsed message as dictionary.

VMK(start=None, end=None, parsed=False)

Downloads the interim transaction report in SWIFT format (MT942).

Parameters:
  • start – The start date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • end – The end date of requested transactions. Can be a date object or an ISO8601 formatted string.
  • parsed – Flag if the received MT942 message should be parsed and returned as a dictionary or not. See function ebics.swift.parse_mt940().
Returns:

Either the raw data of the MT942 SWIFT message or the parsed message as dictionary.

activate_bank_keys()

Activates the bank keys downloaded via HPB.

change_passphrase(passphrase)

Changes the passphrase by which all keys are encrypted. All available keys are updated and saved.

Parameters:passphrase – The new passphrase.
confirm_download(trans_id=None, success=True)

Confirms the receipt of a previously executed download.

It is usually used to mark received data, so that it is not included in further downloads.

Parameters:
  • trans_id – The transaction id of the download. If omitted or None, the transaction id of the last EBICS download is used (see last_trans_id).
  • success – Informs the EBICS server if the downloaded data was successfully processed or not.
create_ini_letter(bankname, path=None)

Creates the INI-letter as PDF.

Parameters:
  • bankname – The name of the bank which is printed on the INI-letter as the recipient.
  • path – The destination path of the created PDF file. If path is omitted or None the PDF is not saved.
Returns:

The PDF data as byte string if path is None.

download(order_type, params=None)

Performs an arbitrary EBICS download request.

Parameters:
  • order_type – The id of the desired order type.
  • params – A list of parameters that are added to the StandardOrderParams node. Each parameter must be a 2-tuple in the form of (dom_path, value).
Returns:

The downloaded data. The returned transaction id is stored in the attribute last_trans_id.

hostid

The HostID of the bank (read-only).

keyfile

The path to the key file (read-only).

last_trans_id

This attribute stores the transaction id of the last download process (read-only).

partnerid

The PartnerID of the EBICS account (read-only).

save_keys(path=None)

Saves all keys to the file specified by path.

Parameters:path – The path of the key file. If path is omitted or None, the path of the current key file is used.
systemid

The SystemID of the EBICS account (read-only).

upload(order_type, data, params=None)

Performs an arbitrary EBICS upload request.

Parameters:
  • order_type – The id of the desired order type.
  • data – The data to be uploaded.
  • params – A list of parameters that are added to the StandardOrderParams node. Each parameter must be a 2-tuple in the form of (dom_path, value).
Returns:

The id of the uploaded order if applicable.

url

The URL of the EBICS server (read-only).

userid

The UserID of the EBICS account (read-only).

version

The EBICS protocol version (read-only).

exception ebics.client.EbicsVerificationError

EBICS response could not be verified.

exception ebics.client.EbicsTechnicalError(code, message=None)

EBICS request returned a technical error.

exception ebics.client.EbicsFunctionalError(code, message=None)

EBICS request returned a functional error.

Examples

Initializing the EBICS account

from ebics.client import EbicsClient

client = EbicsClient(
    keys='~/mykeys',
    passphrase='secret',
    url='https://www.mybank.de/ebics',
    hostid='MYBANK',
    partnerid='CUSTOMER123',
    userid='USER1',
    )
# Send the public electronic signature key to the bank.
client.INI()
# Send the public authentication and encryption keys to the bank.
client.HIA()

# Create an INI letter which must be printed and sent to the bank.
client.create_ini_letter('MyBank AG', '~/ini_brief.pdf')

# After the account has been activated the public bank keys
# must be downloaded and checked for consistency.
print client.HPB()

# Finally the bank keys must be activated.
client.activate_bank_keys()

Download Bank to Customer Statements (camt.53)

from ebics.client import EbicsClient

client = EbicsClient(
    keys='~/mykeys',
    passphrase='secret',
    url='https://www.mybank.de/ebics',
    hostid='MYBANK',
    partnerid='CUSTOMER123',
    userid='USER1',
    )
# Download camt.53 documents
docs = client.C53('2014-02-01', '2014-02-07')
# Print all received documents
for name, xml in docs.items():
    print xml
# Print the transaction id for this download process
print client.last_trans_id

Can I
  help you?


Just drop me a line at
giraffe@joonis.de