You can use one of several programmatic interfaces when interacting with Cloud Spanner. These are the available interfaces, in the order that we recommend using them:
- Client libraries: The Cloud Spanner client libraries are available in multiple languages and are built on gRPC. These client libraries provide a layer of abstraction on top of gRPC and handle the details of session management, transaction execution, retries, and more.
- RPC API: If a client library is not available for your programming language of choice, use the RPC API, which is built on gRPC. gRPC offers a number of performance benefits compared with using the REST API, including representing objects in protocol buffer format (which are faster to produce and consume compared with JSON) and persistent connections (which result in less per-request overhead). Read more about these and other benefits in gRPC Concepts.
- REST API: If you're unable to use Cloud Spanner's client libraries or the RPC API, use the REST API. Note that some features that are available in the RPC API are not supported in the REST API, as documented below.
RPC vs REST API
|Feature||Supported in the RPC API?||Supported in the REST API?|
|Cancelling a request||doneYes||clearNo|
|Setting a deadline or timeout on a request||doneYes||clearNo|
|Sending a streaming request||doneYes. See
||Partial. HTTP Streaming is supported but application-level flow control is not.|