{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/krimskrams-xyz/json-schema/krimskrams-xyz-metered-grant-search-response-schema.json",
  "title": "MeteredGrantSearchResponse",
  "description": "A grant search response with metered payment values.",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grant-search_krimskrams_xyz_openapi.json#/components/schemas/MeteredGrantSearchResponse",
  "properties": {
    "query": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Query"
    },
    "source_hit_count": {
      "type": "integer",
      "title": "Source Hit Count"
    },
    "candidates_evaluated": {
      "type": "integer",
      "title": "Candidates Evaluated"
    },
    "result_count": {
      "type": "integer",
      "title": "Result Count"
    },
    "partial_results": {
      "type": "boolean",
      "title": "Partial Results"
    },
    "retrieved_at": {
      "type": "string",
      "format": "date-time",
      "title": "Retrieved At"
    },
    "source": {
      "type": "string",
      "title": "Source",
      "default": "Grants.gov"
    },
    "source_api": {
      "type": "string",
      "title": "Source Api",
      "default": "https://api.grants.gov/v1/api"
    },
    "results": {
      "items": {
        "$ref": "#/$defs/GrantOpportunity"
      },
      "type": "array",
      "title": "Results"
    },
    "usage": {
      "$ref": "#/$defs/MeteredUsage"
    }
  },
  "type": "object",
  "required": [
    "query",
    "source_hit_count",
    "candidates_evaluated",
    "result_count",
    "partial_results",
    "retrieved_at",
    "results",
    "usage"
  ],
  "$defs": {
    "GrantOpportunity": {
      "properties": {
        "opportunity_id": {
          "type": "integer",
          "title": "Opportunity Id"
        },
        "opportunity_number": {
          "type": "string",
          "title": "Opportunity Number"
        },
        "title": {
          "type": "string",
          "title": "Title"
        },
        "agency_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Agency Code"
        },
        "agency_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Agency Name"
        },
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Status"
        },
        "open_date": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Open Date"
        },
        "close_date": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Close Date"
        },
        "days_remaining": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Days Remaining"
        },
        "award_floor_usd": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Award Floor Usd"
        },
        "award_ceiling_usd": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Award Ceiling Usd"
        },
        "estimated_total_funding_usd": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Estimated Total Funding Usd"
        },
        "expected_awards": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expected Awards"
        },
        "cost_sharing_required": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cost Sharing Required"
        },
        "eligibility": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Eligibility"
        },
        "funding_categories": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Funding Categories"
        },
        "funding_instruments": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Funding Instruments"
        },
        "assistance_listings": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Assistance Listings"
        },
        "official_url": {
          "type": "string",
          "title": "Official Url"
        },
        "source_updated_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Source Updated At"
        }
      },
      "type": "object",
      "required": [
        "opportunity_id",
        "opportunity_number",
        "title",
        "official_url"
      ],
      "title": "GrantOpportunity"
    },
    "MeteredUsage": {
      "properties": {
        "unit": {
          "type": "string",
          "title": "Unit"
        },
        "unit_price_usd": {
          "type": "string",
          "title": "Unit Price Usd"
        },
        "requested_units": {
          "type": "integer",
          "title": "Requested Units"
        },
        "delivered_units": {
          "type": "integer",
          "title": "Delivered Units"
        },
        "authorized_value_atomic": {
          "type": "integer",
          "title": "Authorized Value Atomic"
        },
        "authorized_value_usd": {
          "type": "string",
          "title": "Authorized Value Usd"
        },
        "settlement_value_atomic": {
          "type": "integer",
          "title": "Settlement Value Atomic"
        },
        "settlement_value_usd": {
          "type": "string",
          "title": "Settlement Value Usd"
        }
      },
      "type": "object",
      "required": [
        "unit",
        "unit_price_usd",
        "requested_units",
        "delivered_units",
        "authorized_value_atomic",
        "authorized_value_usd",
        "settlement_value_atomic",
        "settlement_value_usd"
      ],
      "title": "MeteredUsage",
      "description": "Payment amounts and delivered units for one metered search."
    }
  }
}