Skip to content

feat(developer-knowledge): add Developer Knowledge API samples - #4424

Merged
llatif merged 6 commits into
GoogleCloudPlatform:mainfrom
llatif:feat/developerknowledge-samples
Sep 12, 2026
Merged

llatif merged 6 commits into
GoogleCloudPlatform:mainfrom
llatif:feat/developerknowledge-samples

Conversation

@llatif

@llatif llatif commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Node.js code samples for the Developer Knowledge API using the @google/developer-knowledge client library:

  • answerQuery.js (developerknowledge_answer_query) - Answers queries against a developer knowledge corpus.
  • getDocument.js (developerknowledge_get_document) - Retrieves a document by resource name.
  • batchGetDocuments.js (developerknowledge_batch_get_documents) - Retrieves multiple documents in a single request.
  • searchDocumentChunks.js (developerknowledge_search_document_chunks) - Searches document chunks with pagination limit.

Includes comprehensive Mocha unit tests (test/samples.test.js), ESLint/Prettier configuration with license headers, package metadata, README documentation, and added developer-knowledge to CODEOWNERS.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • Required CI tests pass (see CI testing)
  • These samples need a new API enabled in testing projects to pass (developerknowledge.googleapis.com)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

llatif added 2 commits August 25, 2026 18:35
Add standalone code samples and test suites for Developer Knowledge API:
- searchDocumentChunks
- getDocument
- batchGetDocuments
- answerQuery
@llatif
llatif requested review from a team as code owners August 26, 2026 02:12
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Aug 26, 2026
@snippet-bot

snippet-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@llatif
llatif marked this pull request as draft August 26, 2026 02:13

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Node.js code samples and tests for the Google Developer Knowledge API, including scripts for answering queries, retrieving documents, batch-fetching documents, and searching document chunks. The review feedback highlights potential TypeError issues across several files (answerQuery.js, getDocument.js, and searchDocumentChunks.js) where properties or methods are accessed on potentially undefined or null fields (such as response.answer, document.content, and chunk.content). It is recommended to use optional chaining or fallback values to ensure robust error handling.

@llatif
llatif marked this pull request as ready for review August 26, 2026 02:26
@llatif

llatif commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Hi, Could one of the maintainers please review this PR, cheers :)

@dandhlee dandhlee left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing for Sample styles.

@llatif
llatif merged commit fd14f85 into GoogleCloudPlatform:main Sep 12, 2026
19 checks passed
@llatif
llatif deleted the feat/developerknowledge-samples branch September 12, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants