AI-generated Key Takeaways
-
The Google Knowledge Graph Search API lets you search for entities (people, places, things) using a variety of search parameters like keywords, IDs, and entity types.
-
The API returns structured data in JSON-LD format, following schema.org standards and Google extensions, providing detailed information about the matched entities.
-
You can refine searches using language filters, substring matching, and limiting the number of results for efficiency.
-
The response includes key entity details such as name, description, image, website URL, and a relevance score.
-
You are responsible for adhering to applicable laws, especially regarding the use of images returned by the API.
Searches Knowledge Graph for entities that match the constraints.
HTTP request
GET https://kgsearch.googleapis.com/v1/entities:search
Query parameters
Parameter name | Type | Description |
---|---|---|
query |
string |
A literal string to search for in the Knowledge Graph. |
ids |
string |
A list of entity IDs to search for in the Knowledge Graph. To specify multiple IDs in the HTTP request, repeat the parameter in the URL as in ...?ids=A&ids=B |
languages |
string |
The list of language codes (defined in ISO 639) to run the query with, for instance `en`. |
types |
string |
Restricts returned entities to those of the specified types. For example, you can specify `Person` (as defined in http://schema.org/Person) to restrict the results to entities representing people. If multiple types are specified, returned entities will contain one or more of these types. |
indent |
boolean |
Enables indenting of JSON results. |
prefix |
boolean |
Enables prefix (initial substring) match against names and aliases of entities. For example, a prefix `Jung` will match entities and aliases such as `Jung`, `Jungle`, and `Jung-ho Kang`. |
limit |
number |
Limits the number of entities to be returned. Maximum is 500. Default is 20. Requests with high limits have a higher chance of timing out. |
Request body
The request body must be empty.
Response body
A response message contains a list of entities, presented in JSON-LD format and compatible with schema.org schemas (with limited external extensions).
The following JSON-LD example shows how the response body is structured:
{
"@context": {
"@vocab": "http://schema.org/",
"goog": "http://schema.googleapis.com/",
"resultScore": "goog:resultScore",
"detailedDescription": "goog:detailedDescription",
"EntitySearchResult": "goog:EntitySearchResult",
"kg": "http://g.co/kg"
},
"@type": "ItemList",
"itemListElement": [
{
"@type": "EntitySearchResult",
"result": {
"@id": "kg:/m/0dl567",
"name": "Taylor Swift",
"@type": [
"Thing",
"Person"
],
"description": "Singer-songwriter",
"image": {
"contentUrl": "https://t1.gstatic.com/images?q=tbn:ANd9GcQmVDAhjhWnN2OWys2ZMO3PGAhupp5tN2LwF_BJmiHgi19hf8Ku",
"url": "https://en.wikipedia.org/wiki/Taylor_Swift",
"license": "http://creativecommons.org/licenses/by-sa/2.0"
},
"detailedDescription": {
"articleBody": "Taylor Alison Swift is an American singer-songwriter and actress. Raised in Wyomissing, Pennsylvania, she moved to Nashville, Tennessee, at the age of 14 to pursue a career in country music. ",
"url": "http://en.wikipedia.org/wiki/Taylor_Swift",
"license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
},
"url": "http://taylorswift.com/"
},
"resultScore": 4850
}
]
}
Response fields
Field name | Type | Description |
---|---|---|
@id |
string |
The canonical URI for the entity. |
name |
string |
The name of the entity. |
@type |
array |
The list of supported schema.org types that match the entity. |
description |
string |
A short description of the entity. |
image |
URL |
An image to help identify the entity. |
detailedDescription |
string |
A detailed description of the entity. |
url |
URL |
The official website URL of the entity, if available. |
resultScore |
number |
An indicator of how well the entity matched the request constraints. |
JSON-LD keywords
For JSON-LD keywords such as @context , @vocab, @type, or @id, refer to the JSON-LD spec.
Schema.org compatibility
The response uses the vocabulary hosted at
schema.org, with limited extensions (for
example, resultScore
) that are compatible with schema.org vocabulary.
For more details about these extensions, see
List of schema extensions.
For each of the Schema.org types (such as Person
) and properties (such as
name
) there is a corresponding full URI, as in the following examples:
- Person -> http://schema.org/Person
Thing -> http://schema.org/Thing
name -> http://schema.org/name
description -> http://schema.org/description
Types and properties defined as Google schema extensions can be expanded with http://schema.googleapis.com. For example,
- EntitySearchResult -> http://schema.googleapis.com/EntitySearchResult
- detailedDescription -> http://schema.googleapis.com/detailedDescription
The documentation for each type and property is available at the corresponding URI.
List of schema extensions
Schema extensions used in this API are hosted at http://schema.googleapis.com as external extensions.
The type extension to Schema.org is:
The property extensions to Schema.org are: