{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cspriceapi-com/json-schema/cspriceapi-com-market-cap-response-schema.json",
  "title": "MarketCapResponse",
  "description": "Aggregate YouPin market-cap envelope.",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cspriceapi-com-indexes-api-openapi.yml#/components/schemas/MarketCapResponse",
  "type": "object",
  "properties": {
    "currency": {
      "type": "string",
      "enum": [
        "CNY"
      ]
    },
    "resolution": {
      "type": "string",
      "enum": [
        "daily",
        "hourly"
      ]
    },
    "days": {
      "type": "integer",
      "description": "Present for `resolution=daily`."
    },
    "hours": {
      "type": "integer",
      "description": "Present for `resolution=hourly`."
    },
    "cleaned": {
      "type": "boolean",
      "description": "`true` when outlier filters were applied. `false` when the\nprecomputed `market_cap_daily` fallback was used.\n"
    },
    "formula": {
      "type": "string"
    },
    "filters": {
      "type": "object",
      "properties": {
        "max_price_rmb": {
          "type": "integer"
        },
        "min_listings": {
          "type": "integer"
        }
      }
    },
    "current": {
      "description": "Latest point in the returned series, or `null` if empty.",
      "nullable": true,
      "oneOf": [
        {
          "$ref": "#/$defs/MarketCapPointDaily"
        },
        {
          "$ref": "#/$defs/MarketCapPointHourly"
        }
      ]
    },
    "change_7d": {
      "allOf": [
        {
          "$ref": "#/$defs/DecimalString"
        }
      ],
      "nullable": true,
      "description": "Percent change vs ~7 days earlier. `null` if not enough history."
    },
    "change_range": {
      "allOf": [
        {
          "$ref": "#/$defs/DecimalString"
        }
      ],
      "nullable": true,
      "description": "Percent change from the first to the last point in this response."
    },
    "from": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "First daily point (`resolution=daily` only)."
    },
    "to": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "Last daily point (`resolution=daily` only)."
    },
    "count": {
      "type": "integer"
    },
    "data": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/MarketCapPointDaily"
          },
          {
            "$ref": "#/$defs/MarketCapPointHourly"
          }
        ]
      }
    },
    "source": {
      "type": "string"
    },
    "requestor": {
      "type": "string",
      "format": "email"
    },
    "plan": {
      "type": "string"
    },
    "timestamp": {
      "$ref": "#/$defs/UpdatedAt"
    }
  },
  "required": [
    "currency",
    "resolution",
    "cleaned",
    "count",
    "data",
    "source",
    "timestamp"
  ],
  "$defs": {
    "DecimalString": {
      "type": "string",
      "description": "Fixed-point decimal value serialized as a string (preserves precision\nacross languages). Parse with an arbitrary-precision decimal library;\ndo **not** parse as a native float.\n",
      "pattern": "^-?\\d+(\\.\\d+)?$"
    },
    "MarketCapPointDaily": {
      "type": "object",
      "properties": {
        "day": {
          "type": "string",
          "format": "date"
        },
        "market_cap_rmb": {
          "allOf": [
            {
              "$ref": "#/$defs/DecimalString"
            }
          ],
          "description": "Aggregate YouPin market cap for that day, in CNY."
        },
        "listing_count": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Sum of listing counts included in the cap."
        }
      },
      "required": [
        "day",
        "market_cap_rmb"
      ]
    },
    "MarketCapPointHourly": {
      "type": "object",
      "properties": {
        "ts": {
          "type": "integer",
          "description": "Unix timestamp of the hour bucket (UTC)."
        },
        "hour": {
          "type": "string",
          "format": "date-time",
          "description": "ISO-8601 UTC timestamp for the hour bucket."
        },
        "market_cap_rmb": {
          "allOf": [
            {
              "$ref": "#/$defs/DecimalString"
            }
          ],
          "description": "Aggregate YouPin market cap for that hour, in CNY."
        },
        "listing_count": {
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "ts",
        "hour",
        "market_cap_rmb"
      ]
    },
    "UpdatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO-8601 UTC timestamp (millisecond precision)."
    }
  }
}