# Method: projects.instances.databases.sessions.read

- [HTTP request](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.aspect)
- [Try it!](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#try-it)

Reads rows from the database using key lookups and scans, as a simple key/value style alternative to `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/executeSql#google.spanner.v1.Spanner.ExecuteSql`. This method can't be used to return a result set larger than 10 MiB; if the read matches more data than that, the read fails with a `FAILED_PRECONDITION` error.

Reads inside read-write transactions might return `ABORTED`. If this occurs, the application should restart the transaction from the beginning. See `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/Transaction` for more details.

Larger result sets can be yielded in streaming fashion by calling `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/streamingRead#google.spanner.v1.Spanner.StreamingRead` instead.

### HTTP request

Choose a location:
<button value="global" default="">global</button> <button value="europe-west8">europe-west8</button> <button value="me-central2">me-central2</button> <button value="us-central1">us-central1</button> <button value="us-central2">us-central2</button> <button value="us-east1">us-east1</button> <button value="us-east4">us-east4</button> <button value="us-east5">us-east5</button> <button value="us-south1">us-south1</button> <button value="us-west1">us-west1</button> <button value="us-west2">us-west2</button> <button value="us-west3">us-west3</button> <button value="us-west4">us-west4</button> <button value="us-west8">us-west8</button> <button value="us-east7">us-east7</button>   
`POST https://spanner.googleapis.com/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read`

<br />

The URLs use [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `session` | `string` Required. The session in which the read should be performed. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `session`: - `spanner.databases.read` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "transaction": { object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/TransactionSelector`) }, "table": string, "index": string, "columns": [ string ], "keySet": { object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/KeySet`) }, "limit": string, "resumeToken": string, "partitionToken": string, "requestOptions": { object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/RequestOptions`) }, "directedReadOptions": { object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/DirectedReadOptions`) }, "dataBoostEnabled": boolean } ``` |

| Fields ||
|---|---|
| `transaction` | ``object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/TransactionSelector`)`` The transaction to use. If none is provided, the default is a temporary read-only transaction with strong concurrency. |
| `table` | `string` Required. The name of the table in the database to be read. |
| `index` | `string` If non-empty, the name of an index on `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.table`. This index is used instead of the table primary key when interpreting `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.key_set` and sorting result rows. See `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.key_set` for further information. |
| `columns[]` | `string` Required. The columns of `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.table` to be returned for each row matching this request. |
| `keySet` | ``object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/KeySet`)`` Required. `keySet` identifies the rows to be yielded. `keySet` names the primary keys of the rows in `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.table` to be yielded, unless `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.index` is present. If `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.index` is present, then `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.key_set` instead names index keys in `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.index`. If the `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.partition_token` field is empty, rows are yielded in table primary key order (if `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.index` is empty) or index key order (if `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.index` is non-empty). If the `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#body.request_body.FIELDS.partition_token` field isn't empty, rows are yielded in an unspecified order. It isn't an error for the `keySet` to name rows that don't exist in the database. sessions.read yields nothing for nonexistent rows. |
| `limit` | `string (https://developers.google.com/discovery/v1/type-format format)` If greater than zero, only the first `limit` rows are yielded. If `limit` is zero, the default is no limit. A limit can't be specified if `partitionToken` is set. |
| `resumeToken` | `string (https://developers.google.com/discovery/v1/type-format format)` If this request is resuming a previously interrupted read, `resumeToken` should be copied from the last `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/PartialResultSet` yielded before the interruption. Doing this enables the new read to resume where the last read left off. The rest of the request parameters must exactly match the request that yielded this token. A base64-encoded string. |
| `partitionToken` | `string (https://developers.google.com/discovery/v1/type-format format)` If present, results are restricted to the specified partition previously created using `sessions.partitionRead`. There must be an exact match for the values of fields common to this message and the PartitionReadRequest message used to create this partitionToken. A base64-encoded string. |
| `requestOptions` | ``object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/RequestOptions`)`` Common options for this request. |
| `directedReadOptions` | ``object (`https://docs.cloud.google.com/spanner/docs/reference/rest/v1/DirectedReadOptions`)`` Directed read options for this request. |
| `dataBoostEnabled` | `boolean` If this is for a partitioned read and this field is set to `true`, the request is executed with Spanner Data Boost independent compute resources. If the field is set to `true` but the request doesn't set `partitionToken`, the API returns an `INVALID_ARGUMENT` error. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/ResultSet`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/spanner.data`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).