This guide shows you how to get started with the Developer Knowledge API. You'll learn how to enable the Developer Knowledge API, get an API key, and make your first API calls to search for and retrieve developer documentation.
Before you begin
Before you start using the Developer Knowledge API, make sure you complete the following steps.
Enable the API
- Open the Developer Knowledge API page in the Google APIs library.
- Check that you have the correct project selected in which you intend to use the API.
- Click Enable . No specific IAM roles are required to enable or use the API.
Create and secure the API key
- In the Google Cloud console for the project in which you enabled the API, go to the Credentials page .
- Click Create credentials , and then select API key from the menu.
- In the Name field, provide a name for the key.
-
Click the Select API restrictions drop-down, and then type Developer Knowledge API . Click the result, and then click OK .
Notes:
- If you just enabled the Developer Knowledge API, there may be a delay before it appears in the list. Wait a few minutes and try again.
- If you plan to use this same key for your AI client's general model
calls (for example,
GEMINI_API_KEY), you must also select Generative Language API . Otherwise, those calls will be blocked.
- Click Create .
Answer a query with grounded generation
Once you have your Developer Knowledge API key, you can start using the API. The following example shows how to ask a query and get an answer grounded in the documentation:
-
Save your Developer Knowledge API key to an environment variable:
export DEVELOPERKNOWLEDGE_API_KEY = " YOUR_API_KEY "Replace
YOUR_API_KEYwith the API key you generated. -
Use
curlto call theAnswerQueryendpoint:curl -X POST "https://developerknowledge.googleapis.com/v1alpha:answerQuery?key= $DEVELOPERKNOWLEDGE_API_KEY " \ -H "Content-Type: application/json" \ -d '{"query": "How do I create a BigQuery dataset?"}'
This command returns an answer to your query based on the documentation.
Search for document chunks
If you want to find specific documentation snippets rather than a generated answer, you can directly search for document chunks.
Use curl
to call the SearchDocumentChunks
endpoint:
curl
"https://developerknowledge.googleapis.com/v1/documents:searchDocumentChunks?query=BigQuery&key=
$DEVELOPERKNOWLEDGE_API_KEY
"
The response includes matching chunks of content from the documentation and references to the parent documents.
Retrieve a document
The response from searchDocumentChunks
contains a list of document chunks.
Each document chunk has a parent
field containing the resource name of the
document, which you can use with GetDocument
to retrieve the document's full
content.
To retrieve a document, copy the parent
field from one of the chunks
returned by searchDocumentChunks
and save it to an environment variable, then
use curl
to call the GetDocument
endpoint:
export
DOC_NAME
=
" PARENT_FIELD_FROM_SEARCH
"
curl
"https://developerknowledge.googleapis.com/v1/
$DOC_NAME
?key=
$DEVELOPERKNOWLEDGE_API_KEY
"
This returns the full Markdown content of the specified document.
What's next
- Explore the Corpus reference to see the full list of included documentation.
- See the API reference documentation for more details on API methods and parameters.
- Learn how to set up the MCP server in Google Antigravity

