← All documentation · Dashboard · REST API

Python SDK

Create contracts, validate payloads and monitor API data from Python. The SDK uses only the Python standard library and supports Python 3.9+.

Install

git clone https://github.com/ssitdeveloper/zorqelio-monetization.git
cd zorqelio-monetization/sdks/python
python -m pip install .

Authenticate

Create an account in the dashboard, then copy the one-time workspace API token into an environment variable. Use the workspace API token for long-running server integrations; account session tokens expire after 14 days.

export ZORQELIO_API_TOKEN="your-workspace-api-token"

Create a contract and validate a response

import os
from zorqelio import ZorqelioClient, ZorqelioError

client = ZorqelioClient(os.environ["ZORQELIO_API_TOKEN"])
contract = client.create_contract(
    "Orders API",
    {
        "type": "object",
        "required": ["id", "status"],
        "properties": {
            "id": {"type": "string"},
            "status": {"type": "string"},
        },
        "additionalProperties": False,
    },
)
contract_id = contract["contract"]["contractId"]
result = client.validate(contract_id, {"id": "ord_123", "status": "paid"})

if result["decision"] == "BLOCK":
    print(result["issues"])

Monitor an API endpoint

monitor = client.create_monitor(
    contract_id,
    "Orders production API",
    expected_interval_minutes=15,
    endpoint_url="https://api.example.com/orders/health",
)
print(monitor["monitor"])

Scheduled checks accept public HTTPS JSON endpoints. They do not currently support custom authentication headers or redirects. Omit endpoint_url to create a push monitor.

Available methods

Error handling

try:
    workspace = client.get_workspace()
except ZorqelioError as exc:
    print(exc.status_code, exc.code, str(exc))

ZorqelioError exposes the HTTP status, machine-readable error code and parsed response details. Network failures are also reported as this exception.

Security guidance