# Civic Transparency – Types
[](https://civic-interconnect.github.io/civic-transparency-types/)
[](https://pypi.org/project/civic-transparency-types/)
[](#)
[](https://github.com/civic-interconnect/civic-transparency-types/actions/workflows/ci.yml)
[](./LICENSE)
> **Typed Python models (Pydantic v2) for the Civic Transparency schema.**
> Maintained by [**Civic Interconnect**](https://github.com/civic-interconnect).
- **Docs (types):** https://civic-interconnect.github.io/civic-transparency-types/
- **Schemas & OpenAPI (spec):** https://civic-interconnect.github.io/civic-transparency-spec/
- **Contributing:** [CONTRIBUTING.md](./CONTRIBUTING.md)
---
## Install
```bash
pip install civic-transparency-types
```
> This package depends on `civic-transparency-spec` and uses its JSON Schemas to generate types.
---
## Quick Start
### Import canonical models
```python
from ci.transparency.types import Meta, Run, Scenario, Series, ProvenanceTag
```
Or import directly by module:
```python
from ci.transparency.types.series import Series
```
### Example: Build and validate a `Series`
```python
from ci.transparency.types import Series
series = Series(
topic="#CityElection2026",
generated_at="2026-02-07T00:00:00Z",
interval="minute",
points=[]
)
# Validate using Pydantic (raises if invalid)
series.model_validate(series.model_dump())
# Serialize to JSON-compatible dict
payload = series.model_dump()
print(payload)
```
### Example: Validate against the JSON Schema (optional)
To validate against the canonical Draft-07 schema:
```python
import json
from importlib.resources import files
from jsonschema import Draft7Validator
schema_text = files("ci.transparency.spec.schemas").joinpath("series.schema.json").read_text("utf-8")
series_schema = json.loads(schema_text)
Draft7Validator.check_schema(series_schema)
Draft7Validator(series_schema).validate(payload)
```
---
## Regenerating Types (for contributors)
Types are generated using [`datamodel-code-generator`](https://github.com/koxudaxi/datamodel-code-generator). To regenerate:
```bash
python scripts/generate_types.py
```
This rewrites `src/ci/transparency/types/*.py` and updates `__init__.py`.
---
## Versioning
- **SemVer**: Mirrors the version of the underlying schema in `civic-transparency-spec`.
- To ensure compatibility, pin both packages:
```bash
pip install "civic-transparency-types==0.1.*" "civic-transparency-spec==0.1.*"
```
---
## About
Civic Transparency is a shared data model for privacy-preserving, non-partisan insight into how content spreads online.
Raw data
{
"_id": null,
"home_page": null,
"name": "civic-transparency-types",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "civic, transparency, jsonschema, specification, types",
"author": "Civic Interconnect",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/86/f7/b2a943d17360589ba33808a14532521980f15ff0988c65cea259a5551367/civic_transparency_types-0.1.8.tar.gz",
"platform": null,
"description": "# Civic Transparency \u2013 Types\n\n[](https://civic-interconnect.github.io/civic-transparency-types/)\n[](https://pypi.org/project/civic-transparency-types/)\n[](#)\n[](https://github.com/civic-interconnect/civic-transparency-types/actions/workflows/ci.yml)\n[](./LICENSE)\n\n> **Typed Python models (Pydantic v2) for the Civic Transparency schema.**\n\n> Maintained by [**Civic Interconnect**](https://github.com/civic-interconnect).\n\n- **Docs (types):** https://civic-interconnect.github.io/civic-transparency-types/\n- **Schemas & OpenAPI (spec):** https://civic-interconnect.github.io/civic-transparency-spec/\n- **Contributing:** [CONTRIBUTING.md](./CONTRIBUTING.md)\n\n---\n\n## Install\n\n```bash\npip install civic-transparency-types\n```\n\n> This package depends on `civic-transparency-spec` and uses its JSON Schemas to generate types.\n\n---\n\n## Quick Start\n\n### Import canonical models\n\n```python\nfrom ci.transparency.types import Meta, Run, Scenario, Series, ProvenanceTag\n```\n\nOr import directly by module:\n\n```python\nfrom ci.transparency.types.series import Series\n```\n\n### Example: Build and validate a `Series`\n\n```python\nfrom ci.transparency.types import Series\n\nseries = Series(\n topic=\"#CityElection2026\",\n generated_at=\"2026-02-07T00:00:00Z\",\n interval=\"minute\",\n points=[]\n)\n\n# Validate using Pydantic (raises if invalid)\nseries.model_validate(series.model_dump())\n\n# Serialize to JSON-compatible dict\npayload = series.model_dump()\nprint(payload)\n```\n\n### Example: Validate against the JSON Schema (optional)\n\nTo validate against the canonical Draft-07 schema:\n\n```python\nimport json\nfrom importlib.resources import files\nfrom jsonschema import Draft7Validator\n\nschema_text = files(\"ci.transparency.spec.schemas\").joinpath(\"series.schema.json\").read_text(\"utf-8\")\nseries_schema = json.loads(schema_text)\n\nDraft7Validator.check_schema(series_schema)\nDraft7Validator(series_schema).validate(payload)\n```\n\n---\n\n## Regenerating Types (for contributors)\n\nTypes are generated using [`datamodel-code-generator`](https://github.com/koxudaxi/datamodel-code-generator). To regenerate:\n\n```bash\npython scripts/generate_types.py\n```\n\nThis rewrites `src/ci/transparency/types/*.py` and updates `__init__.py`.\n\n---\n\n## Versioning\n\n- **SemVer**: Mirrors the version of the underlying schema in `civic-transparency-spec`.\n- To ensure compatibility, pin both packages:\n\n```bash\npip install \"civic-transparency-types==0.1.*\" \"civic-transparency-spec==0.1.*\"\n```\n\n---\n\n## About\n\nCivic Transparency is a shared data model for privacy-preserving, non-partisan insight into how content spreads online.\n",
"bugtrack_url": null,
"license": null,
"summary": "Typed Python models (Pydantic v2) for the Civic Transparency specification",
"version": "0.1.8",
"project_urls": {
"Documentation": "https://civic-interconnect.github.io/civic-transparency-types/latest/",
"Homepage": "https://github.com/civic-interconnect/civic-transparency-types",
"Repository": "https://github.com/civic-interconnect/civic-transparency-types"
},
"split_keywords": [
"civic",
" transparency",
" jsonschema",
" specification",
" types"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5728a6397919f3abab2a082b3a5e351f05a77e37beb20ea93c07d4947bd74fbd",
"md5": "38645016c20bf7e63f15b04a702edf98",
"sha256": "72c2fb678b108625ead85843489f4ee1e47cc3a8adc910561f07513e1aa41e1c"
},
"downloads": -1,
"filename": "civic_transparency_types-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "38645016c20bf7e63f15b04a702edf98",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 24946,
"upload_time": "2025-08-15T02:09:49",
"upload_time_iso_8601": "2025-08-15T02:09:49.614198Z",
"url": "https://files.pythonhosted.org/packages/57/28/a6397919f3abab2a082b3a5e351f05a77e37beb20ea93c07d4947bd74fbd/civic_transparency_types-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "86f7b2a943d17360589ba33808a14532521980f15ff0988c65cea259a5551367",
"md5": "4eb77ae7fc8c45c435faf8157f0360cf",
"sha256": "ae8ebb0c4d564c49fa2513b692fae7d1b25978453aa0f7693518c30ea8a608cc"
},
"downloads": -1,
"filename": "civic_transparency_types-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "4eb77ae7fc8c45c435faf8157f0360cf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 23775,
"upload_time": "2025-08-15T02:09:50",
"upload_time_iso_8601": "2025-08-15T02:09:50.616762Z",
"url": "https://files.pythonhosted.org/packages/86/f7/b2a943d17360589ba33808a14532521980f15ff0988c65cea259a5551367/civic_transparency_types-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-15 02:09:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "civic-interconnect",
"github_project": "civic-transparency-types",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "civic-transparency-types"
}