saprfclib - Pure Python SAP RFC Protocol Implementation
saprfclib is a pure-Python reimplementation of the SAP RFC wire protocol - zero
native/C dependencies. Call any SAP function module from Python with just a pip install.
Supports direct TCP, SAProuter, message server (load-balanced), SNC (X.509/Kerberos),
and WebSocket RFC (SAP BTP/cloud) connections. Requires Python 3.12 or later.
No SAP NetWeaver RFC SDK. No C compiler. No LD_LIBRARY_PATH. No container image built
around a proprietary .so.
Installation
pip install saprfclib
Pulls two pure-Python dependencies (wsproto and h11)
Quick Start
import saprfclib
conn = saprfclib.connect(
ashost="your-sap-host", # Application server hostname or IP
sysnr=0, # System number (port = 3300 + sysnr)
client="100", # SAP client (Mandant)
user="RFC_USER", # SAP logon user
passwd="secret", # Password (never logged by saprfclib)
)
result = conn.call("STFC_CONNECTION", REQUTEXT="Hello from saprfclib!")
print(result["ECHOTEXT"]) # "Hello from saprfclib!"
print(result["RESPTEXT"]) # SAP server response text
conn.close()
conn.call() fetches function module metadata from DDIC on the first call and caches
it in-process - no configuration needed.
Connection Options
| Mode | Key Parameters |
|---|---|
| Direct TCP | ashost, sysnr |
| SAProuter | ashost, sysnr, saprouter="/H/router/S/3299/H/target" |
| Message server | mshost, sysid, group |
| SNC (X.509 / Kerberos) | snc_lib, snc_partnername, snc_qop |
| WebSocket RFC | wshost, wsport, ws_path |
See the Connection Options guide for the full parameter reference.
Documentation
Full documentation: https://randomstr1ng.github.io/saprfclib/
- Getting Started - install, connect, and make your first call in 10 minutes
- Cookbook - TABLE parameters, RFC server, tRFC/qRFC, connection pool, SNC, WebSocket RFC
- API Reference - auto-generated from typed docstrings via MkDocs + mkdocstrings
- Protocol Docs - NI/CPIC framing, ABAP type serialization, RFC handshake, SNC, tRFC/bgRFC wire specs
Example Scripts
The examples/ directory contains runnable scripts for common patterns:
| Script | Pattern |
|---|---|
examples/01_connect_and_call.py |
Basic connect → call → close |
examples/02_table_params.py |
RFC_READ_TABLE with TABLE parameters |
examples/03_connection_pool.py |
Multi-threaded connection pool |
examples/04_trfc_submit.py |
tRFC / qRFC lifecycle |
examples/05_rfc_server.py |
RFC server with handler |
examples/06_snc_connection.py |
SNC X.509 connection |
examples/07_websocket_rfc.py |
WebSocket RFC to SAP BTP |
All examples read connection parameters from SAPRFC_* environment variables.
Development
git clone https://github.com/randomstr1ng/saprfclib
cd saprfclib
pip install -e ".[dev]"
# Run offline test suite (no live SAP needed)
hatch run test -m "not integration"
# Lint and format
hatch run lint:check
hatch run lint:fmt
# Type-check
hatch run lint:type
# Build wheel + sdist
hatch build
Live integration tests require a running SAP system. Set environment variables:
export SAPRFC_ASHOST=your-sap-host
export SAPRFC_SYSNR=0
export SAPRFC_CLIENT=100
export SAPRFC_USER=RFC_USER
export SAPRFC_PASSWD=secret
pytest -m integration
See CONTRIBUTING.md for the full contributor guide, and CLAUDE.md for the protocol-fidelity rules every change must follow.
License
Licensed under the Mozilla Public License 2.0 - see LICENSE.
MPL-2.0 is deliberate: you may use saprfclib inside a closed-source, commercial
product with no obligation to release your own code. If you modify saprfclib's own
source files, those modified files must remain under MPL-2.0 and be made available.
Improvements to the library flow back; your product stays yours.
Trademarks and Affiliation
This project is not affiliated with, endorsed by, or supported by SAP SE. SAP,
ABAP, SAP NetWeaver, SAProuter, and SAP S/4HANA are trademarks or registered
trademarks of SAP SE in Germany and other countries, used here for identification
only. saprfclib contains no SAP code, binaries, or headers. Using it does not grant
you any licence to SAP software - you remain responsible for your own SAP licensing.
See NOTICE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saprfclib-0.1.2.tar.gz.
File metadata
- Download URL: saprfclib-0.1.2.tar.gz
- Upload date:
- Size: 414.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
857162e9b4dbc81b779016730165e7287cca338467437b6cf9355fc0e6e76d59
|
|
| MD5 |
2dc5dce3352cf8811547d1f10fa28618
|
|
| BLAKE2b-256 |
8092df60a29dfa6e77689c46dd47b42f42e56a706e4cac8cd3e67e529e57bbcb
|
Provenance
The following attestation bundles were made for saprfclib-0.1.2.tar.gz:
Publisher:
publish.yml on randomstr1ng/saprfclib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
saprfclib-0.1.2.tar.gz -
Subject digest:
857162e9b4dbc81b779016730165e7287cca338467437b6cf9355fc0e6e76d59 - Sigstore transparency entry: 2625993902
- Sigstore integration time:
-
Permalink:
randomstr1ng/saprfclib@f1930d42c923b24dcfaa57ed6b29605797c21c8e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/randomstr1ng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1930d42c923b24dcfaa57ed6b29605797c21c8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file saprfclib-0.1.2-py3-none-any.whl.
File metadata
- Download URL: saprfclib-0.1.2-py3-none-any.whl
- Upload date:
- Size: 190.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54956c86b41aac18e4bf5d2a463bd623af7a862b8bcbface1eec112d5ccaad96
|
|
| MD5 |
f089b21faf26424fd59394367a7f7def
|
|
| BLAKE2b-256 |
5b18cf7ef5dcac44c035aa50329323a784ea2e9361deb48cc659d48e9c0e5d85
|
Provenance
The following attestation bundles were made for saprfclib-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on randomstr1ng/saprfclib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
saprfclib-0.1.2-py3-none-any.whl -
Subject digest:
54956c86b41aac18e4bf5d2a463bd623af7a862b8bcbface1eec112d5ccaad96 - Sigstore transparency entry: 2625993909
- Sigstore integration time:
-
Permalink:
randomstr1ng/saprfclib@f1930d42c923b24dcfaa57ed6b29605797c21c8e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/randomstr1ng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1930d42c923b24dcfaa57ed6b29605797c21c8e -
Trigger Event:
push
-
Statement type: