This page shows how to get started with the Cloud Client Libraries for the Cloud Spanner API. Read more about the client libraries for Cloud APIs, including the older Google API Client Libraries, in Client Libraries Explained.
The Spanner client libraries mentioned on this page are supported on Compute Engine, App Engine flexible environment, Google Kubernetes Engine, and Cloud Functions. The Spanner client library for Java is supported on App Engine standard environment with Java 8.
If you are using the App Engine standard environment with Go, PHP, or Python, use the REST interface to access Spanner.
Install the client library
C++
See the GitHub quickstart documents for details about this client library's requirements and install dependencies.C#
For more information, see Setting Up a C# Development Environment.
To install theGoogle.Cloud.Spanner.Data
client library in Visual Studio,
do the following:
Right-click your solution in Visual Studio and select Manage Nuget packages for solution.
Select the Include prerelease checkbox.
Search for and install the package named
Google.Cloud.Spanner.Data
.
Go
For more information, see Setting Up a Go Development Environment.
go get cloud.google.com/go/spanner/...
Java
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:
If you are using sbt, add the following to your dependencies:
If you're using Visual Studio Code, 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.
Node.js
For more information, see Setting Up a Node.js Development Environment.
npm install --save @google-cloud/spanner
PHP
For more information, see Using PHP on Google Cloud.
composer require google/cloud-spanner
Python
For more information, see Setting Up a Python Development Environment.
pip install --upgrade google-cloud-spanner
Ruby
For more information, see Setting Up a Ruby Development Environment.
gem install google-cloud-spanner
Set up authentication
When you use client libraries, you use Application Default Credentials (ADC) to authenticate. For information about setting up ADC, see Provide credentials for Application Default Credentials. For information about using ADC with client libraries, see Authenticate using client libraries.
Use the client library
The following example shows how to use the client library.
C++
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
C#
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Ruby
To learn how to install and use the client library for Spanner, see Spanner client libraries.
To authenticate to Spanner, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Additional resources
C++
C#
Go
Java
Node.js
PHP
Python
Ruby
Additional client libraries
In addition to the libraries shown above, a Spring Data module is available for Java applications. Spring Data Cloud Spanner helps you use Spanner in any application that's built with the Spring Framework.
To get started, learn how to add Spring Data Spanner to your application.