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

# Get Analytics Trends

> Return time-series transaction data bucketed by *granularity*.

The aggregation groups transactions by day in MongoDB, then Python
re-buckets the daily totals into week/month windows.  This avoids
MongoDB version-specific ``$dateTrunc`` syntax.



## OpenAPI

````yaml https://api.loyalty.dog/openapi.json get /v2/giftcards/programs/{programId}/analytics/trends
openapi: 3.1.0
info:
  title: LoyaltyDog
  description: >-

    Welcome to the LoyaltyDog API! This API provides access to our loyalty
    program features, allowing you to integrate with various platforms and
    manage your loyalty data.


    Want to query LoyaltyDog via an AI assistant (Claude, Cursor, Windsurf)? See
    the [MCP Integration guide](https://loyaltydog.ai/playground#mcp).
        
  termsOfService: https://loyalty.dog/loyalty-program-terms-service
  contact:
    name: LoyaltyDog Support
    url: https://loyalty.dog/contact-us
    email: support@loyalty.dog
  version: 1.0.1
servers:
  - url: https://api.loyalty.dog
    description: Production
security:
  - bearerAuth: []
paths:
  /v2/giftcards/programs/{programId}/analytics/trends:
    get:
      tags:
        - Gift Card Analytics
      summary: Get Analytics Trends
      description: |-
        Return time-series transaction data bucketed by *granularity*.

        The aggregation groups transactions by day in MongoDB, then Python
        re-buckets the daily totals into week/month windows.  This avoids
        MongoDB version-specific ``$dateTrunc`` syntax.
      operationId: >-
        get_analytics_trends_v2_giftcards_programs__programId__analytics_trends_get
      parameters:
        - name: programId
          in: path
          required: true
          schema:
            anyOf:
              - $ref: '#/components/schemas/PydanticObjectId'
              - type: 'null'
            title: Programid
        - name: period
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                pattern: ^(7d|30d|90d|12m|custom)$
              - type: 'null'
            title: Period
        - name: granularity
          in: query
          required: false
          schema:
            type: string
            default: daily
            title: Granularity
        - name: from
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: From
        - name: to
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: To
        - name: cardId
          in: query
          required: false
          schema:
            anyOf:
              - $ref: '#/components/schemas/PydanticObjectId'
              - type: 'null'
            title: Cardid
        - name: X-Eposn-Customer-Token
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Eposn-Customer-Token
        - name: X-Eposn-Merchant-Token
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Eposn-Merchant-Token
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    PydanticObjectId:
      type: string
      maxLength: 24
      minLength: 24
      pattern: ^[0-9a-f]{24}$
      example: 5eb7cf5a86d9755df3a6c593
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT access token obtained from POST /v2/token.

````