|
| 1 | +# Changelog |
| 2 | + |
| 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.1 (and includes everything in it). 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)`). |
| 41 | + |
| 42 | +### Added |
| 43 | + |
| 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`, |
| 77 | + `page_process_pattern`, `max_to_crawl_per_subdomain`, `max_to_process_per_subdomain`, |
| 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: |
| 82 | + `NlpField`, `NlpFormat`, `NlpCustomSummary`, `NlpResponse`. |
| 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). |
| 89 | + |
| 90 | +### Changed |
| 91 | + |
| 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. |
| 101 | + |
| 102 | +### Fixed |
| 103 | + |
| 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`. |
| 107 | +- `dql(format="csv")` and `dql(format="jsonl")` without `raw=True` crashed in |
| 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`. |
| 125 | +- `crawl_get_job` still returns `{}` for a missing job (the TypeScript SDK returns |
| 126 | + `undefined`). |
| 127 | +- No generic success-path response headers. |
| 128 | + |
| 129 | +### Migrating DQL: mocks and proxies |
| 130 | + |
| 131 | +Test mocks keyed on `GET` and `?query=` stop matching. Before/after: |
| 132 | + |
| 133 | +```python |
| 134 | +# before (3.1.x) |
| 135 | +def handler(request: httpx.Request) -> httpx.Response: |
| 136 | + assert request.method == "GET" |
| 137 | + assert request.url.params["query"] == "type:Organization" |
| 138 | + return httpx.Response(200, json={"data": []}) |
| 139 | + |
| 140 | +# after (3.4.0) |
| 141 | +def handler(request: httpx.Request) -> httpx.Response: |
| 142 | + assert request.method == "POST" |
| 143 | + assert json.loads(request.content)["query"] == "type:Organization" |
| 144 | + return httpx.Response(200, json={"data": []}) |
| 145 | +``` |
| 146 | + |
| 147 | +GET-only proxies, caches, or a custom `dql_url` mirror may reject or not cache |
| 148 | +POSTs. If you need the old wire format, use the low-level call (no new API): |
| 149 | + |
| 150 | +```python |
| 151 | +db.request("GET", db.dql_url, params={"token": db.token, "query": q, "size": 10}) |
| 152 | +``` |
| 153 | + |
| 154 | +or pin `diffbot<3.4` (3.1.x). |
0 commit comments