Справочные карточки
Отдаёт справочную карточку одной сущности.
Справочник написан на английском. Названия полей, примеры и коды ошибок на всех языках одинаковые.
Returns the encyclopedia card of one person, place, organization or thing: its name, a short label, a short description with the article it comes from, its website and key facts. The same card comes with page 1 of a web search as knowledge_panel; this endpoint is for a caller that wants only the card.
q is the name of the entity, at most 256 bytes and 200 characters; runs of spaces become one space. language is detected from q when it is not sent.
panel has title always, and type, description, description_url, description_site_name, website and attributes (at most 30 facts as {name: value}, in a stable order) when they are known. attribution lists the open data sets the card comes from; show it with the card, and link to description_url when you show the description. There is no image. When no entity matches, panel is absent and the warning is no_results.
What is charged
One knowledge unit when a card comes back. No card (warning no_results) is free, as is every error.
Units: knowledge. usage.items in the response lists them.
Request
POST https://api.websearch.fast/v1/web/knowledgeBody
| Name | Type | Description |
|---|---|---|
qrequired | string | The name of the entity, at most 200 characters. Runs of spaces become one space. 1 to 256 characters. |
language | string | BCP 47 language tag. Detected from q when absent. At most 12 characters. |
Example request
curl https://api.websearch.fast/v1/web/knowledge \
-H "Authorization: Bearer $WEBSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "Marie Curie"}'import os
import httpx
response = httpx.post(
"https://api.websearch.fast/v1/web/knowledge",
headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
json={
"q": "Marie Curie",
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch("https://api.websearch.fast/v1/web/knowledge", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
q: "Marie Curie",
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());Example response
{
"object": "web.knowledge",
"request_id": "20261128120000323456789a1b2c3d4Kx7Qm2Pa",
"created": 1795867200,
"input": {"q": "Marie Curie"},
"panel": {
"title": "Marie Curie",
"type": "Physicist",
"description": "Marie Curie was a Polish and naturalised French physicist and chemist.",
"description_url": "https://encyclopedia.example.org/wiki/Marie_Curie",
"description_site_name": "Example Encyclopedia",
"attributes": {
"Born": "7 November 1867, Warsaw",
"Died": "4 July 1934"
},
"attribution": [
{
"source": "Open encyclopedic data",
"url": "https://encyclopedia.example.org/wiki/Marie_Curie",
"license": "CC BY-SA 4.0"
}
]
},
"usage": {"charged": true, "items": [{"unit": "knowledge", "count": 1}]}
}Response fields
The card, or no panel with the warning no_results.
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
objectrequired | string | Always web.knowledge. | |||||||||||||||||||||||||||||||||||||||
request_idrequired | string | Same as the X-Request-Id header. | |||||||||||||||||||||||||||||||||||||||
createdrequired | integer | Unix seconds (UTC). | |||||||||||||||||||||||||||||||||||||||
inputrequired | object | The parameters as applied, defaults filled in. | |||||||||||||||||||||||||||||||||||||||
usagerequired | object | Show fields
| |||||||||||||||||||||||||||||||||||||||
warnings | array of object | Show fields
| |||||||||||||||||||||||||||||||||||||||
panel | object | An encyclopedia card from open data. In a search it comes only on page 1 of a search with results and is included in the search price.Show fields
|
Errors
| Status | Codes |
|---|---|
400 | invalid_request, invalid_url, invalid_schema or invalid_image. Not charged. |
401 | invalid_token. Not charged. |
403 | pre_consume_token_quota_failed (the key's own spending limit), access_denied, web_not_allowed or model_not_in_plan (customer keys while plans cannot include the web tools). Not charged. |
404 | not_found or invalid_endpoint. Not charged. |
413 | read_request_body_failed: the request body is over the limit. Not charged. |
429 | rate_limited, concurrency_limited, api_key_temporarily_frozen, or the failure guard. Not charged. |
500 | internal_error. Not charged. |
503 | source_unavailable, web_api_disabled, token_cache_busy or billing_busy (the charge could not be prepared in time; retry after Retry-After). Not charged. |
504 | timeout. Not charged. |