Skip to main content

DataGraphs Python Client

Python client library for DataGraphs.

Installation

uv add pydatagraphs

or

pip install pydatagraphs

Quick starts

from datagraphs import Client

# Connect to a project
client = Client(
    project_name="my-project",
    api_key="your-api-key",
)

# Check the API is reachable
print(client.status())

# Retrieve all entities of a given type
products = client.get("Product")

# Query one page, or page through every result
results = client.query(q="Acme", page_size=50)
page = client.query_page(filters="territory:GB")  # results, total_results, next_page_token
everything = client.query_all(filters="territory:GB")

Every read returns complete results or raises, so an empty list always means there was nothing to read. A failed request raises HttpStatusError (with its status_code and errors), a transport failure such as a timeout raises DatagraphsError, and a paged read whose pages do not add up to the reported total raises IncompleteReadError. Reads retry transient failures (HTTP 429, 502, 503 and 504, connection errors and timeouts) up to max_read_retries times (default 3) before raising. Every request, including the auth token request, times out after timeout seconds (default (10, 60): connect, read).

from datagraphs import Client

# Connect to a project
client = Client(
    project_name="my-project",
    api_key="your-api-key",
    client_id="your-client-id",
    client_secret="your-client-secret"
)

# Read the project schema and dataset configurations
schema = client.get_schema()
datasets = client.get_datasets()

# Update the project schema and dataset configurations
client.apply_schema(schema)
client.apply_datasets(datasets)
import json
from datagraphs import Client, Gateway, Schema, Dataset

# Connect to a project
client = Client(
    project_name="my-project",
    api_key="your-api-key",
    client_id="your-client-id",
    client_secret="your-client-secret"
)
gateway = Gateway(client)

# Load / dump data via the Gateway
dumped = gateway.dump_data("./backup")
if not dumped.ok:
    # Classes not exported: dumped.failed holds the error for each. No file is
    # written for a failed class.
    raise SystemExit(1)
result = gateway.load_data(from_dir_path="./backup")
# A batch with an invalid entity is rejected whole: the entities in it are then
# resubmitted in halves to find the rejected ones (isolation=ISOLATION_MODE.BISECT,
# the default), one at a time (INDIVIDUAL), or not at all (NONE).
if not result.ok:
    # Entities not written, per class: result.failed holds a FailedWrite (id, HTTP
    # status, errors) for each. result.timed_out holds the ids of writes that hit a
    # 504 and may still have completed: verify them with a read, or reload them.
    raise SystemExit(1)

# Load / dump project via the Gateway
schema_output_path = "./schemas/"
datasets_output_path = "./datasets/"
gateway.dump_project(schema_output_path, datasets_output_path)

with open("./schemas/myproject-model-v1.0.json") as f:
    schema_data = json.load(f)
with open("./datasets/myproject-datasets-v1.0.json") as f:
    datasets_data = json.load(f)
schema = Schema.create_from(schema_data)
datasets = [Dataset.create_from(d) for d in datasets_data]
gateway.load_project(schema, datasets)

For full API documentation, please see here

Authentication

For read-only access, an API key is sufficient. For write operations, supply OAuth credentials as well:

client = Client(
    project_name="my-project",
    api_key="your-api-key",
    client_id="your-client-id",
    client_secret="your-client-secret",
)

Key classes

Class Description
Client HTTP client for the DataGraphs REST API
Gateway Higher-level wrapper class for deploying projects and bulk export/load of data
Schema In-memory representation of a project's domain model
Dataset Represents a dataset within a project

Development

Install uv, then:

uv sync                                          # create virtualenv & install deps
uv run pytest tests -v                            # unit tests
uv run pytest tests_integration -v                # integration tests
uv run pytest tests -v --capture=tee-sys          # capturing stdout/stderr
uv run pytest --cov=src --cov-report=html         # coverage report
uvx ruff check .                                  # lint

License

MIT — Copyright (c) 2026 Data Language

Metadata

Release files for pydatagraphs 0.14.1

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

Source distribution (sdist)

Source distribution for pydatagraphs 0.14.1
File Size Uploaded Provenance Actions
pydatagraphs-0.14.1.tar.gz 73.7 kB With provenance Details for pydatagraphs-0.14.1.tar.gz

Built distribution (wheel)

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

Total release size: 152.3 kB

Release files / pydatagraphs-0.14.1.tar.gz

Download URL pydatagraphs-0.14.1.tar.gz
Size 73.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0623e3d3e87c56fd9539f3f5a6a3900104c7f90d3f498416b79cabdab84cf876
BLAKE2b-256 checksum
How to use checksums
e4ce65a272012ad5c4551a8c7f091bb2fd2f6b7750d5a72e16fb6441e3a6e4c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / pydatagraphs-0.14.1-py3-none-any.whl

Download URL pydatagraphs-0.14.1-py3-none-any.whl
Size 78.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb3a7f1fe8c458da77c6db7cd427ec97012b1ad5c73e32d281d827e95c0a696f
BLAKE2b-256 checksum
How to use checksums
b41396c9ec094ed3c946c77815d12d3669998583505615018811fb0152bd4504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Security for pydatagraphs 0.14.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydatagraphs-0.14.1.tar.gz

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 Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.14.1 This release

2 release files Full provenance

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