{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/appy-to/json-schema/appy-to-app-stats-schema.json",
  "title": "AppStats",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/appy-to-openapi.yaml#/components/schemas/AppStats",
  "type": "object",
  "required": [
    "appId",
    "start",
    "end",
    "installs",
    "daily",
    "sources",
    "events",
    "links"
  ],
  "properties": {
    "appId": {
      "type": "string",
      "format": "uuid"
    },
    "start": {
      "type": "string",
      "format": "date"
    },
    "end": {
      "type": "string",
      "format": "date"
    },
    "installs": {
      "type": "object",
      "required": [
        "total",
        "attributed",
        "verified",
        "organic",
        "byStore",
        "byNetwork"
      ],
      "properties": {
        "total": {
          "type": "integer",
          "description": "Installs whose first open happened in the window."
        },
        "attributed": {
          "type": "integer",
          "description": "Installs Appy matched to a link."
        },
        "verified": {
          "type": "integer",
          "description": "Attributed installs that are verified: the link opened the app, its click came back in the\ndeep link, or the store's install referrer carried it. With strict attribution on, every\nattributed install is verified.\n"
        },
        "organic": {
          "type": "integer",
          "description": "Installs without a link."
        },
        "byStore": {
          "type": "object",
          "description": "All installs by the store that installed the app: `app_store` for iOS, and on Android the\ninstaller reported by the device (`google_play`, `huawei_appgallery`, `samsung_galaxy_store`,\n`xiaomi_getapps`, `vivo_app_store`, `oppo_app_market`, `rustore`, `amazon_appstore`), `other`\nfor any other installer and `unknown` for sideloaded or unreported installs. Keys with no\ninstalls are omitted.\n",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "byNetwork": {
          "type": "object",
          "description": "Attributed installs by source: `link` for Appy links, `apple_ads`, `google_ads`, `meta` or `tiktok`\nfor installs an ad network's own data attributed. Keys with no installs are omitted.\n",
          "additionalProperties": {
            "type": "integer"
          }
        }
      }
    },
    "retention": {
      "type": "object",
      "description": "Day-N cohort retention based on subsequent app opens and events.",
      "required": [
        "days",
        "milestones",
        "cohorts"
      ],
      "properties": {
        "days": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "milestones": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "day",
              "installs",
              "retained",
              "rate"
            ],
            "properties": {
              "day": {
                "type": "integer"
              },
              "installs": {
                "type": "integer",
                "description": "Eligible installs from cohorts at least `day` days old."
              },
              "retained": {
                "type": "integer",
                "description": "Installs active on day `day` after install."
              },
              "rate": {
                "type": "number",
                "description": "Ratio from 0 to 1."
              }
            }
          }
        },
        "cohorts": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "date",
              "installs",
              "retained"
            ],
            "properties": {
              "date": {
                "type": "string",
                "format": "date"
              },
              "installs": {
                "type": "integer"
              },
              "retained": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "daily": {
      "type": "array",
      "description": "One row per UTC day of the window, oldest first, with zeros on days without activity.",
      "items": {
        "type": "object",
        "required": [
          "date",
          "installs",
          "attributed",
          "organic",
          "events",
          "revenue"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "installs": {
            "type": "integer",
            "description": "Installs first seen that day."
          },
          "attributed": {
            "type": "integer"
          },
          "organic": {
            "type": "integer"
          },
          "events": {
            "type": "integer",
            "description": "Events that happened that day."
          },
          "revenue": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/RevenueAmount"
            }
          }
        }
      }
    },
    "sources": {
      "type": "array",
      "description": "Attributed installs grouped by the `utm_source`, `utm_medium` and `utm_campaign` of the click,\nat most 50 rows ordered by installs. A null value means the link carried no such parameter; a\nrow with all three null holds the installs without UTM values. Organic installs are not listed.\n",
      "items": {
        "type": "object",
        "required": [
          "source",
          "medium",
          "campaign",
          "installs",
          "events",
          "revenue"
        ],
        "properties": {
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "medium": {
            "type": [
              "string",
              "null"
            ]
          },
          "campaign": {
            "type": [
              "string",
              "null"
            ]
          },
          "installs": {
            "type": "integer"
          },
          "events": {
            "type": "integer"
          },
          "revenue": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/RevenueAmount"
            }
          }
        }
      }
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "count",
          "revenue"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "revenue": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/RevenueAmount"
            }
          }
        }
      }
    },
    "links": {
      "type": "array",
      "description": "Up to 100 links ordered by installs.",
      "items": {
        "type": "object",
        "required": [
          "slug",
          "installs",
          "verified",
          "events",
          "revenue"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "installs": {
            "type": "integer"
          },
          "verified": {
            "type": "integer",
            "description": "Installs from this link that are verified."
          },
          "events": {
            "type": "integer"
          },
          "revenue": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/RevenueAmount"
            }
          }
        }
      }
    }
  },
  "$defs": {
    "RevenueAmount": {
      "type": "object",
      "required": [
        "currency",
        "amount"
      ],
      "properties": {
        "currency": {
          "type": "string"
        },
        "amount": {
          "type": "string",
          "description": "Decimal sum as a string to avoid rounding."
        }
      }
    }
  }
}