Skip to main content
The Knowledge Graph Search API lets you look up structured information about real-world entities — people, places, organizations, works of art, and more — directly from Google’s Knowledge Graph. Unlike the Custom Search JSON API, which returns a list of web pages, the Knowledge Graph API returns rich, machine-readable entity records: canonical names, descriptions, images, types, and Wikipedia-sourced article bodies. Use it to power entity disambiguation, auto-complete suggestions, knowledge panels, or fact-checking features in your application.
The Knowledge Graph Search API is a separate product from the Custom Search JSON API. It has its own endpoint, its own quota, and must be enabled independently in Google Cloud Console. The same API key works for both, provided you enable both APIs in your project.

Enable the Knowledge Graph Search API

Before you make your first request, enable the API in your Google Cloud project.
1

Open Google Cloud Console

Go to the Google Cloud Console and select the project you use for your Custom Search API key.
2

Navigate to the API Library

In the left-hand navigation, click APIs & Services → Library. Search for Knowledge Graph Search API.
3

Enable the API

Click the Knowledge Graph Search API card, then click Enable. Wait for the confirmation banner.
4

Confirm your API key has access

If your API key has API restrictions applied, go to APIs & Services → Credentials, click your key, and add Knowledge Graph Search API to its allowed APIs list.

Endpoint

All Knowledge Graph requests use a single endpoint with the GET method:
Authentication is via an API key passed as the key query parameter — the same mechanism as the Custom Search API.

Request Parameters

string
required
Your Google Cloud API key. Always include this parameter.
string
A free-text search query to find matching entities. Use this to search by name or description. Either query or ids must be present.
string
One or more Knowledge Graph entity IDs (e.g., kg:/m/04wgh), separated by commas. Use this when you already know the entity ID and want to retrieve its full record directly. Either query or ids must be present.
string
A comma-separated list of BCP-47 language codes that restrict which language versions of entity descriptions are returned (e.g., en, fr, de). Defaults to English if omitted.
string
A comma-separated list of schema.org entity types to filter results. Only entities whose @type array includes one of the specified types are returned. Common values: Person, Organization, Place, Event, Movie, Book, MusicGroup.
boolean
When true, the JSON response is formatted with indentation for human readability. Useful during development and debugging. Defaults to false.
boolean
When true, the query parameter is treated as a prefix and matches entities whose name starts with the query string. Useful for building autocomplete and type-ahead features. Defaults to false.
integer
The maximum number of entity results to return. Accepts values between 1 and 500. Defaults to 20.

Response Fields

object or string
The JSON-LD context declaration. Defines the schema used for the response, including the schema.org vocabulary and the Knowledge Graph-specific goog and EntitySearchResult types.
string
Always "ItemList" for a Knowledge Graph search response.
array
An array of entity result objects, sorted by relevance score. Each element wraps one entity.

Examples

Basic Entity Lookup by Name

Search for the entity “Marie Curie” and limit results to Person types:
cURL
Response:

Lookup by Entity ID

If you already have a Knowledge Graph ID, retrieve the entity directly:
cURL
URL-encode the entity ID when passing it as a query parameter. The / in kg:/m/04wgh becomes %2F, giving kg%3A%2Fm%2F04wgh.

Prefix Search for Autocomplete

Use prefix=true to match all entities whose name starts with a string — ideal for powering a live search input:
cURL
This returns up to 5 Person entities whose names begin with “Albert Ein”, making it suitable for an autocomplete dropdown.

Multi-Language Response

Request descriptions in both English and French:
cURL

Application Code Example


Error Codes

error
The request is malformed — for example, neither query nor ids was provided, or a parameter value is invalid.
error
The key parameter is missing or the API key is invalid. Verify the key in Google Cloud Console and ensure the Knowledge Graph Search API is enabled.
error
The API key does not have access to the Knowledge Graph Search API, the API is not enabled for your project, or your project has exceeded its quota.
error
You have exceeded the rate limit. Implement exponential backoff and retry logic in your application.

Relationship to the Custom Search API

Custom Search JSON API

Returns a list of web pages (or images) matching a query. Best for: site search, web search boxes, news aggregation, image search.Endpoint: https://www.googleapis.com/customsearch/v1

Knowledge Graph Search API

Returns structured entity records from Google’s Knowledge Graph. Best for: entity disambiguation, knowledge panels, autocomplete, fact lookup.Endpoint: https://kgsearch.googleapis.com/v1/entities:search
Use both APIs together for a richer experience: run a Knowledge Graph lookup to identify and display a canonical entity card at the top of your results page, then use the Custom Search API to populate the list of relevant web links below it.