Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A serializer and deserializer of ISO8583 data.

Project description


PyPI Documentation Status Test coverage

iso8583 module serializes and deserializes ISO8583 data between a bytes or bytearray instance containing ISO8583 data and a Python dict.

iso8583 supports custom specifications that can define field encoding (e.g. ASCII, EBCDIC, ISO8859-1, BCD, etc.), field types (e.g. fixed, LLVAR, LLLVAR, etc.), and maximum length


pip install pyiso8583

Decode iso8583 data received from a socket.

>>> import iso8583
>>> from iso8583.specs import default
>>> s = b'0200\x40\x10\x00\x00\x00\x00\x00\x00161234567890123456123456'
>>> doc_dec, doc_enc = iso8583.decode(s, spec=default)

Contents of the produced dictionaries.

>>> import pprint
>>> pprint.pp(doc_dec) # Decoded data
{'bm': {2, 12},
 't': '0200',
 'p': '4010000000000000',
 '2': '1234567890123456',
 '12': '123456'}
>>> pprint.pp(doc_enc) # Encoded data
{'bm': {2, 12},
 't': {'len': b'', 'data': b'0200'},
 'p': {'len': b'', 'data': b'@\x10\x00\x00\x00\x00\x00\x00'},
 '2': {'len': b'16', 'data': b'1234567890123456'},
 '12': {'len': b'', 'data': b'123456'}}

Pretty print result using iso8583.pp.

>>> iso8583.pp(doc_dec, spec=default) # Decoded data only
'bm'  Enabled Fields                      : [2, 12]
't'   Message Type                        : [0200]
'p'   Bitmap, Primary                     : [4010000000000000]
'2'   Primary Account Number (PAN)        : 16 [1234567890123456]
'12'  Time, Local Transaction             : [123456]

Add or remove fields.

>>> iso8583.del_field(doc_dec, '12') # Decoded data only
>>> doc_dec['t'] = '0210'
>>> iso8583.add_field(doc_dec, '39', '00')  # Decoded data only

Encode iso8583 data to send to a socket.

>>> s, doc_enc = iso8583.encode(doc_dec, spec=default)
>>> print(s)

For more info read the docs.


iso8583 is hosted on GitHub.

Feel free to fork and send contributions over.

Project details

Download files

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

Files for pyiso8583, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pyiso8583-1.0.1-py3-none-any.whl (13.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pyiso8583-1.0.1.tar.gz (12.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page