home / skills / cnemri / google-genai-skills / google-developer-knowledge

google-developer-knowledge skill

/skills/google-developer-knowledge

This skill helps you swiftly search and retrieve Google's developer docs via the Developer Knowledge API for quick reference and code examples.

npx playbooks add skill cnemri/google-genai-skills --skill google-developer-knowledge

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
2.8 KB
---
name: google-developer-knowledge
description: "Search and retrieve Google's developer documentation using the Developer Knowledge API. Query documentation chunks, get full document content, or batch retrieve multiple documents. Covers ai.google.dev, developer.android.com, docs.cloud.google.com, firebase.google.com, and more."
---

# Google Developer Knowledge

Use this skill to search and retrieve content from Google's public developer documentation corpus using the Developer Knowledge API.

This skill uses simple bash scripts with curl (no dependencies required).

## Prerequisites

1.  **Enable the API**: Enable the [Developer Knowledge API](https://console.cloud.google.com/apis/library/developerknowledge.googleapis.com) in your Google Cloud project.

2.  **Create an API Key**:
    -   Go to the [Credentials page](https://console.cloud.google.com/apis/credentials)
    -   Click **Create credentials** → **API key**
    -   Restrict the key to **Developer Knowledge API** only

3.  **Set Environment Variable**:
    -   `DEVELOPERKNOWLEDGE_API_KEY`: Your Developer Knowledge API key

## Searchable Corpus

The API searches these domains:
-   `ai.google.dev`
-   `developer.android.com`
-   `developer.chrome.com`
-   `developers.google.com`
-   `docs.cloud.google.com`
-   `firebase.google.com`
-   `web.dev`
-   `www.tensorflow.org`

## Usage

### 1. Search for Documents

Search for document chunks matching a query. Returns snippets and parent document references.

```bash
./skills/google-developer-knowledge/scripts/search_docs.sh "How to use Gemini API in Python"
```

**With pagination:**
```bash
./skills/google-developer-knowledge/scripts/search_docs.sh "BigQuery" --page-size 10
```

### 2. Get a Single Document

Retrieve the full content of a document using its name from search results.

```bash
./skills/google-developer-knowledge/scripts/get_document.sh "documents/ai.google.dev/gemini-api/docs/get-started/python"
```

**Save to file:**
```bash
./skills/google-developer-knowledge/scripts/get_document.sh "documents/ai.google.dev/..." --output doc.json
```

### 3. Batch Get Documents

Retrieve up to 20 documents in a single API call.

```bash
./skills/google-developer-knowledge/scripts/batch_get_documents.sh \
  "documents/ai.google.dev/gemini-api/docs/get-started/python" \
  "documents/ai.google.dev/gemini-api/docs/models"
```

## Options

**search_docs.sh**
-   `query`: The search query (required)
-   `--page-size`: Number of results (1-20, default 5)
-   `--page-token`: Token for next page of results
-   `--output`: Save results to JSON file

**get_document.sh**
-   `name`: Document name from search results (required)
-   `--output`: Save content to file

**batch_get_documents.sh**
-   `names`: Space-separated document names (up to 20)
-   `--output`: Save all documents to directory

Overview

This skill lets you search and retrieve Google developer documentation using the Developer Knowledge API. It queries indexed documentation chunks across Google developer sites and can fetch full document contents or batch-retrieve multiple documents. Use it to surface authoritative docs snippets or to download complete pages for integration into tooling or analysis.

How this skill works

The skill issues search requests to the Developer Knowledge API and returns matching document chunks with snippets and parent document references. You can request a single document by name to get complete content, or submit up to 20 document names to retrieve them in a single batch call. Pagination, page-size control, and optional output saving are supported.

When to use it

  • Locate exact code examples or API usage snippets from Google docs quickly.
  • Retrieve full documentation pages for offline review, analysis, or embedding in internal tools.
  • Batch-download multiple related docs for migration, auditing, or change tracking.
  • Power an assistant or search UI with authoritative developer documentation results.
  • Verify official behavior, parameters, or constraints directly from Google-managed sites.

Best practices

  • Enable and restrict a Developer Knowledge API key in Google Cloud and store it in an environment variable for scripts.
  • Use focused queries (service, method name, or error text) to get more relevant snippets from search results.
  • Page through results with page tokens and keep page-size between 1–20 to control response size.
  • When pulling full documents, use the document name returned by search to ensure you fetch the correct resource.
  • For repeat retrievals, prefer batch requests to reduce API calls and improve throughput.

Example use cases

  • Search for "Gemini API Python get started" to retrieve quick setup steps and example code snippets.
  • Fetch a specific document like an SDK guide to save it locally for offline reading or documentation bundles.
  • Batch retrieve multiple API reference pages to generate a curated developer guide or internal knowledge base.
  • Integrate search results into a developer chatbot to answer precise implementation questions with citation links.
  • Audit cloud product docs by pulling the latest pages and comparing them against stored versions.

FAQ

What domains does the API search?

It covers Google developer domains such as ai.google.dev, developer.android.com, developer.chrome.com, developers.google.com, docs.cloud.google.com, firebase.google.com, web.dev, and www.tensorflow.org.

How many documents can I retrieve in a batch?

You can request up to 20 documents in a single batch get operation.