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

# Get Payment Statistics

> Get aggregated payment statistics across all developer's projects

Retrieve aggregated payment statistics across all projects owned by the authenticated developer. Includes subscription counts, payment totals, and revenue metrics.

## Authentication

<Note>
  This endpoint requires developer authentication via OAuth2 Bearer Token.
</Note>

## Query Parameters

<ParamField query="test_mode" type="boolean" default="true">
  Include test mode data in statistics. Set to `false` for live mode only.
</ParamField>

## Response

<ResponseField name="total_projects" type="integer">
  Total number of projects owned by the developer
</ResponseField>

<ResponseField name="projects_with_config" type="integer">
  Number of projects with Stripe configuration
</ResponseField>

<ResponseField name="projects_with_test" type="integer">
  Number of projects with test mode credentials
</ResponseField>

<ResponseField name="projects_with_live" type="integer">
  Number of projects with live mode credentials
</ResponseField>

<ResponseField name="total_subscriptions" type="integer">
  Total number of subscriptions across all projects
</ResponseField>

<ResponseField name="active_subscriptions" type="integer">
  Number of currently active subscriptions
</ResponseField>

<ResponseField name="total_payments" type="integer">
  Total number of payment transactions
</ResponseField>

<ResponseField name="successful_payments" type="integer">
  Number of successful payments
</ResponseField>

<ResponseField name="total_revenue_cents" type="integer">
  Total revenue in cents
</ResponseField>

<ResponseField name="currency" type="string" default="usd">
  Currency for revenue (lowercase ISO code)
</ResponseField>

## Example Request

```bash theme={null}
curl "https://api.devkit4ai.com/api/v1/payments/stats?test_mode=true" \
  -H "Authorization: Bearer {developer_jwt}"
```

## Example Response

```json theme={null}
{
  "total_projects": 3,
  "projects_with_config": 2,
  "projects_with_test": 2,
  "projects_with_live": 1,
  "total_subscriptions": 45,
  "active_subscriptions": 38,
  "total_payments": 127,
  "successful_payments": 120,
  "total_revenue_cents": 359700,
  "currency": "usd"
}
```

## Formatting Revenue

To display revenue as currency:

```javascript theme={null}
const revenue = stats.total_revenue_cents / 100;
const formatted = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: stats.currency.toUpperCase()
}).format(revenue);

// $3,597.00
```

## Dashboard Metrics

Use these statistics to build a developer dashboard:

```mermaid theme={null}
flowchart LR
    subgraph Projects
        A[Total: 3]
        B[Configured: 2]
    end
    
    subgraph Subscriptions
        C[Total: 45]
        D[Active: 38]
    end
    
    subgraph Revenue
        E[Payments: 120]
        F[$3,597.00]
    end
```

(((REPLACE\_THIS\_WITH\_IMAGE: cloud-admin-payment-stats-dashboard.png: Developer dashboard showing payment statistics with subscription counts, revenue chart, and project configuration status)))

## Key Metrics Explained

| Metric                 | Description                                      |
| ---------------------- | ------------------------------------------------ |
| `active_subscriptions` | Subscriptions with status `active` or `trialing` |
| `successful_payments`  | Payments with status `succeeded`                 |
| `total_revenue_cents`  | Sum of all successful payment amounts            |

<Warning>
  When `test_mode=true`, statistics include both test and live data. Set `test_mode=false` to see only production metrics.
</Warning>

## Related Pages

<CardGroup cols={2}>
  <Card title="List Subscriptions" icon="list" href="/cloud-api/payments/list-subscriptions">
    View all subscriptions
  </Card>

  <Card title="List Transactions" icon="receipt" href="/cloud-api/payments/list-transactions">
    View payment transactions
  </Card>

  <Card title="Console Statistics" icon="gauge" href="/cloud-admin/console/statistics">
    Cloud Admin statistics view
  </Card>
</CardGroup>


## OpenAPI

````yaml GET /api/v1/payments/stats
openapi: 3.1.0
info:
  title: Dev Kit for AI API
  description: 'API for Dev Kit for AI: Developer Toolkit for AI-Powered Web Applications'
  version: 1.6.1
servers:
  - url: https://api.devkit4ai.com
    description: Dev Kit for AI Production Server
  - url: https://api.vibecoding.ad
    description: Vibe Coding Production Server
security: []
paths:
  /api/v1/payments/stats:
    get:
      tags:
        - Payments
      summary: Get Payment Statistics
      description: >-
        Get aggregated payment statistics across all developer's projects
        including subscription counts, payment counts, and revenue.
      operationId: get_payment_stats_api_v1_payments_stats_get
      parameters:
        - name: test_mode
          in: query
          required: false
          schema:
            type: boolean
            description: Include test mode data
            default: true
            title: Test Mode
          description: Include test mode data
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentStatsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2PasswordBearer: []
components:
  schemas:
    PaymentStatsResponse:
      properties:
        total_projects:
          type: integer
          title: Total Projects
        projects_with_config:
          type: integer
          title: Projects With Config
        projects_with_test:
          type: integer
          title: Projects With Test
        projects_with_live:
          type: integer
          title: Projects With Live
        total_subscriptions:
          type: integer
          title: Total Subscriptions
        active_subscriptions:
          type: integer
          title: Active Subscriptions
        total_payments:
          type: integer
          title: Total Payments
        successful_payments:
          type: integer
          title: Successful Payments
        total_revenue_cents:
          type: integer
          title: Total Revenue Cents
        currency:
          type: string
          title: Currency
          default: usd
      type: object
      required:
        - total_projects
        - projects_with_config
        - projects_with_test
        - projects_with_live
        - total_subscriptions
        - active_subscriptions
        - total_payments
        - successful_payments
        - total_revenue_cents
      title: PaymentStatsResponse
      description: Aggregated payment statistics.
    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
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2PasswordBearer:
      type: oauth2
      flows:
        password:
          scopes: {}
          tokenUrl: auth/login

````