Package google.firestore.v1  |  Firebase

Package google.firestore.v1 Stay organized with collections Save and categorize content based on your preferences.

Index

Firestore

The Cloud Firestore service.

Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL document database that simplifies storing, syncing, and querying data for your mobile, web, and IoT apps at global scale. Its client libraries provide live synchronization and offline support, while its security features and integrations with Firebase and Google Cloud Platform accelerate building truly serverless apps.

BatchGetDocuments
rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (BatchGetDocumentsResponse)
Gets multiple documents.
Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
BatchWrite
rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse)
Applies a batch of write operations.
The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write.
If you require an atomically applied set of writes, use Commit instead.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
BeginTransaction
rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse)
Starts a new transaction.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
Commit
rpc Commit(CommitRequest) returns (CommitResponse)
Commits a transaction, while optionally updating documents.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
CreateDocument
rpc CreateDocument(CreateDocumentRequest) returns (Document)
Creates a new document.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
DeleteDocument
rpc DeleteDocument(DeleteDocumentRequest) returns (Empty)
Deletes a document.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
ExecutePipeline
rpc ExecutePipeline(ExecutePipelineRequest) returns (ExecutePipelineResponse)
Executes a pipeline query.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
GetDocument
rpc GetDocument(GetDocumentRequest) returns (Document)
Gets a single document.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
ListCollectionIds
rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse)
Lists all the collection IDs underneath a document.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
ListDocuments
rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse)
Lists documents.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
Listen
rpc Listen(ListenRequest) returns (ListenResponse)
Listens to changes. This method is only available via gRPC or WebChannel (not REST).
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
PartitionQuery
rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse)
Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
Rollback
rpc Rollback(RollbackRequest) returns (Empty)
Rolls back a transaction.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
RunAggregationQuery
rpc RunAggregationQuery(RunAggregationQueryRequest) returns (RunAggregationQueryResponse)
Runs an aggregation query.
Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side.
High-Level Example:
<br>-- Return the number of documents in table given a filter.<br>SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );<br>
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
RunQuery
rpc RunQuery(RunQueryRequest) returns (RunQueryResponse)
Runs a query.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
UpdateDocument
rpc UpdateDocument(UpdateDocumentRequest) returns (Document)
Updates or inserts a document.
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.
Write
rpc Write(WriteRequest) returns (WriteResponse)
Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
Authorization scopes
Requires one of the following OAuth scopes:
- https://www.googleapis.com/auth/datastore
- https://www.googleapis.com/auth/cloud-platform
For more information, see the OAuth 2.0 Overview.

AggregationResult

The result of a single bucket from a Firestore aggregation query.

The keys of aggregate_fields are the same for all results in an aggregation query, unlike document queries which can have different fields present for each result.

Fields
aggregate_fields

ArrayValue

An array value.

Fields
values[]

BatchGetDocumentsRequest

The request for Firestore.BatchGetDocuments.

Fields
database
documents[]
mask
Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
transaction
new_transaction
read_time

BatchGetDocumentsResponse

The streamed response for Firestore.BatchGetDocuments.

Fields
transaction
read_time
Union field result. A single result. This can be empty if the server is just returning a transaction. result can be only one of the following:
found
missing

BatchWriteRequest

The request for Firestore.BatchWrite.

Fields
database
writes[]
labels

BatchWriteResponse

The response from Firestore.BatchWrite.

Fields
write_results[]
status[]

BeginTransactionRequest

The request for Firestore.BeginTransaction.

Fields
database
options

BeginTransactionResponse

The response for Firestore.BeginTransaction.

Fields
transaction

BitSequence

A sequence of bits, encoded in a byte array.

Each byte in the bitmap byte array stores 8 bits of the sequence. The only exception is the last byte, which may store 8 or fewer bits. The padding defines the number of bits of the last byte to be ignored as "padding". The values of these "padding" bits are unspecified and must be ignored.

To retrieve the first bit, bit 0, calculate: (bitmap[0] & 0x01) != 0. To retrieve the second bit, bit 1, calculate: (bitmap[0] & 0x02) != 0. To retrieve the third bit, bit 2, calculate: (bitmap[0] & 0x04) != 0. To retrieve the fourth bit, bit 3, calculate: (bitmap[0] & 0x08) != 0. To retrieve bit n, calculate: (bitmap[n / 8] & (0x01 << (n % 8))) != 0.

The "size" of a BitSequence (the number of bits it contains) is calculated by this formula: (bitmap.length * 8) - padding.

Fields
bitmap
padding

BloomFilter

A bloom filter ( https://en.wikipedia.org/wiki/Bloom_filter)).

The bloom filter hashes the entries with MD5 and treats the resulting 128-bit hash as 2 distinct 64-bit hash values, interpreted as unsigned integers using 2's complement encoding.

These two hash values, named h1 and h2, are then used to compute the hash_count hash values using the formula, starting at i=0:

h(i) = h1 + (i * h2)

These resulting values are then taken modulo the number of bits in the bloom filter to get the bits of the bloom filter to test for the given entry.

Fields
bits
hash_count

CommitRequest

The request for Firestore.Commit.

Fields
database
writes[]
transaction

CommitResponse

The response for Firestore.Commit.

Fields
write_results[]
commit_time

CreateDocumentRequest

The request for Firestore.CreateDocument.

Fields
parent
collection_id
document_id
document
mask

Cursor

A position in a query result set.

Fields
values[]
before

DeleteDocumentRequest

The request for Firestore.DeleteDocument.

Fields
name
current_document

Document

A Firestore document.

Must not exceed 1 MiB - 4 bytes.

Fields
name
fields
create_time
update_time

DocumentChange

A Document has changed.

May be the result of multiple writes, including deletes, that ultimately resulted in a new value for the Document.

Multiple DocumentChange messages may be returned for the same logical change, if multiple targets are affected.

Fields
document
target_ids[]
removed_target_ids[]

DocumentDelete

A Document has been deleted.

May be the result of multiple writes, including updates, the last of which deleted the Document.

Multiple DocumentDelete messages may be returned for the same logical delete, if multiple targets are affected.

Fields
document
removed_target_ids[]
read_time

DocumentMask

A set of field paths on a document. Used to restrict a get or update operation on a document to a subset of its fields. This is different from standard field masks, as this is always scoped to a Document, and takes in account the dynamic nature of Value.

Fields
field_paths[]

DocumentRemove

A Document has been removed from the view of the targets.

Sent if the document is no longer relevant to a target and is out of view. Can be sent instead of a DocumentDelete or a DocumentChange if the server can not send the new value of the document.

Multiple DocumentRemove messages may be returned for the same logical write or delete, if multiple targets are affected.

Fields
document
removed_target_ids[]
read_time

DocumentTransform

A transformation of a document.

Fields
document
field_transforms[]

FieldTransform

A transformation of a field of the document.

Fields
field_path
Union field transform_type. The transformation to apply on the field. transform_type can be only one of the following:
set_to_server_value
increment
maximum
minimum
append_missing_elements
remove_all_from_array

ServerValue

A value that is calculated by the server.

Enums
SERVER_VALUE_UNSPECIFIED
REQUEST_TIME

ExecutePipelineRequest

The request for Firestore.ExecutePipeline.

Fields
database
Union field pipeline_type.
pipeline_type can be only one of the following:
structured_pipeline
Union field consistency_selector. Optional consistency arguments, defaults to strong consistency. consistency_selector can be only one of the following:
transaction
new_transaction
read_time

ExecutePipelineResponse

The response for [Firestore.Execute][].

Fields
transaction
results[]
execution_time
explain_stats

ExecutionStats

Execution statistics for the query.

Fields
results_returned
execution_duration
read_operations
debug_stats

ExistenceFilter

A digest of all the documents that match a given target.

Fields
target_id
count
unchanged_names

ExplainMetrics

Explain metrics for the query.

Fields
plan_summary
execution_stats

ExplainOptions

Explain options for the query.

Fields
analyze

ExplainStats

Pipeline explain stats.

Depending on the explain options in the original request, this can contain the optimized plan and / or execution stats.

Fields
data

Function

Represents an unevaluated scalar expression.

For example, the expression like(user_name, "%alice%") is represented as:

name: "like"
args { field_reference: "user_name" }
args { string_value: "%alice%" }
Fields
name
args[]
options

GetDocumentRequest

The request for Firestore.GetDocument.

Fields
name
mask
Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
transaction
read_time

ListCollectionIdsRequest

The request for Firestore.ListCollectionIds.

Fields
parent
page_size
page_token
Union field consistency_selector. The consistency mode for this request. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
read_time

ListCollectionIdsResponse

The response from Firestore.ListCollectionIds.

Fields
collection_ids[]
next_page_token

ListDocumentsRequest

The request for Firestore.ListDocuments.

Fields
parent
collection_id
page_size
page_token
order_by
mask
show_missing
Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
transaction
read_time

ListDocumentsResponse

The response for Firestore.ListDocuments.

Fields
documents[]
next_page_token

ListenRequest

A request for Firestore.Listen

Fields
database
labels
Union field target_change. The supported target changes. target_change can be only one of the following:
add_target
remove_target

ListenResponse

The response for Firestore.Listen.

Fields
Union field response_type. The supported responses. response_type can be only one of the following:
target_change
document_change
document_delete
document_remove
filter

MapValue

A map value.

Fields
fields

PartitionQueryRequest

The request for Firestore.PartitionQuery.

Fields
parent
partition_count
page_token
page_size
Union field query_type. The query to partition. query_type can be only one of the following:
structured_query
Union field consistency_selector. The consistency mode for this request. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
read_time

PartitionQueryResponse

The response for Firestore.PartitionQuery.

Fields
partitions[]
next_page_token

Pipeline

A Firestore query represented as an ordered list of operations / stages.

Fields
stages[]

Stage

A single operation within a pipeline.

A stage is made up of a unique name, and a list of arguments. The exact number of arguments & types is dependent on the stage type.

To give an example, the stage filter(state = "MD") would be encoded as:

name: "filter"
args {
  function_value {
    name: "eq"
    args { field_reference_value: "state" }
    args { string_value: "MD" }
  }
}

See public documentation for the full list.

Fields
name
args[]
options

PlanSummary

Planning phase information for the query.

Fields
indexes_used[]

Precondition

A precondition on a document, used for conditional operations.

Fields
Union field condition_type. The type of precondition. condition_type can be only one of the following:
exists
update_time

RollbackRequest

The request for Firestore.Rollback.

Fields
database
transaction

RunAggregationQueryRequest

The request for Firestore.RunAggregationQuery.

Fields
parent
explain_options
Union field query_type. The query to run. query_type can be only one of the following:
structured_aggregation_query
Union field consistency_selector. The consistency mode for the query, defaults to strong consistency. consistency_selector can be only one of the following:
transaction
new_transaction
read_time

RunAggregationQueryResponse

The response for Firestore.RunAggregationQuery.

Fields
result
transaction
read_time
explain_metrics

RunQueryRequest

The request for Firestore.RunQuery.

RunQueryResponse

The response for Firestore.RunQuery.

Fields
transaction
document
read_time
skipped_results
explain_metrics
Union field continuation_selector. The continuation mode for the query. If present, it indicates the current query response stream has finished. This can be set with or without a document present, but when set, no more results are returned. continuation_selector can be only one of the following:
done

StructuredAggregationQuery

Firestore query for running an aggregation over a StructuredQuery.

Fields
aggregations[]
Union field query_type. The base query to aggregate over. query_type can be only one of the following:
structured_query

Aggregation

Defines an aggregation that produces a single result.

Fields
alias
Union field operator. The type of aggregation to perform, required. operator can be only one of the following:
count
sum
avg

Avg

Average of the values of the requested field.

Fields
field

Count

Count of documents that match the query.

The COUNT(*) aggregation function operates on the entire document so it does not require a field reference.

Fields
up_to

Sum

Sum of the values of the requested field.

Fields
field

StructuredPipeline

A Firestore query represented as an ordered list of operations / stages.

This is considered the top-level function which plans and executes a query. It is logically equivalent to query(stages, options), but prevents the client from having to build a function wrapper.

Fields
pipeline
options

StructuredQuery

A Firestore query.

The query stages are executed in the following order: 1. from 2. where 3. select 4. order_by + start_at + end_at 5. offset 6. limit 7. find_nearest

Fields
select
from[]
where
order_by[]
start_at
end_at
offset
limit
find_nearest

CollectionSelector

A selection of a collection, such as messages as m1.

Fields
collection_id
all_descendants

CompositeFilter

A filter that merges multiple other filters using the given operator.

Fields
op
filters[]

Operator

A composite filter operator.

Enums
OPERATOR_UNSPECIFIED
AND
OR

Direction

A sort direction.

Enums
DIRECTION_UNSPECIFIED
ASCENDING
DESCENDING

FieldFilter

A filter on a specific field.

Fields
field
op
value

Operator

A field filter operator.

Enums
OPERATOR_UNSPECIFIED
LESS_THAN
LESS_THAN_OR_EQUAL
GREATER_THAN
GREATER_THAN_OR_EQUAL
EQUAL
NOT_EQUAL
ARRAY_CONTAINS
IN
ARRAY_CONTAINS_ANY
NOT_IN

FieldReference

A reference to a field in a document, ex: stats.operations.

Fields
field_path

Filter

A filter.

Fields
Union field filter_type. The type of filter. filter_type can be only one of the following:
composite_filter
field_filter
unary_filter

FindNearest

Nearest Neighbors search config. The ordering provided by FindNearest supersedes the order_by stage. If multiple documents have the same vector distance, the returned document order is not guaranteed to be stable between queries.

Fields
vector_field
query_vector
distance_measure
limit
distance_result_field
distance_threshold

DistanceMeasure

The distance measure to use when comparing vectors.

Enums
DISTANCE_MEASURE_UNSPECIFIED
EUCLIDEAN
COSINE
DOT_PRODUCT

Order

An order on a field.

Fields
field
direction

Projection

The projection of document's fields to return.

Fields
fields[]

UnaryFilter

A filter with a single operand.

Fields
op
Union field operand_type. The argument to the filter. operand_type can be only one of the following:
field

Operator

A unary operator.

Enums
OPERATOR_UNSPECIFIED
IS_NAN
IS_NULL
IS_NOT_NAN
IS_NOT_NULL

Target

A specification of a set of documents to listen to.

Fields
target_id
once
expected_count
Union field target_type. The type of target to listen to. target_type can be only one of the following:
query
documents
Union field resume_type. When to start listening.
If specified, only the matching Documents that have been updated AFTER the resume_token or read_time will be returned. Otherwise, all matching Documents are returned before any subsequent changes. resume_type can be only one of the following:
resume_token
read_time

DocumentsTarget

A target specified by a set of documents names.

Fields
documents[]

QueryTarget

A target specified by a query.

Fields
parent
Union field query_type. The query to run. query_type can be only one of the following:
structured_query

TargetChange

Targets being watched have changed.

Fields
target_change_type
target_ids[]
cause
resume_token
read_time

TargetChangeType

The type of change.

Enums
NO_CHANGE
ADD
REMOVE
CURRENT
RESET

TransactionOptions

Options for creating a new transaction.

Fields
Union field mode. The mode of the transaction. mode can be only one of the following:
read_only
read_write

ReadOnly

Options for a transaction that can only be used to read documents.

Fields
Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
read_time

ReadWrite

Options for a transaction that can be used to read and write documents.

Firestore does not allow 3rd party auth requests to create read-write. transactions.

Fields
retry_transaction

UpdateDocumentRequest

The request for Firestore.UpdateDocument.

Fields
document
update_mask
mask
current_document

Value

A message that can hold any of the supported value types.

Fields
Union field value_type. Must have a value set. value_type can be only one of the following:
null_value
boolean_value
integer_value
double_value
timestamp_value
string_value
bytes_value
reference_value
geo_point_value
array_value
map_value
field_reference_value
variable_reference_value
function_value
pipeline_value

Write

A write on a document.

Fields
update_mask
update_transforms[]
current_document
Union field operation. The operation to execute. operation can be only one of the following:
update
delete
transform

WriteRequest

The request for Firestore.Write.

The first request creates a stream, or resumes an existing one from a token.

When creating a new stream, the server replies with a response containing only an ID and a token, to use in the next request.

When resuming a stream, the server first streams any responses later than the given token, then a response containing only an up-to-date token, to use in the next request.

Fields
database
stream_id
writes[]
stream_token
labels

WriteResponse

The response for Firestore.Write.

Fields
stream_id
stream_token
write_results[]
commit_time

WriteResult

The result of applying a write.

Fields
update_time
transform_results[]

Was this helpful?

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-04-25 UTC.

Need to tell us more?

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-04-25 UTC."],[],[]]

Chat

Ask about this page

bug_reportfullscreenclose_fullscreenclose

Chat

BETA

restart_alt

Sign in