Python SDK

The official Python SDK for Opedd, for buyers: opedd on PyPI, current release 0.8.0.

The SDK calls the endpoints in the API reference as Python methods, with the same responses and credentials. Every method returns the API's JSON answer as a Python dict. For step-by-step flows see the AI buyer guide.


Install

pip install opedd

Requires Python 3.10 or later.

Package: pypi.org/project/opedd.


Credentials

Pass the credentials you have when you create the client. Each method uses the one its endpoint needs and raises OpeddAuthError if it is missing. Public methods need no credential.

Credential Argument Environment variable Used by
Buyer account sign-in token buyer_jwt= OPEDD_BUYER_JWT licenses.order, licenses.list, audit.events, compliance.*; also licenses.orders and licenses.get_order
Buyer token or buyer API key (opedd_buyer_live_…) buyer_token= OPEDD_BUYER_TOKEN content.get (with an API key, articles under any order your account holds); content.search (an API key with the search scope); feed.list and feed.stream_ndjson with order_id= (0.5.0); also licenses.orders and licenses.get_order (an API key needs the audit scope)
Access key (ent_…) access_key= OPEDD_ACCESS_KEY feed.list, feed.stream_ndjson (wins over a buyer API key when both are set)
none discovery.*, rsl.get, onboarding.detect_platform

Other arguments: base_url= (or OPEDD_BASE_URL, default https://api.opedd.com) and timeout= in seconds (default 60.0; feed.stream_ndjson always allows at least 300). The client can be used as a context manager (with Opedd(...) as client:).

from opedd import Opedd

client = Opedd(buyer_jwt="<your sign-in token>")

# or from environment variables
client = Opedd()

One buyer API key now covers search, articles and the feed. Alternatively, a buyer token for one order comes from POST /enterprise-auth in exchange for its access key. Opedd.from_access_key(access_key="ent_…", buyer_email="[email protected]") does that exchange and returns a client with both credentials set (fixed in 0.3.2).

Methods take keyword arguments, except content.get(article_id), content.search(query) and licenses.get_order(order_id).


Buy and track licences: client.licenses

licenses.order(licence=, billing_mode=, publisher_ids=, for_company=False, terms_accepted=False, terms_version=None) places a licence order (POST /enterprise-license) with your sign-in token.

licence billing_mode
"enterprise" "metered" AI answers, per article used in an answer
"enterprise" "monthly" Subscription: the whole catalogue while it is paid, within daily reading limits
"training" "one_time" Full download + training
print("You are accepting:", client.licenses.current_terms_version())

order = client.licenses.order(
    licence="enterprise",
    billing_mode="monthly",
    publisher_ids=["<publisher-uuid>", "<publisher-uuid>"],
    terms_accepted=True,
)
data = order["data"]
print("Pay at:", data["hosted_invoice_url"])
print("Access key (shown once):", data["access_key"])
for line in data["lines"]:
    print(line["publisher_name"], line["amount_cents"])
print("Left out:", data["unavailable"])

licenses.orders(cursor=None, limit=20) lists your orders with their lines (GET /buyer-orders); follow data["pagination"]["next_cursor"].

licenses.get_order(order_id) returns one order; each line carries its Schedule's text and SHA-256.

licenses.list() returns your buyer profile and masked API keys (GET /buyer-account).


Get content: client.feed and client.content

feed.list(since=None, cursor=None, limit=200, order_id=None) returns one page of the articles your order covers (GET /enterprise-license, JSON, up to 200).

feed.stream_ndjson(since=None, cursor=None, limit=5000, order_id=None) yields one article dict at a time from the bulk export, following _meta.next_cursor for you. The API sends at most 1,000 articles per request, so pass limit=1000; the SDK keeps paging either way.

since is an ISO-8601 time: only articles published after it, oldest first.

Every article carries content_access. Branch on it:

for article in client.feed.stream_ndjson(since="2026-09-01T00:00:00Z", limit=1000):
    if article["content_access"] == "included":
        store(article["content_body"], metadata=article)
    else:
        full = client.content.get(article["id"])
        store(full["content"], metadata=article)

content.get(article_id) returns one article's text and details (GET /content-delivery). Sandbox tokens get the first 500 characters.

content.search(query, publishers=None, published_after=None, published_before=None, max_results=None, max_charge_cents=None) asks a question across the publications you are licensed to search (POST /search, 3 to 1,000 characters) and returns passages, billing and filters. Pay per answer charges each article an answer uses, at its publication's price; publications covered by a subscription are included in it, not cut to 300 words (rights["basis"] == "subscription"). New accounts get their first 3 answers free. The filters only narrow: publishers (ids or publication names), a publication-date window (date, datetime or ISO-8601 strings; undated articles are left out when you set either bound) max_results from 1 to 10 (default 5), and max_charge_cents caps what one question may cost.


Records: client.audit and client.compliance

These use your sign-in token (buyer_jwt).

audit.events(from_=None, to=None, event_type=None, cursor=None, limit=100): every fetch of licensed content (GET /buyer-audit), up to 90 days per request.

compliance.report(from_=, to=, cursor=None): a compliance report (GET /buyer-compliance-report), up to 90 days per request. Each report is itself recorded; _meta.audit_event_id points to that record.

report = client.compliance.report(from_="2026-08-01", to="2026-08-31")
print(report["dossier_metadata"]["summary"])

See the compliance guide.


Public lookups

result = client.discovery.publisher_directory(category="finance", min_articles=5)
for pub in result["data"]["publishers"]:
    print(pub["name"], pub["licences"]["enterprise"]["prices"])

Errors

All errors inherit from OpeddError:

Exception Status
OpeddAuthError 401, 403, or a credential missing on the client
OpeddNotFoundError 404
OpeddValidationError 400, 422
OpeddRateLimitError 429; retry_after_seconds when the API gives it
OpeddServerError 5xx
OpeddError anything else

Each carries status_code, request_id and body. The SDK does not retry for you.

from opedd import OpeddError, OpeddRateLimitError
import time

try:
    article = client.content.get(article_id)
except OpeddRateLimitError as e:
    time.sleep(e.retry_after_seconds or 60)
except OpeddError as e:
    print(e, e.status_code, e.request_id)

LangChain integration

langchain-opedd (current release 0.1.4: stops cleanly at a subscription's daily reading limit) wraps this SDK for LangChain:

pip install langchain-opedd

Source: github.com/Opedd/langchain-opedd.


Versions

Pin the version in production (opedd==0.8.0). 0.8.0 orders the three licences (for_company added; retired licence options removed). 0.7.1 sends the access key in a header, never in the URL. Version 0.3.0 sends an old agreement version and its orders are refused: upgrade. New optional fields reach you without an SDK update; a change that renames or removes something ships as a new release.

Package and release history: pypi.org/project/opedd. See also the AI buyer guide, the compliance guide and the MCP server.

Questions: [email protected]