A reference to a collection in a Firestore database.
The collection may already exist or this class can facilitate creation
of documents within the collection.
Parameters
Name
Description
path
Tuple[str, ...]
The components in the collection path. This is a series of strings representing each collection and sub-collection ID, as well as the document IDs for any documents that contain a sub-collection.
kwargs
dict
The keyword arguments for the constructor. The only supported keyword is client and it must be a Client if provided. It represents the client that created this collection reference.
Create a document in the Firestore database with the provided data.
Parameters
Name
Description
document_data
dict
Property names and values to use for creating the document.
document_id
Optional[str]
The document identifier within the current collection. If not provided, an ID will be automatically assigned by the server (the assigned ID will be a random 20 character string composed of digits, uppercase and lowercase letters).
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried. Defaults to a system-specified policy.
timeout
float
The timeout for this request. Defaults to a system-specified value.
Exceptions
Type
Description
google.cloud.exceptions.Conflict
If document_id is provided and the document already exists.
Create a sub-document underneath the current collection.
Parameter
Name
Description
document_id
Optional[str]
The document identifier within the current collection. If not provided, will default to a random 20 character string composed of digits, uppercase and lowercase and letters.
The maximum number of documents in each page of results from this request. Non-positive values are ignored. Defaults to a sensible value set by the API.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried. Defaults to a system-specified policy.
timeout
float
The timeout for this request. Defaults to a system-specified value.
Returns
Type
Description
Sequence[DocumentReference]
iterator of subdocuments of the current collection. If the collection does not exist at the time of snapshot, the iterator will be empty
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class AsyncCollectionReference (2.21.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.21.0 (latest)](/python/docs/reference/firestore/latest/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.20.2](/python/docs/reference/firestore/2.20.2/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.19.0](/python/docs/reference/firestore/2.19.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.18.0](/python/docs/reference/firestore/2.18.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.17.2](/python/docs/reference/firestore/2.17.2/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.16.1](/python/docs/reference/firestore/2.16.1/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.15.0](/python/docs/reference/firestore/2.15.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.14.0](/python/docs/reference/firestore/2.14.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.13.1](/python/docs/reference/firestore/2.13.1/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.12.0](/python/docs/reference/firestore/2.12.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.11.1](/python/docs/reference/firestore/2.11.1/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.10.1](/python/docs/reference/firestore/2.10.1/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.9.1](/python/docs/reference/firestore/2.9.1/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.8.0](/python/docs/reference/firestore/2.8.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.7.3](/python/docs/reference/firestore/2.7.3/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.6.1](/python/docs/reference/firestore/2.6.1/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.5.3](/python/docs/reference/firestore/2.5.3/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.4.0](/python/docs/reference/firestore/2.4.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.3.4](/python/docs/reference/firestore/2.3.4/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.2.0](/python/docs/reference/firestore/2.2.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.1.3](/python/docs/reference/firestore/2.1.3/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [2.0.2](/python/docs/reference/firestore/2.0.2/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [1.9.2](/python/docs/reference/firestore/1.9.2/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [1.8.1](/python/docs/reference/firestore/1.8.1/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [1.7.0](/python/docs/reference/firestore/1.7.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [1.6.2](/python/docs/reference/firestore/1.6.2/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [1.5.0](/python/docs/reference/firestore/1.5.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [1.4.0](/python/docs/reference/firestore/1.4.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference)\n- [1.3.0](/python/docs/reference/firestore/1.3.0/google.cloud.firestore_v1.async_collection.AsyncCollectionReference) \n\n AsyncCollectionReference(*path, **kwargs)\n\nA reference to a collection in a Firestore database.\n\nThe collection may already exist or this class can facilitate creation\nof documents within the collection.\n\nMethods\n-------\n\n### add\n\n add(\n document_data: dict,\n document_id: typing.Optional[str] = None,\n retry: (\n google.api_core.retry.retry_unary_async.AsyncRetry | object | None\n ) = _MethodDefault._DEFAULT_VALUE,\n timeout: typing.Optional[float] = None,\n ) -\u003e typing.Tuple[typing.Any, typing.Any]\n\nCreate a document in the Firestore database with the provided data.\n\n### document\n\n document(\n document_id: typing.Optional[str] = None,\n ) -\u003e google.cloud.firestore_v1.async_document.AsyncDocumentReference\n\nCreate a sub-document underneath the current collection.\n\n### get\n\n get(\n transaction: Optional[transaction.Transaction] = None,\n retry: retries.AsyncRetry | object | None = _MethodDefault._DEFAULT_VALUE,\n timeout: Optional[float] = None,\n *,\n explain_options: Optional[ExplainOptions] = None\n ) -\u003e QueryResultsList[DocumentSnapshot]\n\nRead the documents in this collection.\n\nThis sends a `RunQuery` RPC and returns a list of documents\nreturned in the stream of `RunQueryResponse` messages.\n\n### list_documents\n\n list_documents(\n page_size: typing.Optional[int] = None,\n retry: (\n google.api_core.retry.retry_unary_async.AsyncRetry | object | None\n ) = _MethodDefault._DEFAULT_VALUE,\n timeout: typing.Optional[float] = None,\n ) -\u003e typing.AsyncGenerator[google.cloud.firestore_v1.document.DocumentReference, None]\n\nList all subdocuments of the current collection.\n\n### stream\n\n stream(\n transaction: Optional[transaction.Transaction] = None,\n retry: retries.AsyncRetry | object | None = _MethodDefault._DEFAULT_VALUE,\n timeout: Optional[float] = None,\n *,\n explain_options: Optional[ExplainOptions] = None\n ) -\u003e AsyncStreamGenerator[DocumentSnapshot]\n\nRead the documents in this collection.\n\nThis sends a `RunQuery` RPC and then returns a generator which\nconsumes each document returned in the stream of `RunQueryResponse`\nmessages.\n| **Note:** The underlying stream of responses will time out after the `max_rpc_timeout_millis` value set in the GAPIC client configuration for the `RunQuery` API. Snapshots not consumed from the iterator before that point will be lost."]]