CTS Client Libraries

This page shows how to get started with the Cloud Client Libraries for the Cloud Talent Solution API. Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Client libraries for more languages are coming soon.

Installing the client library


For more information, see Setting Up a C# Development Environment.

Install-Package Google.Cloud.Talent.V4 -Pre


For more information, see Setting Up a Go Development Environment.

go get -u cloud.google.com/go/talent/apiv4


For more information, see Setting Up a Java Development Environment.

If you are using Maven, add the following to your pom.xml file. For more information about BOMs, see The Google Cloud Platform Libraries BOM.



If you are using Gradle, add the following to your dependencies:

compile 'com.google.cloud:google-cloud-talent:1.0.2'

If you are using sbt, add the following to your dependencies:

libraryDependencies += "com.google.cloud" % "google-cloud-talent" % "1.0.2"

If you're using IntelliJ or Eclipse, you can add client libraries to your project using the following IDE plugins:

The plugins provide additional functionality, such as key management for service accounts. Refer to each plugin's documentation for details.


For more information, see Setting Up a Node.js Development Environment.

npm install @google-cloud/talent


For more information, see Using PHP on Google Cloud.

composer require google/cloud-talent


For more information, see Setting Up a Ruby Development Environment.

gem install google-cloud-talent

Setting up authentication

To run the client library, you must first set up authentication by creating a service account and setting an environment variable. Complete the following steps to set up authentication. For other ways to authenticate, see the GCP authentication documentation.

Cloud Console

  1. In the Cloud Console, go to the Create service account key page.

    Go to the Create Service Account Key page
  2. From the Service account list, select New service account.
  3. In the Service account name field, enter a name.
  4. From the Role list, select Project > Owner.

  5. Click Create. A JSON file that contains your key downloads to your computer.

Command line

You can run the following commands using the Cloud SDK on your local machine, or in Cloud Shell.

  1. Create the service account. Replace NAME with a name for the service account.

    gcloud iam service-accounts create NAME
  2. Grant permissions to the service account. Replace PROJECT_ID with your project ID.

    gcloud projects add-iam-policy-binding PROJECT_ID --member="serviceAccount:NAME@PROJECT_ID.iam.gserviceaccount.com" --role="roles/owner"
  3. Generate the key file. Replace FILE_NAME with a name for the key file.

    gcloud iam service-accounts keys create FILE_NAME.json --iam-account=NAME@PROJECT_ID.iam.gserviceaccount.com

Provide authentication credentials to your application code by setting the environment variable GOOGLE_APPLICATION_CREDENTIALS. Replace [PATH] with the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.

Linux or macOS


For example:

export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json"


With PowerShell:


For example:


With command prompt:


Using the client library

The following example shows how to use the client library.


public static object ListCompanies(string projectId, string tenantId)
    CompanyServiceClient companyServiceClient = CompanyServiceClient.Create();
    TenantName tenantName = TenantName.FromProjectTenant(projectId, tenantId);

    ListCompaniesRequest request = new ListCompaniesRequest
        ParentAsTenantName = tenantName
    var companies = companyServiceClient.ListCompanies(request);
    foreach (var company in companies)
        Console.WriteLine($"Company Name: {company.Name}");
        Console.WriteLine($"Display Name: {company.DisplayName}");
        Console.WriteLine($"External ID: {company.ExternalId}");
    return 0;


import (

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"

func main() {
	projectID := os.Getenv("GOOGLE_CLOUD_PROJECT")

	// Initialize job search client.
	ctx := context.Background()
	c, err := talent.NewCompanyClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewCompanyClient: %v", err)

	// Construct a listCompany request.
	req := &talentpb.ListCompaniesRequest{
		Parent: "projects/" + projectID,

	it := c.ListCompanies(ctx, req)

	for {
		resp, err := it.Next()
		if err == iterator.Done {
		if err != nil {
			fmt.Printf("it.Next: %v", err)
		fmt.Printf("Company: %v\n", resp.GetName())


import com.google.cloud.talent.v4.Company;
import com.google.cloud.talent.v4.CompanyServiceClient;
import com.google.cloud.talent.v4.ListCompaniesRequest;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;

public class JobSearchListCompanies {

  public static void listCompanies() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    listCompanies(projectId, tenantId);

  // List Companies.
  public static void listCompanies(String projectId, String tenantId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);

      ListCompaniesRequest request =

      for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
        System.out.format("Company Name: %s%n", responseItem.getName());
        System.out.format("Display Name: %s%n", responseItem.getDisplayName());
        System.out.format("External ID: %s%n", responseItem.getExternalId());


const talent = require('@google-cloud/talent').v4;

 * List Companies
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
function sampleListCompanies(projectId, tenantId) {
  const client = new talent.CompanyServiceClient();
  // Iterate over all elements.
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  const formattedParent = client.tenantPath(projectId, tenantId);

    .listCompanies({parent: formattedParent})
    .then(responses => {
      const resources = responses[0];
      for (const resource of resources) {
        console.log(`Company Name: ${resource.name}`);
        console.log(`Display Name: ${resource.displayName}`);
        console.log(`External ID: ${resource.externalId}`);
    .catch(err => {



require "google/cloud/talent"

# Instantiate a client
company_service = Google::Cloud::Talent.company_service

# project_id = "Your Google Cloud Project ID"
# tenant_id = "Your Tenant ID (using tenancy is required)"
formatted_parent = company_service.tenant_path project: project_id, tenant: tenant_id

# Iterate over all results.
response = company_service.list_companies parent: formatted_parent
response.each do |element|
  puts "Company Name: #{element.name}"
  puts "Display Name: #{element.display_name}"
  puts "External ID: #{element.external_id}"

Additional resources