Skip to main content

x12sdk

Typed Pydantic v2 models and a streaming SDK/CLI for HIPAA ASC X12 5010 health care transactions.

License CI Python

x12sdk is the maintained continuation of LinuxForHealth x12, which stopped at 0.57.0 in June 2022. It runs on Pydantic v2 and Python 3.10–3.13.

Supported transaction sets:

Set Implementation What it is
837P 005010X222A2 Professional claim
837I 005010X223A3 Institutional claim
835 005010X221A1 Claim payment / remittance advice
834 005010X220A1 Benefit enrollment and maintenance
270 / 271 005010X279A1 Eligibility inquiry / response
276 / 277 005010X212 Claim status inquiry / response

Every transaction is parsed into a validated Pydantic model and can be serialized back to X12; the test suite asserts that round trip reproduces each sample file byte for byte.

Install

pip install x12sdk

From source:

git clone https://github.com/owgreen-dev/x12sdk
cd x12sdk
python3 -m venv .venv && source .venv/bin/activate
pip install --upgrade pip
pip install -e .

SDK

The x12sdk.io module streams either raw segments or validated transaction models from a file.

Stream segments (each segment becomes its name plus a list of fields):

from x12sdk.io import X12SegmentReader

with X12SegmentReader("/home/edi/270.x12") as r:
    for segment_name, segment_fields in r.segments():
        print(segment_name, segment_fields)

Stream models (the payload is validated; one model per transaction set):

from x12sdk.io import X12ModelReader

with X12ModelReader("/home/edi/270.x12") as r:
    for model in r.models():
        print(model.header)   # common attributes: header, footer
        print(model.footer)
        model.x12()           # serialize back to X12

CLI

x12sdk --help
usage: x12sdk [-h] [-s | -m] [-x] [-p] [-d] file

The x12sdk CLI parses and validates X12 messages.
Messages are returned in JSON format in either a segment or transactional format.

positional arguments:
  file              The path to a ASC X12 file

options:
  -h, --help        show this help message and exit
  -s, --segment     Returns X12 segments
  -m, --model       Returns X12 models
  -x, --exclude     Exclude fields set to None in model output
  -p, --pretty      Pretty print output
  -d, --delimiters  Include X12 delimiters in output (model mode only)
x12sdk -s -p demo-file/demo.270   # segments
x12sdk -m -p demo-file/demo.270   # models

Migrating from linuxforhealth-x12

before after
pip install linuxforhealth-x12 pip install x12sdk
from linuxforhealth.x12.io import X12ModelReader from x12sdk.io import X12ModelReader
lfhx12 -m -p file.x12 x12sdk -m -p file.x12
lfhx12-api (FastAPI endpoint) removed; wrap the SDK in your own service

See CHANGELOG.md for everything that changed.

Development

pip install -e ".[dev]"
ruff check src
pytest --cov

Contributions are welcome; see CONTRIBUTING.md (Apache-2.0, DCO sign-off, no copyrighted standards text, no real PHI). To add a transaction set, see repo-docs/NEW_TRANSACTION.md; the design is described in repo-docs/DESIGN.md.

x12sdk is a fork of LinuxForHealth x12 by Dixon Whitmire and the LinuxForHealth contributors (IBM), released under the Apache License 2.0. The models, parser, readers, and test corpus originate there; x12sdk exists to keep that work usable on current Python and Pydantic. The original LICENSE is retained, and attribution and trademark notes are in NOTICE and TRADEMARK.md. x12sdk is not affiliated with or endorsed by IBM, LinuxForHealth, or the Linux Foundation.

  • MdClarity/x12 — an independent fork by MD Clarity (Cary Lee) that completed a Pydantic v2 migration and added type checking and fuzzing in 2026. x12sdk's port is written separately from the 2022 upstream; their work is acknowledged here and their fixes are welcome upstream in x12sdk.
  • pyx12 — the long-standing Python X12 validator/converter (XML/dict output, map-driven). Choose pyx12 for validation against X12 maps; choose x12sdk for typed Python models.
  • edi-835-parser — a popular 835-only parser with pandas output.

License

Apache License 2.0. See LICENSE and NOTICE.

Release files for x12sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for x12sdk 1.0.0
File Size Uploaded
x12sdk-1.0.0.tar.gz 161.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for x12sdk 1.0.0
File Interpreter ABI Platform
x12sdk-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 341.8 kB

Release files / x12sdk-1.0.0.tar.gz

Download URL x12sdk-1.0.0.tar.gz
Size 161.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44e89b73b1a82d05297f69609992c7a47d13e10b69a8dbba5c35150e16c4e63f
BLAKE2b-256 checksum
How to use checksums
5af4c16725be898b2e52bbb3a182e239b269e3c8e887624df3d209e6e695cd35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release files / x12sdk-1.0.0-py3-none-any.whl

Download URL x12sdk-1.0.0-py3-none-any.whl
Size 180.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92e842bc63a8e7304d41c18b43717ec96ee8b9cf1bdd93f510cb581475d6d4c5
BLAKE2b-256 checksum
How to use checksums
bea09ef304ad0b879af022484a38d8a55f5b7a11f93b162288359a38f2be388b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

2.1.0

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page