11# Changelog
22
3- ## 3.4.0 (unreleased)
4-
5- Named options on endpoints the SDK already calls, plus ` nlp() ` and two ontology
6- helpers. Additive, except that invalid ` snippet_length ` values now raise (see
7- Changed). The package version in ` pyproject.toml ` is bumped at release time.
3+ All notable changes to the ` diffbot ` Python package are documented here. The format
4+ follows [ Keep a Changelog] ( https://keepachangelog.com/en/1.1.0/ ) , and the project uses
5+ [ Semantic Versioning] ( https://semver.org/ ) .
6+
7+ ## [ 3.4.0] - 2026-11-17
8+
9+ First release since 3.1.x. It rolls up three development lines that were never
10+ published on their own: the shared transport, sync/async de-duplication and DQL over
11+ POST (planned as 3.2.0), response types plus ` account ` /` verify_token ` /` crawl_download ` /
12+ extract options (3.3.0), and named options on existing endpoints plus ` nlp() ` (3.4.0).
13+ No new Diffbot API areas are added.
14+
15+ ### ⚠ Breaking changes
16+
17+ - ** DQL is sent as ` POST ` with a JSON body.** ` dql() ` , ` dql_parallel() ` and their async
18+ twins keep the same signature and results, but mocks, proxies, or mirrors keyed on
19+ ` GET ` + ` ?query= ` stop matching. See [ Migrating DQL] ( #migrating-dql-mocks-and-proxies )
20+ below.
21+ - ** ` crawl() ` raises ` APIError ` when the create call answers HTTP 200 with
22+ ` errorCode ` /` error ` ** (for example errorCode 505, job name over 30 characters). It used
23+ to yield ` JOB_CREATED ` for a job that was never created. The error keeps the real
24+ status (200), body, and headers.
25+ - ** A ` Retry-After ` above ` RetryPolicy.max_delay ` (default 5.0 s) is no longer waited
26+ out or retried.** The call raises at once: ` RateLimitError ` with ` retry_after ` = raw
27+ header, or ` APIError ` with ` headers["retry-after"] ` for a 5xx (sync, async, and
28+ streamed). Raise ` max_delay ` to keep waiting.
29+ - ** Requests are now retried by default** (` 429 ` , ` 5xx ` , connection errors; 3 attempts
30+ with backoff and jitter). ` crawl_delete_job ` is never retried. Pass ` retry=False ` for
31+ the old single-attempt behavior.
32+ - ** ` web_search(snippet_length=...) ` is validated:** anything other than ` short ` ,
33+ ` medium ` , ` long ` , ` full ` (case-insensitive) raises ` ValidationError ` instead of being
34+ sent upstream.
35+ - ** ` dql() ` raises ` ValidationError ` when ` extra ` repeats one of the new named options**
36+ (` type ` , ` col ` , ` filter_exclude ` , ...).
37+ - ** Type-level:** ` dql ` , ` extract ` , ` web_search ` , ` entities ` , ` crawl_list_jobs ` ,
38+ ` crawl_get_job ` return ` TypedDict ` s instead of ` Dict[str, Any] ` , and several methods
39+ gained ` @overload ` s. Runtime values are unchanged; a type checker may flag undeclared
40+ keys (escape hatch: ` typing.cast(Dict[str, Any], resp) ` ).
841
942### Added
1043
11- - ` dql() ` /` dql_async() ` (and so ` dql_parallel ` ) keyword-only options ` type `
12- (` "query" ` , ` "text" ` , ` "queryTextFallback" ` , ` "crawl" ` ; ` "crawl" ` searches crawl
13- collections), ` col ` , ` filter_exclude ` , ` exportseparator ` , ` exportfile ` ,
14- ` jsonmode ` , ` non_canonical_facts ` , ` no_dedup_articles ` , ` cluster ` . They go in the
15- POST JSON body (wire names ` filterExclude ` , ` nonCanonicalFacts ` ,
16- ` noDedupArticles ` ); the token stays in the query string. Passing the same key as a
17- named option and in ` extra ` raises ` ValidationError ` . ` report ` and ` view ` are not
18- named; use ` extra ` . ` size ` still defaults to 10. Types: ` DqlType ` , ` DqlJsonMode ` ,
19- ` DqlCluster ` , ` DqlOptions ` .
20- - ` crawl() ` keyword-only create options ` url_crawl_regex ` , ` url_process_regex ` ,
44+ - ** Transport:** per-host base URLs (` api_base ` , ` kg_base ` , ` llm_base ` , ` nlp_base ` on
45+ ` Diffbot ` and ` DiffbotAsync ` ; the older ` *_url ` options still win when both are set);
46+ documented repeated query params; ` client.request(method, url, ...) ` with ` DELETE ` ,
47+ form (` data= ` ) and raw (` content= ` ) bodies, a per-call ` timeout ` , and a
48+ ` follow_redirects ` override; the ` RetryPolicy ` dataclass and ` retry ` option with
49+ per-call ` retryable=False ` .
50+ - ** Errors:** ` NotFoundError ` (404) and ` JobError ` , both subclasses of ` APIError ` ;
51+ ` APIError.headers ` from the error response.
52+ - ** Types:** request aliases (` ChatMessage ` , ` ResponseFormat ` , ` ExportFormat ` ,
53+ ` SnippetLength ` ) and response ` TypedDict ` s exported from ` diffbot ` (` DqlResponse ` /
54+ ` DqlEntity ` , ` WebSearchResponse ` /` WebSearchResult ` , ` EntitiesResponse ` ,
55+ ` ExtractResponse ` and per-API variants, ` CrawlJob ` , ` CrawlDataRecord ` ,
56+ ` AccountResponse ` , ` AskChunk ` , ...). stdlib only, Python 3.9-compatible, no Pydantic.
57+ - ` account(days=None) ` and ` verify_token() ` (sync and async) over ` GET /v4/account ` .
58+ ` verify_token() ` returns ` False ` only on an auth failure. The account response carries
59+ ` token ` and ` childTokens ` ; don't log it whole.
60+ - ` crawl_download(name, *, format="json", type=None, num=None) ` (sync and async) over
61+ ` GET /v3/crawl/data ` . ` format="csv" ` or ` type="urls" ` returns ` str ` , otherwise a list
62+ of records; a non-list JSON body (e.g. unknown job) raises ` JobError ` . The crawl
63+ watcher uses it. For tools that can't block: ` crawl(..., watch=False) ` ->
64+ ` crawl_get_job ` -> ` crawl_download ` .
65+ - ` extract() ` keyword-only options: ` timeout ` (server-side ms, default 30000), ` mode ` ,
66+ ` fields ` (per-API ` Literal ` names), ` fallback ` , ` discussion ` , ` paging ` , ` max_pages ` ,
67+ ` natural_language ` , ` summary_num_sentences ` , ` max_tags ` , ` tag_confidence ` ,
68+ ` category_confidence ` , ` use_proxy ` , and ` extra ` (` proxy ` /` proxyAuth ` ; collisions with a
69+ named option or ` token ` /` url ` raise ` ValidationError ` ). Setting ` timeout ` raises the
70+ per-call transport timeout to at least ` timeout + 10s ` .
71+ - ` dql() ` /` dql_async() ` (and ` dql_parallel ` ) keyword-only options ` type ` (` "query" ` ,
72+ ` "text" ` , ` "queryTextFallback" ` , ` "crawl" ` ), ` col ` , ` filter_exclude ` ,
73+ ` exportseparator ` , ` exportfile ` , ` jsonmode ` , ` non_canonical_facts ` ,
74+ ` no_dedup_articles ` , ` cluster ` , sent in the POST body. ` report ` and ` view ` stay
75+ reachable via ` extra ` . Types: ` DqlType ` , ` DqlJsonMode ` , ` DqlCluster ` , ` DqlOptions ` .
76+ - ` crawl() ` create options ` url_crawl_regex ` , ` url_process_regex ` ,
2177 ` page_process_pattern ` , ` max_to_crawl_per_subdomain ` , ` max_to_process_per_subdomain ` ,
22- ` use_canonical ` , ` notify_webhook ` , ` notify_email ` (query params on the existing
23- GET). ` custom_headers ` now accepts a string or a sequence of strings (sent as
24- repeated ` customHeaders ` params). Recurring-crawl admin (` repeat ` , ` maxRounds ` , ...)
25- is not exposed.
26- - ` nlp(text, *, fields, lang, format, document_type, custom_summary) ` (sync and
27- async) on the existing NL endpoint, single document. ` fields ` is a sequence of
28- ` NlpField ` ; ` format ` may be ` "plain text with title" ` ;
29- ` custom_summary={"max_number_of_sentences": n} ` . ` entities() ` is unchanged. Types:
78+ ` use_canonical ` , ` notify_webhook ` , ` notify_email ` ; ` custom_headers ` accepts a string or
79+ a sequence (repeated params). The 30-character job-name limit is documented.
80+ - ` nlp(text, *, fields, lang, format, document_type, custom_summary) ` (sync and async) on
81+ the existing NL endpoint, single document. ` entities() ` is unchanged. Types:
3082 ` NlpField ` , ` NlpFormat ` , ` NlpCustomSummary ` , ` NlpResponse ` .
31- - ` web_search(text=...) ` accepts a string or 1-5 strings (repeated ` text= ` params on
32- the existing GET). Out -of-range lengths raise ` ValidationError ` before any request.
33- - ` dql_fetch_ontology_text() ` (sync and async) returns the raw ontology JSON text;
34- ` dql_refresh_ontology ` is now also available on ` DiffbotAsync ` (module function
35- ` diffbot.kg.dql_refresh_ontology_async ` ). ` dql_fetch_ontology() ` reuses the text fetch.
36- - Live suite: ` web_search ` (single and two-value ` text ` ) and ` entities ` + ` nlp ` .
83+ - ` web_search(text=...) ` accepts a string or 1-5 strings (repeated ` text= ` );
84+ out -of-range lengths raise ` ValidationError ` before any request.
85+ - ` dql_fetch_ontology_text() ` (sync and async); ` dql_refresh_ontology ` on
86+ ` DiffbotAsync ` (module function ` diffbot.kg.dql_refresh_ontology_async ` ).
87+ - Dev: ` pyright ` gate (basic on ` src/ ` , strict on ` types.py ` , plus ` tests/typing ` ) in CI;
88+ live test workflow (push to ` main ` , manual dispatch, twice-monthly cron; never on PRs) .
3789
3890### Changed
3991
40- - ** ` Retry-After ` now has a ceiling** (parity with the TypeScript SDK).
41- ` RetryPolicy.max_delay ` (default 5.0 s) used to cap only the exponential backoff, so a
42- 429/5xx with ` Retry-After: 3600 ` made one call sleep an hour. Now, if ` Retry-After `
43- (seconds or HTTP-date form) exceeds ` max_delay ` , the SDK neither sleeps nor retries
44- and raises at once: ` RateLimitError ` with ` retry_after ` set, or ` APIError ` with the
45- header in ` headers ` for a 5xx. Sync, async, and streamed requests all behave this
46- way. A ` Retry-After ` at or under the cap is honored as before; a non-finite value
47- (` inf ` , ` nan ` ) now falls back to backoff (` inf ` used to crash ` time.sleep ` ). Raise
48- ` max_delay ` to keep waiting out longer server-requested delays.
49- - ** ` web_search(snippet_length=...) ` is validated** (parity with the TypeScript SDK):
50- the value is case-insensitive and must be one of ` short ` , ` medium ` , ` long ` , ` full ` ;
51- anything else raises ` ValidationError ` instead of being sent upstream. Breaking only
52- for invalid input. ` snippet_length ` and ` rerank ` are undocumented upstream and
53- labelled so in the docstrings.
54-
55- ## 3.3.0 (unreleased)
56-
57- Response types, a pyright gate, and two small methods that complete existing
58- workflows. Additive minor: no wire changes. The package version in
59- ` pyproject.toml ` is bumped at release time.
60-
61- ### Added
62-
63- - Response ` TypedDict ` s (stdlib, ` total=False ` , no Pydantic, Python 3.9-compatible),
64- exported from ` diffbot ` : ` DqlResponse ` /` DqlEntity ` , ` WebSearchResponse ` /
65- ` WebSearchResult ` , ` EntitiesResponse ` , ` ExtractResponse ` and per-API
66- ` ArticleExtractResponse ` , ` ProductExtractResponse ` , ... with their object types,
67- ` CrawlJob ` , ` CrawlDataRecord ` , ` AccountResponse ` , ` AskChunk ` .
68- - ` account(days=None) ` and ` verify_token() ` (sync and async): ` GET /v4/account ` .
69- ` verify_token() ` calls it with ` days=1 ` ; only an auth failure (401/403) returns
70- ` False ` , every other error propagates. The account response carries ` token ` and
71- ` childTokens ` : don't log it whole.
72- - ` crawl_download(name, *, format="json", type=None, num=None) ` (sync and async):
73- ` GET /v3/crawl/data ` . ` format="csv" ` or ` type="urls" ` (that report is always CSV)
74- returns ` str ` , otherwise a list of records; a JSON body that is not a list (e.g. an
75- unknown job) raises ` JobError ` . The crawl watcher now uses it. For tools that can't block, the recommended
76- pattern is ` crawl(..., watch=False) ` -> ` crawl_get_job ` -> ` crawl_download ` .
77- - ` extract() ` keyword-only options after ` fmt ` : ` timeout ` (server-side fetch timeout
78- in ms, default still 30000), ` mode ` (overrides the ` fmt="markdown" ` -> ` llm `
79- mapping), ` fields ` (sequence, comma-joined; per-API ` Literal ` names), ` fallback ` ,
80- ` discussion ` , ` paging ` , ` max_pages ` , ` natural_language ` , ` summary_num_sentences ` ,
81- ` max_tags ` , ` tag_confidence ` , ` category_confidence ` , ` use_proxy ` , and ` extra `
82- for anything else (` proxy ` /` proxyAuth ` ; keys that collide with a named option or
83- ` token ` /` url ` raise ` ValidationError ` ). When you set ` timeout ` , the per-call
84- transport timeout is raised to at least ` timeout + 10s ` (never lowered).
85- - Dev: ` pyright ` (basic on ` src/ ` , strict on ` types.py ` ) plus ` tests/typing `
86- ` assert_type ` checks, run in ` tests.yml ` .
92+ - ` dql() ` request shape: ` POST {dql_url}?token=… ` with `{"query", "size", "from"?,
93+ "format"?, "filter"?, "exportspec"?, …extra}`. The token stays in the query string;
94+ the query text no longer appears in URLs, and the URL length limit is gone. ` extra ` is
95+ typed ` Mapping[str, Any] ` and its values go into the JSON body verbatim.
96+ - A failed crawl job raises ` JobError ` (carrying the job name) instead of a synthesized
97+ ` APIError(500, ...) ` . ` JobError ` subclasses ` APIError ` , so ` except APIError ` still
98+ catches it.
99+ - Internal: shared sync/async transport helpers in ` _transport.py ` replace the
100+ per-handler ` _http.get(...) ` + raise pattern.
87101
88102### Fixed
89103
104+ - ` ask() ` /` ask_json() ` (sync and async): a non-2xx response while streaming raises
105+ ` AuthError ` /` RateLimitError ` /` APIError ` as documented instead of
106+ ` httpx.ResponseNotRead ` .
90107- ` dql(format="csv") ` and ` dql(format="jsonl") ` without ` raw=True ` crashed in
91- ` response.json() ` . ` csv ` now returns ` str ` , ` xls ` /` xlsx ` return ` bytes ` , and
92- ` jsonl ` returns an iterator of entities (` AsyncIterator ` from the async client).
93- ` raw=True ` is unchanged (undecoded ` bytes ` ).
94- - ` crawl() ` create failures that the crawler reports as HTTP 200 with ` errorCode ` /
95- ` error ` in the body (e.g. errorCode 505 for a job name over 30 characters, which
96- creates nothing) now raise ` APIError ` (status 200, the real body and headers,
97- ` message ` from ` error ` ) instead of yielding ` JOB_CREATED ` for a job that doesn't exist.
98-
99- ### Changed (type-level only)
100-
101- - Return annotations changed from ` Dict[str, Any] ` to the TypedDicts above
102- (` dql ` , ` extract ` , ` web_search ` , ` entities ` , ` crawl_list_jobs ` , ` crawl_get_job ` ),
103- and ` dql ` /` extract ` /` crawl_download ` gained ` @overload ` s. Runtime values are
104- unchanged. A type checker may now flag keys the types don't declare; wrap the
105- value in ` typing.cast(Dict[str, Any], resp) ` as the escape hatch. ` dql_parallel `
106- returns ` List[Any] ` (each element's type follows its own call).
108+ ` response.json() ` . ` csv ` now returns ` str ` , ` xls ` /` xlsx ` return ` bytes ` , and ` jsonl `
109+ returns an iterator of entities (` AsyncIterator ` on the async client).
110+ - ` crawl() ` no longer reports ` JOB_CREATED ` for a create that failed with HTTP 200 +
111+ ` errorCode ` .
112+ - ` APIError.message ` falls back to the body's ` error ` field (the ` {errorCode, error} `
113+ shape), matching the TypeScript SDK.
114+ - ` Retry-After: inf ` no longer crashes ` time.sleep ` with ` OverflowError ` ; non-finite
115+ values fall back to backoff.
116+
117+ ### Known limitations
118+
119+ - ` extra ` can still override the pre-existing DQL keys (` size ` , ` from ` , ` format ` ,
120+ ` filter ` , ` exportspec ` ); only the new named keys are collision-checked.
121+ - ` crawl() ` has no ` extra ` ; recurring-crawl admin (` repeat ` , ` maxRounds ` , ...) is not
122+ exposed. ` Diffbot.crawl(**kwargs) ` does not type-check the new create options.
123+ - ` nlp() ` returns one ` NlpResponse ` ` TypedDict ` (all fields optional), not a per-` fields `
124+ type. ` custom_summary ` reads only the Python key ` max_number_of_sentences ` .
107125- ` crawl_get_job ` still returns ` {} ` for a missing job (the TypeScript SDK returns
108- ` undefined ` ); unchanged on purpose.
109-
110- ## 3.2.0 (unreleased)
111-
112- Shared transport foundation, a sync/async de-duplication refactor, and DQL sent
113- as a POST. The package version in ` pyproject.toml ` is bumped at release time.
114-
115- ### Changed
126+ ` undefined ` ).
127+ - No generic success-path response headers.
116128
117- - ** DQL is now sent as ` POST ` with a JSON body.** ` dql() ` , ` dql_parallel() ` and
118- their async twins keep the same names, options, defaults and return values;
119- only the wire format changes: ` POST {dql_url}?token=… ` with
120- ` {"query", "size", "from"?, "format"?, "filter"?, "exportspec"?, …extra} ` .
121- The token stays in the query string; the query text no longer appears in the
122- URL, and the URL-length limit on long queries is gone. ` extra ` is now typed
123- ` Mapping[str, Any] ` (values go into the JSON body verbatim).
124- - ` crawl() ` failure now raises ` JobError ` (carrying the job name) instead of a
125- synthesized ` APIError(500, ...) ` . ` JobError ` subclasses ` APIError ` .
126-
127- #### Migration note: mocks and proxies
129+ ### Migrating DQL: mocks and proxies
128130
129131Test mocks keyed on ` GET ` and ` ?query= ` stop matching. Before/after:
130132
@@ -135,7 +137,7 @@ def handler(request: httpx.Request) -> httpx.Response:
135137 assert request.url.params[" query" ] == " type:Organization"
136138 return httpx.Response(200 , json = {" data" : []})
137139
138- # after (3.2 .0)
140+ # after (3.4 .0)
139141def handler (request : httpx.Request) -> httpx.Response:
140142 assert request.method == " POST"
141143 assert json.loads(request.content)[" query" ] == " type:Organization"
@@ -149,51 +151,4 @@ POSTs. If you need the old wire format, use the low-level call (no new API):
149151db.request(" GET" , db.dql_url, params = {" token" : db.token, " query" : q, " size" : 10 })
150152```
151153
152- or pin ` diffbot<3.2 ` .
153-
154- ### Added
155-
156- - Per-host base URL options: ` api_base ` , ` kg_base ` , ` llm_base ` , ` nlp_base ` on
157- both ` Diffbot ` and ` DiffbotAsync ` . The older per-endpoint options
158- (` analyze_url ` , ` crawler_url ` , ` llm_url ` , ` web_search_url ` , ` nlp_url ` ,
159- ` dql_url ` , ` ontology_url ` ) still work and win over the matching base when
160- both are set.
161- - Repeated query parameters: handler param builders now declare
162- ` Sequence ` -valued params explicitly (httpx already encoded them as repeated
163- keys; this makes it a documented, tested capability).
164- - ` client.request(method, url, ...) ` on both clients: ` DELETE ` + arbitrary
165- method/body/` Content-Type ` , form-encoded (` data= ` ) and raw (` content= ` )
166- bodies, a per-call ` timeout ` override separate from the client default, and
167- a ` follow_redirects ` override.
168- - A default-on retry policy (` RetryPolicy ` dataclass, ` retry ` client option)
169- for ` 429 ` /` 5xx ` /connection errors, with backoff, jitter, and ` Retry-After `
170- support, capped at 3 attempts by default. Disable with ` retry=False ` , or
171- opt a single call out with ` retryable=False ` (used internally by
172- ` crawl_delete_job ` /` crawl_delete_job_async ` , a GET-shaped mutation that must
173- never be retried blindly).
174- - ` NotFoundError ` (404) and ` JobError ` , both subclassing ` APIError ` so
175- existing ` except APIError ` call sites are unaffected.
176- - ` APIError.headers ` (and subclasses), populated from the error response.
177- - Additive ` TypedDict ` /` Literal ` type aliases in ` diffbot.types ` :
178- ` ChatMessage ` , ` ResponseFormat ` , ` ExportFormat ` , ` SnippetLength ` — used in
179- ` ask() ` /` ask_json() ` /` dql() ` /` web_search() ` signatures. No Pydantic, no
180- runtime behavior change.
181-
182- ### Fixed
183-
184- - ` ask() ` /` ask_json() ` (sync and async): a non-2xx response (e.g. 401, 429)
185- while streaming now raises ` AuthError ` /` RateLimitError ` as documented,
186- instead of ` httpx.ResponseNotRead ` . The error body is now read before
187- raising.
188- - ` crawl() ` 's job-failure path now raises ` JobError ` (carrying the job name)
189- instead of a synthesized ` APIError(500, ...) ` .
190- - ` APIError.message ` falls back to the body's ` error ` field when there is no
191- ` message ` (the ` {errorCode, error} ` shape several Diffbot APIs use), matching
192- the TypeScript SDK.
193-
194- ### Internal
195-
196- - Sync/async de-duplication: ` Diffbot ` /` DiffbotAsync._raise_for_status ` and
197- the repeated ` client._http.get(...) ` + raise pattern in every handler
198- module are replaced by shared helpers in a new ` _transport.py ` , used by
199- both clients through ` client.request() ` .
154+ or pin ` diffbot<3.4 ` (3.1.x).
0 commit comments