{
  "openapi": "3.0.3",
  "info": {
    "title": "OpenGrants API",
    "description": "RESTful API for accessing grants, government contracts, and funding organization data.",
    "version": "1.0.0",
    "contact": { "name": "OpenGrants", "url": "https://opengrants.io" }
  },
  "servers": [{ "url": "https://ops.opengrants.io/functions/v1", "description": "Production" }],
  "paths": {
    "/grants-api": {
      "get": {
        "summary": "List grants",
        "operationId": "listGrants",
        "parameters": [
          { "name": "search", "in": "query", "schema": { "type": "string" } },
          { "name": "status", "in": "query", "schema": { "type": "string", "enum": ["open", "posted", "closed", "forecasted"] } },
          { "name": "category", "in": "query", "schema": { "type": "string" } },
          { "name": "geography", "in": "query", "schema": { "type": "string", "enum": ["national", "state", "local", "international"] } },
          { "name": "min_amount", "in": "query", "schema": { "type": "number" } },
          { "name": "max_amount", "in": "query", "schema": { "type": "number" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 20, "maximum": 100 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } }
        ],
        "responses": { "200": { "description": "Paginated grants list" } },
        "security": [{ "apiKey": [] }]
      }
    },
    "/contracts-api": {
      "get": {
        "summary": "List contracts",
        "operationId": "listContracts",
        "parameters": [
          { "name": "search", "in": "query", "schema": { "type": "string" } },
          { "name": "status", "in": "query", "schema": { "type": "string" } },
          { "name": "naics", "in": "query", "schema": { "type": "string" } },
          { "name": "set_aside", "in": "query", "schema": { "type": "string" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 20, "maximum": 100 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } }
        ],
        "responses": { "200": { "description": "Paginated contracts list" } },
        "security": [{ "apiKey": [] }]
      }
    },
    "/funders-api": {
      "get": {
        "summary": "List funders",
        "operationId": "listFunders",
        "parameters": [
          { "name": "search", "in": "query", "schema": { "type": "string" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 20, "maximum": 100 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } }
        ],
        "responses": { "200": { "description": "Paginated funders list" } },
        "security": [{ "apiKey": [] }]
      }
    },
    "/semantic-search": {
      "post": {
        "summary": "Semantic search",
        "operationId": "semanticSearch",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "type": "object", "required": ["query"], "properties": { "query": { "type": "string" }, "type": { "type": "string", "enum": ["grants", "contracts"] }, "limit": { "type": "integer", "default": 10 } } } } }
        },
        "responses": { "200": { "description": "Semantically matched results" } },
        "security": [{ "apiKey": [] }]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": { "type": "http", "scheme": "bearer", "description": "API key from the OpenGrants Developer portal" }
    }
  }
}
