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

# Get sales data with filtering 

> Get sales data with revenue breakdown, filtered by month/week. This is a public API that requires a fermion API key.

Authentication with the "FERMION-API-KEY" header is required to use this endpoint.

Rate limit: Maximum 30 requests in a window of 1m.



## OpenAPI

````yaml https://backend.codedamn.com/webhook/fermion-backend-openapi.yaml post /public/get-sales-data
openapi: 3.0.0
info:
  version: 1.0.0
  title: Fermion Backend API
  description: Documentation for interacting with the Fermion API
  contact:
    name: Fermion Support
    email: support@codedamn.com
servers:
  - url: https://backend.codedamn.com/api
    description: Fermion primary backend server
security: []
externalDocs:
  description: Fermion Docs
  url: https://docs.fermion.app
paths:
  /public/get-sales-data:
    post:
      tags:
        - Analytics
      summary: 'Get sales data with filtering '
      description: >-
        Get sales data with revenue breakdown, filtered by month/week. This is a
        public API that requires a fermion API key.


        Authentication with the "FERMION-API-KEY" header is required to use this
        endpoint.


        Rate limit: Maximum 30 requests in a window of 1m.
      requestBody:
        description: API Request Body
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: array
                  items:
                    type: object
                    properties:
                      data:
                        type: object
                        properties:
                          from:
                            type: string
                            description: >-
                              Start date - accepts formats like "2024-01-01",
                              "Jan 1 2024", "1/1/2024", "January 1, 2024",
                              "01-Jan-2024"
                          to:
                            type: string
                            description: >-
                              End date - accepts formats like "2024-12-31", "Dec
                              31 2024", "12/31/2024", "December 31, 2024",
                              "31-Dec-2024"
                          groupBy:
                            type: string
                            enum:
                              - week
                              - month
                            description: Group revenue data by week or month
                          timezone:
                            anyOf:
                              - type: string
                              - nullable: true
                              - nullable: true
                            description: >-
                              Timezone for date calculations (e.g.,
                              "America/New_York")
                          shouldIncludeBreakdown:
                            type: boolean
                            default: true
                            description: >-
                              Include detailed breakdown of revenue by product
                              type
                          productTypeFilter:
                            anyOf:
                              - type: array
                                items:
                                  type: string
                                  enum:
                                    - FermionDigitalProduct
                                    - Course
                                    - LearningPath
                                    - Pro
                                minItems: 1
                              - nullable: true
                              - nullable: true
                            description: >-
                              Filter sales by specific product types (must not
                              be empty if provided)
                          paymentStatusFilter:
                            anyOf:
                              - type: array
                                items:
                                  type: string
                                  enum:
                                    - Valid
                                    - Refunded
                                minItems: 1
                              - nullable: true
                              - nullable: true
                            description: >-
                              Filter sales by payment status (must not be empty
                              if provided)
                        required:
                          - from
                          - to
                          - groupBy
                    required:
                      - data
              required:
                - data
      responses:
        '200':
          description: API Response Body
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    output:
                      anyOf:
                        - type: object
                          properties:
                            status:
                              type: string
                              enum:
                                - ok
                            data:
                              type: object
                              properties:
                                summary:
                                  type: object
                                  properties:
                                    totalRevenueInrPaise:
                                      type: number
                                      description: >-
                                        Total revenue for the period in INR
                                        paise
                                    totalSalesCount:
                                      type: number
                                      description: Total number of sales for the period
                                    averageSaleValueInrPaise:
                                      type: number
                                      description: Average sale value in INR paise
                                    periodStart:
                                      type: string
                                      format: date-time
                                      description: Start of the reporting period
                                    periodEnd:
                                      type: string
                                      format: date-time
                                      description: End of the reporting period
                                  required:
                                    - totalRevenueInrPaise
                                    - totalSalesCount
                                    - averageSaleValueInrPaise
                                    - periodStart
                                    - periodEnd
                                revenueByPeriod:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      period:
                                        type: string
                                        description: >-
                                          Period label (e.g., "1st Jan 2024",
                                          "Week 1 2024", "Jan 2024")
                                      startDate:
                                        type: string
                                        format: date-time
                                        description: Start date of this period
                                      endDate:
                                        type: string
                                        format: date-time
                                        description: End date of this period
                                      totalRevenuePaise:
                                        type: number
                                        description: Total revenue for this period in paise
                                      salesCount:
                                        type: number
                                        description: Number of sales in this period
                                      breakdown:
                                        anyOf:
                                          - type: array
                                            items:
                                              type: object
                                              properties:
                                                productType:
                                                  type: string
                                                  enum:
                                                    - Course
                                                    - LearningPath
                                                    - Pro
                                                    - FermionDigitalProduct
                                                    - FermionLedgerInvoicePayment
                                                    - FermionSchoolPlanCycleInvoice
                                                    - FermionCourse
                                                  description: Type of product
                                                revenuePaise:
                                                  type: number
                                                  description: Revenue from this product type in paise
                                                salesCount:
                                                  type: number
                                                  description: Number of sales for this product type
                                              required:
                                                - productType
                                                - revenuePaise
                                                - salesCount
                                          - nullable: true
                                          - nullable: true
                                        description: >-
                                          Revenue breakdown by product type (if
                                          includeBreakdown is true)
                                    required:
                                      - period
                                      - startDate
                                      - endDate
                                      - totalRevenuePaise
                                      - salesCount
                                  description: Revenue data grouped by the specified period
                                topProducts:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      productId:
                                        type: string
                                        description: Unique identifier of the product
                                      productName:
                                        type: string
                                        description: Name of the product
                                      productType:
                                        type: string
                                        enum:
                                          - Course
                                          - LearningPath
                                          - Pro
                                          - FermionDigitalProduct
                                          - FermionLedgerInvoicePayment
                                          - FermionSchoolPlanCycleInvoice
                                          - FermionCourse
                                        description: Type of product
                                      totalRevenuePaise:
                                        type: number
                                        description: Total revenue from this product in paise
                                      salesCount:
                                        type: number
                                        description: Number of sales for this product
                                    required:
                                      - productId
                                      - productName
                                      - productType
                                      - totalRevenuePaise
                                      - salesCount
                                  description: Top 10 products by revenue for the period
                              required:
                                - summary
                                - revenueByPeriod
                                - topProducts
                          required:
                            - status
                            - data
                        - type: object
                          properties:
                            status:
                              type: string
                              enum:
                                - error
                            errorMessage:
                              type: string
                          required:
                            - status
                            - errorMessage
                  required:
                    - output
      security:
        - FERMION-API-KEY: []
components:
  securitySchemes:
    FERMION-API-KEY:
      name: FERMION-API-KEY
      type: apiKey
      in: header

````