---
title: "datacontract-specification | pypx"
description: "The Pydantic Model of the Data Contract Specification"
canonical_url: "https://pypx.app/packages/datacontract-specification"
meta:
  "og:description": "The Pydantic Model of the Data Contract Specification"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_datacontract-specification%2Cversion_1.2.3%2Csummary_The%2BPydantic%2BModel%2Bof%2Bthe%2BData%2BContract%2BSpecification%2Clicense_MIT%2BLicense%2Cp_Ii9wYWNrYWdlcy9kYXRhY29udHJhY3Qtc3BlY2lmaWNhdGlvbiI%2Cs_AYxL_zm8flDxybP2.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "datacontract-specification 1.2.3"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_datacontract-specification%2Cversion_1.2.3%2Csummary_The%2BPydantic%2BModel%2Bof%2Bthe%2BData%2BContract%2BSpecification%2Clicense_MIT%2BLicense%2Cp_Ii9wYWNrYWdlcy9kYXRhY29udHJhY3Qtc3BlY2lmaWNhdGlvbiI%2Cs_AYxL_zm8flDxybP2.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **datacontract-specification**

v1.2.3

The Pydantic Model of the Data Contract Specification

15 KB Python 3.10+ py3-none-anyMIT License2 deps

[** Diff **](https://pypx.app/packages/datacontract-specification/diff)

`$ uv add datacontract-specification`

# Data Contract Specification (Python)

The pip module `datacontract-specification` to read and write YAML files using the [Data Contract Specification](https://datacontract.com). The pip module was extracted from the [Data Contract CLI](https://github.com/datacontract/datacontract-cli), which is its primary user.

The version number of the pip module corresponds to the version of the Data Contract Specification it supports.

## Version Mapping

| Data Contract Specification Version | Pip Module Version |
| --- | --- |
| 1.2.0 | >=1.2.0 |
| 1.1.0 | >=1.1.0 |

**Note**: We mirror major and minor version from the Data Contract Specification to the pip module, but not the patch version!

## Installation

```
pip install datacontract-specification
```

## Usage

```
from datacontract_specification.model import DataContractSpecification

# Load a data contract specification from a file
data_contract = DataContractSpecification.from_file('path/to/your/data_contract.yaml')
# Print the data contract specification as a YAML string
print(data_contract.to_yaml())
```

```
from datacontract_specification.model import DataContractSpecification

# Load a data contract specification from a string
data_contract_str = """
dataContractSpecification: 1.2.0
id: urn:datacontract:checkout:orders-latest
info:
  title: Orders Latest
  version: 2.0.0
  description: |
    Successful customer orders in the webshop.
    All orders since 2020-01-01.
    Orders with their line items are in their current state (no history included).
  owner: Checkout Team
  status: active
  contact:
    name: John Doe (Data Product Owner)
    url: https://teams.microsoft.com/l/channel/example/checkout
"""
data_contract = DataContractSpecification.from_string(data_contract_str)
# Print the data contract specification as a YAML string
print(data_contract.to_yaml())
```

## Development

```
uv sync --all-extras
```

## Release

- Change version number in `pyproject.toml`
- Run `./release` in your command line
- Wait for the releases on [GitHub](https://github.com/datacontract/datacontract-specification-python/releases), [PyPi](https://test.pypi.org/project/datacontract-specification/) and [PyPi (test)](https://test.pypi.org/project/datacontract-specification/)

## **Details **

<dl>

<dt>Version</dt>
<dd>1.2.3</dd>

<dt>License</dt>
<dd>MIT License</dd>

<dt>Python</dt>
<dd>&gt;=3.10</dd>

<dt>Maintainer</dt>
<dd>Jochen Christ &lt;jochen.christ@innoq.com&gt;, Stefan Negele &lt;stefan.negele@innoq.com&gt;, Simon Harrer &lt;simon.harrer@innoq.com&gt;</dd></dl>

## **Links**

- [Homepage](https://github.com/datacontract/datacontract-specification-python)
- [Issues](https://github.com/datacontract/datacontract-specification-python/issues)
- [View on PyPI](https://pypi.org/project/datacontract-specification/)

## **Maintainers **

- Jochen Christ · [jochen.christ@innoq.com](mailto:jochen.christ@innoq.com)
- Stefan Negele · [stefan.negele@innoq.com](mailto:stefan.negele@innoq.com)
- Simon Harrer · [simon.harrer@innoq.com](mailto:simon.harrer@innoq.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/datacontract-specification#webpage","@type":"WebPage","description":"The Pydantic Model of the Data Contract Specification","name":"datacontract-specification","url":"https://pypx.app/packages/datacontract-specification","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/datacontract-specification"]}]},{"@id":"https://pypx.app/packages/datacontract-specification#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"The Pydantic Model of the Data Contract Specification","license":"MIT License","name":"datacontract-specification","softwareVersion":"1.2.3"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
