Developer Knowledge API client libraries

This page shows how to get started with the Cloud Client Libraries for the Developer Knowledge API. Instead of constructing raw HTTP requests, client libraries provide idiomatic types, built-in authentication, automatic pagination, and retry handling that reduce the amount of code you need to write.

To learn more about client libraries for Google APIs, refer to Client libraries explained.

Install the client library

Select your programming language to install the official Developer Knowledge API client library:

Go

Add the module to your Go project:

go get cloud.google.com/go/developerknowledge/apiv1

To learn more, refer to Setting up a Go development environment.

Java

If you use Maven, add the following dependency to your pom.xml file:

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-developer-knowledge</artifactId>
  <version>0.6.0</version>
</dependency>

If you use Gradle, add the following dependency to your build.gradle file:

implementation 'com.google.cloud:google-cloud-developer-knowledge:0.6.0'

To learn more, refer to Setting up a Java development environment.

Node.js and TypeScript

Install the package using npm:

npm install @google/developer-knowledge

To learn more, refer to Setting up a Node.js development environment.

PHP

Install the package using Composer:

composer require google/developer-knowledge

To learn more, refer to Using PHP on Google Cloud.

Python

Install the package using pip:

pip install --upgrade google-developer-knowledge

To learn more, refer to Setting up a Python development environment.

Ruby

Install the gem:

gem install google-developers-developer_knowledge

To learn more, refer to Setting up a Ruby development environment.

Set up authentication

Before making API requests, make sure that you have enabled the Developer Knowledge API in your Google Cloud project.

To authenticate calls to the Developer Knowledge API, client libraries support Application Default Credentials (ADC). The libraries look for credentials in a set of defined locations and use those credentials to authenticate requests to the API. With ADC, you can make credentials available to your application in a variety of environments, such as local development or production, without needing to modify your application code.

For production environments, the way you set up ADC depends on the service and context:

  • Google Cloud environments: when your application runs on Cloud Run, Google Kubernetes Engine, Compute Engine, or Cloud Run functions, ADC automatically uses the service account attached to the compute resource.
  • External or on-premises environments: use Workload Identity Federation or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a credential configuration file.

To learn more about production credential options, refer to Set up Application Default Credentials.

For a local development environment, you can set up ADC with the credentials associated with your Google Account:

  1. Install and initialize the gcloud CLI.
  2. Create local authentication credentials for your Google Account:

    gcloud auth application-default login
    

    A sign-in screen appears. After you sign in, your credentials are stored in the local credential file used by ADC.

Additional resources

Select a language tab to find links to API reference documentation, code samples, best practices, issue trackers, and source code repositories for each client library:

Go

The following list contains links to more resources related to the client library for Go:

Java

The following list contains links to more resources related to the client library for Java:

Node.js and TypeScript

The following list contains links to more resources related to the client library for Node.js and TypeScript:

PHP

The following list contains links to more resources related to the client library for PHP:

Python

The following list contains links to more resources related to the client library for Python:

Ruby

The following list contains links to more resources related to the client library for Ruby:

What's next