Repository navigation
v3.5.0: knowledge parameter and knowledge result models
Minor release. Adds support for the new knowledge parameter on
POST /v1/search and the knowledge result models that come back with it, and
closes two documented response fields the SDK had been dropping. Purely
additive — no breaking changes.
Added
knowledgeparameter onsearch()andsearch_async()— pass
knowledge="core"to request knowledge results backed by licensed data
providers such as encyclopedias, market-data firms, and reference publishers.
They arrive in their own section atresponse.results.knowledge."core"is
the only value the API accepts, and anything else raisesValidationError
locally rather than reaching the network, mirroring the server's422.Knowledgeenum —Knowledge.CORE, exported fromyoudotcom.models.
Plain strings are accepted and normalized, soknowledge="core"and
knowledge="CORE"both work.KnowledgeResultandKnowledgeAttributionmodels — a knowledge result
carriestype,title, andattribution, plusdescriptionand an optional
as_ofdate fortype: answerresults, the only kind returned today.type
is modeled as a plainstrso an unrecognized kind parses instead of raising,
since a new kind may populate a different set of fields. Attribution entries
are credits rather than citations and carry no URL.Results.knowledge— new optional field on the search response container.
Up to 25 results are returned, limited to those relevant to the query. When
none are relevant the API omits the key entirely, so the field isNone
rather than an empty list and iterating needs anor []guard.countcaps
the web and news sections, not knowledge.
Fixed
AnswerSearchResultwas droppingdescriptionandthumbnail_url— the
answer spec defines both onresults.web[]and the API returns them on every
result, but the model did not declare them, so they were discarded at parse
time. Both are now optionalstrfields.WebResulton the search endpoint
already had them; the answer model was simply the narrower of the two.FinanceResearchSourcewas missingsnippets— the finance-research spec
defines it onoutput.sources[], and the siblingSourcemodel on the
Research API already declared it. Production was not returning the field at
the time of this release, so nothing was being lost yet, but the model now
matches the published contract instead of relying on a drift-checker
suppression that could not have noticed the API starting to send it.docs/models/researchresponse.mdnever documentedwarnings— the field
exists onResearchResponseand has always parsed correctly; only the docs
page was missing its row.
Changed
scripts/check_drift.pyrecurses nested response schemas — the response
check previously compared top-level fields only, so drift inside a nested
object went undetected. Recursion surfaced the two gaps above, which are now
closed by adding the fields rather than suppressed, soKNOWN_RESPONSE_GAPS
is empty. It and its mirrorKNOWN_SHARED_MODEL_EXTRASboth report an entry
as stale once the side they excuse catches up, instead of quietly keeping it.scripts/check_drift.pyrecursion hardened —visitedwas a global
"already compared this model" cache, so a model reused at two response paths
backed by different schemas was compared only at the first and drift on later
branches went unreported. It is now a recursion stack, discarded on exit, so
cycles still terminate without suppressing sibling branches. The staleness
check also intersected only with the SDK's fields, which reported a field the
spec dropped as stale — contradicting the comment above it — and now requires
the spec to still define the field. Both were found in review, and both are
covered bytests/test_check_drift.py, the first test coverage that script has
had.scripts/audit_wire.py(new) — walks the raw JSON from a live call next to
the parsed model and reports any key the model discarded.check_drift.py
compares the published specs against the models, which cannot see a field the
API returns but no spec declares; that is howAnswerSearchResultcame to drop
descriptionandthumbnail_urlunnoticed. NeedsYDC_API_KEY, so it is a
pre-release check rather than a CI gate. Two keys are recorded in
KNOWN_WIRE_EXTRASas observed-but-undeclared rather than modeled:
results.web[].original_thumbnail_url, and finance-research's top-level
warnings, which the sibling research spec does declare.
Full changelog: https://github.com/youdotcom-oss/youdotcom-python-sdk/blob/v3.5.0/CHANGELOG.md