Quickstart: Get started with the Developer Knowledge API

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

  1. Enable the API: If you haven't already, enable the Developer Knowledge API in your Google Cloud project.
  2. Get an API key: You need a Developer Knowledge API key to authenticate your requests. Follow these instructions to create an API key. Remember to restrict your API key for security.

Search for documents

Once you have your Developer Knowledge API key, you can start using the API. The following example shows how to search for documents related to "BigQuery":

  1. Save your Developer Knowledge API key to an environment variable: bash export DEVELOPERKNOWLEDGE_API_KEY="YOUR_API_KEY" Replace YOUR_API_KEY with the API key you generated.

  2. Use curl to call the SearchDocuments endpoint:

    curl "https://developerknowledge.googleapis.com/v1alpha/documents:search?query=BigQuery&key=$DEVELOPERKNOWLEDGE_API_KEY"
    

This command returns a list of document resources that match the query, including snippets from the content and a name for each document.

Retrieve a document

The response from SearchDocuments contains a list of documents. Each document has a name field, which you can use to retrieve its full content with GetDocument.

Copy the name of one of the documents returned by the SearchDocuments call (for example, documents/developers.google.com/...), save it to an environment variable, and use curl to call the GetDocument endpoint:

export DOC_NAME="PASTE_DOCUMENT_NAME_HERE"
curl "https://developerknowledge.googleapis.com/v1alpha/$DOC_NAME?key=$DEVELOPERKNOWLEDGE_API_KEY"

This returns the full Markdown content of the specified document.

What's next