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 |
terms_accepted=Trueis required: it confirms you accepted the Buyer Master Agreement. Without it the SDK raisesValueErrorbefore calling the API.- You don't need to pass
terms_version: the SDK reads the current Buyer Master Agreement from the API (GET /api?action=trust_facts) when you order.licenses.current_terms_version()returns it, so you can show the buyer which agreement they are accepting. The API refuses any other version with409 NOT_CURRENT_VERSION. for_company=Trueon a subscription or Full download + training covers everyone signed in with your company's email domain (refused locally on a per-answer order).- Licences retired on 12 November 2026 are refused by the API.
- The SDK only checks that
licenceandbilling_modeare known values. The API checks the rest (which pairs are allowed, up to 500 publishers, 18 for per-request orders).
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:
"included": the full text is incontent_body(Full download + training orders)."retrieval_per_article": fetch the text withclient.content.get(article["id"])(subscriptions, within the daily reading limits: 20 full articles per person and 200 per order a day; past them it raisesOpeddRateLimitError, withbody["code"] == "DAILY_READING_LIMIT"andretry_after_secondsuntil the reset)."search_only": no text, andclient.content.get(...)answers403 SEARCH_ONLY_LICENCE. Per-request (pay per answer) orders read the content by asking questions withPOST /search.
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
discovery.publisher_directory(category=None, min_articles=None, verified=None, limit=None, offset=None): publishers with their licences, prices and sample articles.discovery.lookup_article(url=): whether an article can be licensed on Opedd.discovery.verify_license(key=): check a licence key.rsl.get(publisher_id=, jsonld=False): a publisher's RSL licence manifest;jsonld=Truereturns the signed JSON-LD version.onboarding.detect_platform(url=): which platform a publication runs on.
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
OpeddFeedLoader(access_key="ent_...")loads the articles your order covers as LangChainDocuments, with licensing details inmetadata. When the feed lists articles without their text (retrieval_per_article), passbuyer_token=orbuyer_email=and the loader fetches each article's text throughGET /content-delivery. Pay-per-answer rows (search_only) are skipped, since their content is read by asking questions. Passallow_discovery_only=Trueto load the listing without text.OpeddLookupTool,OpeddDirectoryToolandOpeddVerifyLicenseToolare public lookup tools for agents.OpeddContentTool(buyer_token="opedd_buyer_live_...")fetches the text of one licensed article.
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]