Google Cloud Firestore Documents API

Operations on Firestore documents

OpenAPI Specification

google-cloud-firestore-documents-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Google Cloud Firestore Databases Documents API
  description: The Cloud Firestore API provides RESTful access to Google Cloud Firestore, a flexible, scalable NoSQL cloud database for storing and syncing data. It enables CRUD operations on documents and collections, querying with filters and ordering, managing indexes, and handling real-time data synchronization across client apps.
  version: v1
  contact:
    name: Google Cloud
    url: https://cloud.google.com/firestore/docs/reference/rest
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
- url: https://firestore.googleapis.com/v1
  description: Cloud Firestore API v1
tags:
- name: Documents
  description: Operations on Firestore documents
paths:
  /projects/{project}/databases/{database}/documents/{collectionId}:
    get:
      tags:
      - Documents
      summary: Google Cloud Firestore List documents
      description: Lists documents in a collection.
      operationId: listDocuments
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      - name: database
        in: path
        required: true
        schema:
          type: string
      - name: collectionId
        in: path
        required: true
        schema:
          type: string
      - name: pageSize
        in: query
        schema:
          type: integer
      - name: pageToken
        in: query
        schema:
          type: string
      - name: orderBy
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListDocumentsResponse'
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
        - https://www.googleapis.com/auth/datastore
    post:
      tags:
      - Documents
      summary: Google Cloud Firestore Create a document
      description: Creates a new document in the specified collection.
      operationId: createDocument
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      - name: database
        in: path
        required: true
        schema:
          type: string
      - name: collectionId
        in: path
        required: true
        schema:
          type: string
      - name: documentId
        in: query
        description: Optional client-assigned document ID.
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Document'
      responses:
        '200':
          description: Document created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
        - https://www.googleapis.com/auth/datastore
  /projects/{project}/databases/{database}/documents/{collectionId}/{documentId}:
    get:
      tags:
      - Documents
      summary: Google Cloud Firestore Get a document
      description: Gets a single document.
      operationId: getDocument
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      - name: database
        in: path
        required: true
        schema:
          type: string
      - name: collectionId
        in: path
        required: true
        schema:
          type: string
      - name: documentId
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
        '404':
          description: Document not found
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
        - https://www.googleapis.com/auth/datastore
    patch:
      tags:
      - Documents
      summary: Google Cloud Firestore Update a document
      description: Updates or inserts a document.
      operationId: updateDocument
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      - name: database
        in: path
        required: true
        schema:
          type: string
      - name: collectionId
        in: path
        required: true
        schema:
          type: string
      - name: documentId
        in: path
        required: true
        schema:
          type: string
      - name: updateMask.fieldPaths
        in: query
        schema:
          type: array
          items:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Document'
      responses:
        '200':
          description: Document updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
        - https://www.googleapis.com/auth/datastore
    delete:
      tags:
      - Documents
      summary: Google Cloud Firestore Delete a document
      description: Deletes a document.
      operationId: deleteDocument
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      - name: database
        in: path
        required: true
        schema:
          type: string
      - name: collectionId
        in: path
        required: true
        schema:
          type: string
      - name: documentId
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Document deleted successfully
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
        - https://www.googleapis.com/auth/datastore
  /projects/{project}/databases/{database}/documents:runQuery:
    post:
      tags:
      - Documents
      summary: Google Cloud Firestore Run a query
      description: Runs a structured query against a Firestore database.
      operationId: runQuery
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      - name: database
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunQueryRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/RunQueryResponse'
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
        - https://www.googleapis.com/auth/datastore
components:
  schemas:
    Value:
      type: object
      properties:
        nullValue:
          type: string
        booleanValue:
          type: boolean
        integerValue:
          type: string
        doubleValue:
          type: number
        timestampValue:
          type: string
          format: date-time
        stringValue:
          type: string
        bytesValue:
          type: string
          format: byte
        referenceValue:
          type: string
        geoPointValue:
          type: object
          properties:
            latitude:
              type: number
            longitude:
              type: number
        arrayValue:
          type: object
          properties:
            values:
              type: array
              items:
                $ref: '#/components/schemas/Value'
        mapValue:
          type: object
          properties:
            fields:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/Value'
    RunQueryResponse:
      type: object
      properties:
        document:
          $ref: '#/components/schemas/Document'
        readTime:
          type: string
          format: date-time
        skippedResults:
          type: integer
    Document:
      type: object
      properties:
        name:
          type: string
          description: The resource name of the document.
        fields:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Value'
          description: The document's fields.
        createTime:
          type: string
          format: date-time
        updateTime:
          type: string
          format: date-time
    RunQueryRequest:
      type: object
      properties:
        structuredQuery:
          type: object
          properties:
            from:
              type: array
              items:
                type: object
                properties:
                  collectionId:
                    type: string
                  allDescendants:
                    type: boolean
            where:
              type: object
            orderBy:
              type: array
              items:
                type: object
            limit:
              type: integer
            offset:
              type: integer
    ListDocumentsResponse:
      type: object
      properties:
        documents:
          type: array
          items:
            $ref: '#/components/schemas/Document'
        nextPageToken:
          type: string
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://accounts.google.com/o/oauth2/auth
          tokenUrl: https://oauth2.googleapis.com/token
          scopes:
            https://www.googleapis.com/auth/cloud-platform: Full access to Cloud Platform
            https://www.googleapis.com/auth/datastore: View and manage Firestore data