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

# Získat statistiky kreditů

> Načtení agregovaných statistik využití kreditů za období, připravených pro BI nástroje jako Power BI nebo Looker.

## Význam metrik

* `from` a `to` jsou včetně krajních dat ve formátu `YYYY-MM-DD`. Maximální rozsah je 1 830 dní.
* `summary.previous_period_spent` používá stejně dlouhé období bezprostředně před `from`.
* `daily`, `by_module`, `by_service` a `by_user` představují různé agregace stejné kreditní knihy.
* `lasso.products_enhanced` je snapshot obohacených řádků v odpovídajících tabulkách, zatímco `lasso.credits_per_product` dělí kreditní výdaje Lasso ve zvoleném období tímto počtem.
* `currency_config` odráží firemní nastavení fakturační měny a ceny za kredit.

Publikované TypeScript a Python SDK tento endpoint zatím neposkytují. Volejte ho přímo přes HTTP.

## Příděl a náklady

`summary.monthly_allocation` je pravidelný měsíční příděl, nikoli zbývající zůstatek nebo součet zakoupených balíčků. `summary.cost_per_credit` a `currency_config` používají nastavené poplatky a příděl předplatného; nevyjadřují skutečnou cenu konkrétního jednorázového nákupu.

Pro dostupný zůstatek použijte [zůstatek kreditů](https://productlasso.com/docs/cs/api-reference/credits/balance.md). Platnost balíčků zkontrolujte v přehledu kreditů v aplikaci.


## OpenAPI

````yaml openapi.yaml GET /credits/stats
openapi: 3.1.0
info:
  title: Lasso API
  description: AI-powered product data extraction and enhancement API
  version: 1.0.0
  contact:
    name: Lasso Support
    url: https://lasso.ai
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://app.productlasso.com/api/v1
    description: Production
security:
  - BearerAuth: []
paths:
  /credits/stats:
    get:
      tags:
        - Credits
      summary: Get aggregated credit usage statistics
      description: >-
        Returns company credit usage for an inclusive date range together with
        the equally sized preceding period. The maximum range is 1,830 days.
      operationId: getCreditStats
      parameters:
        - name: from
          in: query
          required: true
          schema:
            type: string
            format: date
          description: Inclusive start date in YYYY-MM-DD format.
        - name: to
          in: query
          required: true
          schema:
            type: string
            format: date
          description: Inclusive end date in YYYY-MM-DD format.
      responses:
        '200':
          description: Aggregated credit usage statistics.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditStats'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |
            curl --request GET \
              --url "https://app.productlasso.com/api/v1/credits/stats?from=2026-08-01&to=2026-08-31" \
              --header "Authorization: Bearer $LASSO_API_KEY"
        - lang: typescript
          label: TypeScript
          source: >
            const params = new URLSearchParams({ from: "2026-08-01", to:
            "2026-08-31" });

            const response = await fetch(
              `https://app.productlasso.com/api/v1/credits/stats?${params}`,
              { headers: { Authorization: `Bearer ${process.env.LASSO_API_KEY}` } },
            );


            if (!response.ok) throw new Error(await response.text());

            const stats = await response.json();
        - lang: python
          label: Python
          source: |
            import os
            import requests

            response = requests.get(
                "https://app.productlasso.com/api/v1/credits/stats",
                headers={"Authorization": f"Bearer {os.environ['LASSO_API_KEY']}"},
                params={"from": "2026-08-01", "to": "2026-08-31"},
                timeout=30,
            )
            response.raise_for_status()
            stats = response.json()
components:
  schemas:
    CreditStats:
      type: object
      required:
        - period
        - summary
        - daily
        - by_module
        - by_service
        - by_user
        - lasso
        - currency_config
      properties:
        period:
          type: object
          required:
            - from
            - to
          properties:
            from:
              type: string
              format: date
            to:
              type: string
              format: date
        summary:
          type: object
          required:
            - total_spent
            - previous_period_spent
            - previous_period_change_pct
            - monthly_allocation
            - period_end
            - cost_per_credit
          properties:
            total_spent:
              type: number
            previous_period_spent:
              type: number
            previous_period_change_pct:
              type:
                - number
                - 'null'
            monthly_allocation:
              type: number
              description: >-
                Regular monthly allowance, not remaining credits or purchased
                package totals.
            period_end:
              type:
                - string
                - 'null'
              format: date-time
            cost_per_credit:
              description: >-
                Reporting rate based on configured subscription fees and
                allowance, not the actual price paid for a one-time package.
              oneOf:
                - type: object
                  required:
                    - amount
                    - currency
                    - monthly_fee
                    - monthly_credits
                  properties:
                    amount:
                      type: number
                    currency:
                      type: string
                      enum:
                        - CZK
                        - EUR
                    monthly_fee:
                      type: number
                    monthly_credits:
                      type: number
                - type: 'null'
        daily:
          type: array
          items:
            type: object
            required:
              - date
              - total
              - by_module
              - by_user
            properties:
              date:
                type: string
                format: date
              total:
                type: number
              by_module:
                type: object
                additionalProperties:
                  type: number
              by_user:
                type: object
                additionalProperties:
                  type: number
        by_module:
          type: array
          items:
            type: object
            required:
              - module_key
              - total
            properties:
              module_key:
                type: string
              total:
                type: number
        by_service:
          type: array
          items:
            type: object
            required:
              - service_type
              - total
            properties:
              service_type:
                type: string
              total:
                type: number
        by_user:
          type: array
          items:
            type: object
            required:
              - user_id
              - total
            properties:
              user_id:
                type: string
                description: User UUID or `system` for unattributed usage.
              total:
                type: number
        lasso:
          type: object
          required:
            - credits_spent
            - products_enhanced
            - credits_per_product
            - by_table
          properties:
            credits_spent:
              type: number
            products_enhanced:
              type: number
            credits_per_product:
              type:
                - number
                - 'null'
            by_table:
              type: array
              items:
                type: object
                required:
                  - table_id
                  - name
                  - total
                  - products
                properties:
                  table_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                  name:
                    type: string
                  total:
                    type: number
                  products:
                    type: number
        currency_config:
          type: object
          required:
            - monthly_fee_czk
            - monthly_fee_eur
            - monthly_credits
            - auto_eur
          properties:
            monthly_fee_czk:
              type:
                - number
                - 'null'
            monthly_fee_eur:
              type:
                - number
                - 'null'
            monthly_credits:
              type: number
            auto_eur:
              type: boolean
    Error:
      type: object
      required:
        - status_code
        - error_type
        - message
        - request_id
      properties:
        status_code:
          type: integer
        error_type:
          type: string
          enum:
            - invalid_request
            - unauthenticated
            - forbidden
            - not_found
            - conflict
            - validation_error
            - rate_limited
            - service_unavailable
            - internal_error
        message:
          type: string
        request_id:
          type: string
        code:
          type: string
          description: >-
            Stable machine-readable detail code for validation, conflict, and
            retryable availability errors.
        retryable:
          type: boolean
          description: Whether the request can be retried without changing its payload.
        attribute_id:
          type: string
          format: uuid
          description: Stable Attribute identity when the error is scoped to one Attribute.
        attribute_key:
          type: string
          description: Attribute key when the error is scoped to one Attribute.
        details:
          type: object
          additionalProperties: true
        current_updated_at:
          type: string
          format: date-time
          description: >-
            Current resource revision supplied for client-directed refetch after
            a stale write.
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.