{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/metricduck-com/json-schema/metricduck-com-screen-request-schema.json",
  "title": "ScreenRequest",
  "description": "Request body for POST /screener/screen",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/metricduck-com-openapi.json#/components/schemas/ScreenRequest",
  "properties": {
    "filters": {
      "items": {
        "$ref": "#/$defs/MetricFilter"
      },
      "type": "array",
      "title": "Filters",
      "description": "List of metric filters to apply",
      "default": []
    },
    "include_metrics": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Include Metrics",
      "description": "List of metric IDs to include in results. If null, returns common metrics."
    },
    "sectors": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Sectors",
      "description": "List of sector codes to filter by (e.g., ['TECH', 'HEALTH'])"
    },
    "industries": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Industries",
      "description": "List of industry codes to filter by (e.g., ['TECH_SOFTWARE'])"
    },
    "tickers": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array",
          "maxItems": 50
        },
        {
          "type": "null"
        }
      ],
      "title": "Tickers",
      "description": "Filter to specific ticker symbols (max 50). Returns only these companies."
    },
    "required_tags": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Required Tags",
      "description": "Filter to companies whose classification includes ALL of these tags (e.g., ['saas_enterprise'])."
    },
    "excluded_tags": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Excluded Tags",
      "description": "Filter to companies whose classification includes NONE of these tags (e.g., ['china_revenue_heavy'])."
    },
    "signals": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Signals",
      "description": "DEPRECATED (#1535) — no longer accepted; a non-empty value returns 400. Signal screening moved to screen_filing_signals (a universe-correct cross-company screen); intersect its results with your metric screen. Kept only to fail loudly instead of silently ignoring the field.",
      "deprecated": true
    },
    "limit": {
      "type": "integer",
      "maximum": 100.0,
      "minimum": 1.0,
      "title": "Limit",
      "description": "Maximum number of results per page",
      "default": 20
    },
    "page": {
      "type": "integer",
      "minimum": 1.0,
      "title": "Page",
      "description": "Page number (1-indexed) for pagination",
      "default": 1
    },
    "sort_by": {
      "type": "string",
      "title": "Sort By",
      "description": "Metric ID to sort by",
      "default": "market_cap"
    },
    "sort_order": {
      "type": "string",
      "title": "Sort Order",
      "description": "Sort order: asc or desc",
      "default": "desc"
    }
  },
  "type": "object",
  "$defs": {
    "MetricFilter": {
      "properties": {
        "metric_id": {
          "type": "string",
          "title": "Metric Id",
          "description": "Metric identifier (e.g., 'pe_ratio')"
        },
        "period_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Period Type",
          "description": "Period type: 'ttm', 'ss', or growth metrics like 'ttm.yoy'",
          "default": "ttm"
        },
        "operator": {
          "type": "string",
          "title": "Operator",
          "description": "Comparison operator: lt, lte, gt, gte, eq, between"
        },
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value",
          "description": "Single value for lt/lte/gt/gte/eq operators"
        },
        "min_value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Min Value",
          "description": "Minimum value for 'between' operator"
        },
        "max_value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Max Value",
          "description": "Maximum value for 'between' operator"
        }
      },
      "type": "object",
      "required": [
        "metric_id",
        "operator"
      ],
      "title": "MetricFilter",
      "description": "A single metric filter condition"
    }
  }
}