pyas2lib
raw JSON → 1.4.4 verified Mon Apr 27 auth: no python
Python library for building and parsing AS2 (Applicability Statement 2) messages. It supports encryption, signing, compression, and MDN (Message Disposition Notification). Current version 1.4.4, released occasionally.
pip install pyas2lib Common errors
error ModuleNotFoundError: No module named 'pyas2lib' ↓
cause Library not installed
fix
pip install pyas2lib
error ValueError: missing field 'receiver' ↓
cause Required argument not provided to AS2Message.build()
fix
Ensure sender, receiver, subject, content are all passed
Warnings
breaking Python 3.6 support dropped in v1.4.0 ↓
fix Use Python 3.7+
gotcha AS2Message requires all four fields (sender, receiver, subject, content) on build; missing one raises ValueError ↓
fix Always provide all keyword arguments
deprecated AS2Server is deprecated in favor of AS2Server from pyas2lib.as2 ↓
fix Use from pyas2lib.as2 import AS2Server
Imports
- AS2Message
from pyas2lib import AS2Message - AS2Mdn
from pyas2lib import AS2Mdn - AS2Server
from pyas2lib.as2 import AS2Server
Quickstart
from pyas2lib import AS2Message
# Build a message
msg = AS2Message()
msg.build(
sender='as2://sender@domain',
receiver='as2://receiver@domain',
subject='Test',
content=b'Hello AS2',
content_type='application/octet-stream',
sign=False,
encrypt=False,
compress=False,
)
signed_data = msg.to_bytes()
print(signed_data)