> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salesive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get order statistics

> Get aggregate order counts and revenue grouped by status for the store. Requires the READ_ORDERS scope.

Returns counts and revenue amounts per status bucket (total, pending, processing, completed, cancelled, refunded), with optional date-range filtering. The store is bound to your app token server-side — never send a shop id.


## OpenAPI

````yaml GET /orders/stats
openapi: 3.1.0
info:
  title: Salesive Apps API — Orders
  version: 1.0.0
  description: >-
    Read and manage the store's orders from an installed third-party app. Every
    endpoint authenticates with an installed-app access token (prefix `app_`)
    and requires a specific OAuth scope. The target store is bound to the token
    server-side from the installation — never send a shop id.
servers:
  - url: https://api.salesive.com/api/v1
    description: Production
security:
  - AppToken: []
paths:
  /orders/stats:
    get:
      tags:
        - Orders
      summary: Get order statistics
      description: >-
        Returns aggregate order counts and revenue amounts grouped by status for
        the store (overall total plus pending, processing, completed, cancelled
        and refunded buckets). The `completed` bucket corresponds to paid
        orders. Only date-range filtering is applied; status/user query params
        are ignored. Amounts are computed as subtotal + shippingCost - discount
        (floored at 0). Requires the `READ_ORDERS` scope. The store is bound to
        the app token server-side from the installation — never send a shop id.
      operationId: getOrderStats
      parameters:
        - $ref: '#/components/parameters/StartDateFilter'
        - $ref: '#/components/parameters/EndDateFilter'
      responses:
        '200':
          description: Aggregate counts and revenue per status bucket.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/EnvelopeBase'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          total:
                            $ref: '#/components/schemas/StatBucket'
                          pending:
                            $ref: '#/components/schemas/StatBucket'
                          processing:
                            $ref: '#/components/schemas/StatBucket'
                          completed:
                            $ref: '#/components/schemas/StatBucket'
                          cancelled:
                            $ref: '#/components/schemas/StatBucket'
                          refunded:
                            $ref: '#/components/schemas/StatBucket'
              example:
                status: 200
                success: true
                message: Order statistics retrieved
                data:
                  total:
                    count: 128
                    amount: 3120450
                  pending:
                    count: 12
                    amount: 289900
                  processing:
                    count: 8
                    amount: 190050
                  completed:
                    count: 96
                    amount: 2510500
                  cancelled:
                    count: 9
                    amount: 110000
                  refunded:
                    count: 3
                    amount: 20000
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  parameters:
    StartDateFilter:
      name: startDate
      in: query
      required: false
      description: >-
        Inclusive lower bound on order creation date (ISO 8601, filters
        createdAt).
      schema:
        type: string
        format: date-time
    EndDateFilter:
      name: endDate
      in: query
      required: false
      description: >-
        Inclusive upper bound on order creation date (ISO 8601, filters
        createdAt).
      schema:
        type: string
        format: date-time
  schemas:
    EnvelopeBase:
      type: object
      description: >-
        Standard Salesive response envelope. The operation-specific payload is
        carried in `data`.
      required:
        - status
        - success
        - message
      properties:
        status:
          type: integer
          description: HTTP status code, echoed in the body.
        success:
          type: boolean
          description: Whether the request succeeded.
        message:
          type: string
          description: Human-readable result message.
    StatBucket:
      type: object
      description: Count and revenue amount for one status bucket.
      properties:
        count:
          type: integer
        amount:
          type: number
    Envelope:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          properties:
            data:
              description: Operation-specific payload (object, array, or null).
  responses:
    Unauthorized:
      description: Missing or invalid app access token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 401
            success: false
            message: Authentication required
            data: null
    Forbidden:
      description: The app token is missing the OAuth scope required for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 403
            success: false
            message: Insufficient scope
            data: null
  securitySchemes:
    AppToken:
      type: http
      scheme: bearer
      description: >-
        Installed-app access token (prefix app_), issued by the OAuth install
        flow. The store is bound to the token server-side — never send a shop
        id.

````