# Retrieve analytics data

> Retrieves analytics data for insights on user behavior and performance metrics to further use in charts.
>
> Rate limit: 2 requests per second.

## OpenAPI

```yaml
/api-specs/export-analytics-api.yaml post /api/v1/client-api/metrics/analytics/
openapi: 3.1.0
info:
  title: Adapty Export Analytics API
  version: 1.0.0
  description: |
    The Adapty Export Analytics API allows you to export your analytics data to CSV or JSON format, 
    giving you the flexibility to dive deeper into your app's performance metrics, customize reports, 
    and analyze trends over time. With this API, you can easily pull detailed analytics data, 
    making it convenient to track, share, and refine your data insights as needed.
servers:
  - url: https://api-admin.adapty.io
    description: Production server
security:
  - apikeyAuth: []
paths:
  /api/v1/client-api/metrics/analytics/:
    post:
      summary: Retrieve analytics data
      description: |-
        Retrieves analytics data for insights on user behavior and performance metrics to further use in charts.

        Rate limit: 2 requests per second.
      operationId: retrieveAnalyticsData
      security:
        - apikeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AnalyticsDataRequest"
            examples:
              basic:
                summary: Basic analytics data request
                value:
                  chart_id: revenue
                  filters:
                    date:
                      - "2024-01-01"
                      - "2024-12-31"
                    country:
                      - us
                    attribution_channel:
                      - social_media_influencers
                  period_unit: week
                  segmentation: attribution_campaign
      responses:
        "200":
          description: Analytics data retrieved successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AnalyticsDataResponse"
              example:
                data:
                  revenue:
                    data: []
                    value: 0
                    value_from: null
                    value_to: null
                    compare_value_from: null
                    compare_value_to: null
                    title: revenue
                    type: multi
                    default_aggregation: sum
                    description: |-
                      <div>Total money received from both subscriptions and one-time purchases. Does not include
                      revenue from subscriptions and purchases that were refunded afterward. Calculated before the store's fee.<br />
                      For example, there were 5 monthly $10 subs, 1 yearly $100 sub and 10 one-time $50 purchases today,<br />
                      revenue = 5*$10 + 1*$100 + 10*$50 = $650</div>
                    metric_name: Revenue
                    is_json: true
                    unit: USD
                    recommended_period: null
                  proceeds:
                    data: []
                    value: 0
                    value_from: null
                    value_to: null
                    compare_value_from: null
                    compare_value_to: null
                    title: revenue
                    type: multi
                    default_aggregation: sum
                    description: |-
                      <div>Total money received from both subscriptions and one-time purchases. Does not include
                      revenue from subscriptions and purchases that were refunded afterward. Calculated before the store's fee.<br />
                      For example, there were 5 monthly $10 subs, 1 yearly $100 sub and 10 one-time $50 purchases today,<br />
                      revenue = 5*$10 + 1*$100 + 10*$50 = $650</div>
                    metric_name: Revenue
                    is_json: true
                    unit: USD
                    recommended_period: null
                  net_revenue:
                    data: []
                    value: 0
                    value_from: null
                    value_to: null
                    compare_value_from: null
                    compare_value_to: null
                    title: revenue
                    type: multi
                    default_aggregation: sum
                    description: |-
                      <div>Total money received from both subscriptions and one-time purchases. Does not include
                      revenue from subscriptions and purchases that were refunded afterward. Calculated before the store's fee.<br />
                      For example, there were 5 monthly $10 subs, 1 yearly $100 sub and 10 one-time $50 purchases today,<br />
                      revenue = 5*$10 + 1*$100 + 10*$50 = $650</div>
                    metric_name: Revenue
                    is_json: true
                    unit: USD
                    recommended_period: null
            text/csv:
              schema:
                type: string
                description: Analytics data in CSV format
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedError"
        "429":
          description: Rate limit exceeded. Maximum 2 requests per second per API key.
components:
  schemas:
    AnalyticsDataRequest:
      type: object
      required:
        - chart_id
        - filters
      properties:
        chart_id:
          type: string
          enum:
            - revenue
            - mrr
            - arr
            - arppu
            - subscriptions_active
            - subscriptions_new
            - subscriptions_renewal_cancelled
            - subscriptions_expired
            - trials_active
            - trials_new
            - trials_renewal_cancelled
            - trials_expired
            - grace_period
            - billing_issue
            - refund_events
            - refund_money
            - non_subscriptions
            - arpu
            - installs
          description: Specify which chart you need. You can specify only one chart type in each request.
          example: revenue
        filters:
          $ref: "#/components/schemas/MetricsFilters"
        period_unit:
          type: string
          enum:
            - day
            - week
            - month
            - quarter
            - year
          description: Specify the time interval for aggregating analytics data
          default: month
        date_type:
          type: string
          enum:
            - purchase_date
            - profile_install_date
          description: Specify which date should be treated as a user joining date
          default: purchase_date
        segmentation:
          type: string
          description: Sets the basis for segmentation
        format:
          type: string
          enum:
            - json
            - csv
          description: Specify the export file format
          default: json
    AnalyticsDataResponse:
      type: object
      description: Response containing analytics data for the requested chart type
      properties:
        data:
          type: object
          description: Object containing different metric types (revenue, proceeds, net_revenue, etc.)
          additionalProperties:
            $ref: "#/components/schemas/MetricData"
    ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    UnauthorizedError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    MetricsFilters:
      type: object
      required:
        - date
      properties:
        date:
          type: array
          items:
            type: string
          description: Enter the date or time period for which you want to retrieve chart data
        compare_date:
          type: array
          items:
            type: string
          description: Enter the comparison date or time period
        store:
          type: array
          items:
            type: string
          description: Filter by the app store where the purchase was made
        country:
          type: array
          items:
            type: string
          description: Filter by the 2-letter country code where the purchase took place
        store_product_id:
          type: array
          items:
            type: string
          description: Unique identifier of a product from the app store
        duration:
          type: array
          items:
            type: string
          description: Specify the subscription duration
        attribution_source:
          type: array
          items:
            type: string
          description: The source integration for attribution
        attribution_status:
          type: array
          items:
            type: string
          description: Indicates if the attribution is organic or non-organic
        attribution_channel:
          type: array
          items:
            type: string
          description: Marketing channel that led to the transaction
        attribution_campaign:
          type: array
          items:
            type: string
          description: Marketing campaign that brought the transaction
        attribution_adgroup:
          type: array
          items:
            type: string
          description: Attribution ad group that brought the transaction
        attribution_adset:
          type: array
          items:
            type: string
          description: Attribution ad set that led to the transaction
        attribution_creative:
          type: array
          items:
            type: string
          description: Specific visual or text elements in an ad or campaign tracked to measure effectiveness
        offer_category:
          type: array
          items:
            type: string
          description: Specify the offer categories you want to retrieve data for
        offer_type:
          type: array
          items:
            type: string
          description: Specify the offer types you want to retrieve data for
        offer_id:
          type: array
          items:
            type: string
          description: Specify the specific offers you want to retrieve data for
    MetricData:
      type: object
      description: Individual metric data containing values, descriptions, and metadata
      properties:
        data:
          type: array
          description: Array of data points for the metric (can be empty for aggregated metrics)
          items:
            type: object
        value:
          type: number
          description: The main value for this metric
        value_from:
          type: number
          nullable: true
          description: Starting value for the period (if applicable)
        value_to:
          type: number
          nullable: true
          description: Ending value for the period (if applicable)
        compare_value_from:
          type: number
          nullable: true
          description: Starting value for comparison period (if applicable)
        compare_value_to:
          type: number
          nullable: true
          description: Ending value for comparison period (if applicable)
        title:
          type: string
          description: Display title for the metric
        type:
          type: string
          description: Type of metric (e.g., 'multi', 'single')
        default_aggregation:
          type: string
          description: Default aggregation method (e.g., 'sum', 'average')
        description:
          type: string
          description: HTML description explaining what this metric represents and how it's calculated
        metric_name:
          type: string
          description: Internal name of the metric
        is_json:
          type: boolean
          description: Whether the data is in JSON format
        unit:
          type: string
          description: Unit of measurement (e.g., 'USD', 'percent')
        recommended_period:
          type: object
          nullable: true
          description: Recommended date range for this metric
          properties:
            date_from:
              type: string
              description: Start date of recommended period
            date_to:
              type: string
              description: End date of recommended period
            period_unit:
              type: string
              description: Recommended period unit (day, week, month, etc.)
  securitySchemes:
    apikeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        You need to authenticate your API requests with your secret API key as an Authorization header. 
        You can find it in the App Settings. The format is `Api-Key {YOUR_SECRET_API_KEY}`, 
        for example: `Api-Key secret_live_...`.
```
