{
 "openapi": "3.1.0",
 "info": {
  "title": "Awardtide Recompete Radar API",
  "version": "1.1.0",
  "description": "US federal contracts worth $1M+ whose current end date is within 12 months (USAspending.gov data), filtered by NAICS, agency, state, value and set-aside. Free: count, total potential value and the first 10 matches. Radar Pro key (header x-licence or ?key=): every row, CSV, saved filters and weekly feeds. Public US Government data; not affiliated with any agency. \u00a9 2026 CyberMax.",
  "contact": {
   "name": "CyberMax",
   "email": "cybermax.tools@gmail.com",
   "url": "https://awardtide.cybermaxtools.com/"
  }
 },
 "servers": [
  {
   "url": "https://awardtide.cybermaxtools.com"
  },
  {
   "url": "https://awardtide.cybermax-tools.workers.dev"
  }
 ],
 "components": {
  "securitySchemes": {
   "licence": {
    "type": "apiKey",
    "in": "header",
    "name": "x-licence"
   }
  },
  "schemas": {
   "Contract": {
    "type": "object",
    "properties": {
     "key": {
      "type": "string"
     },
     "piid": {
      "type": "string"
     },
     "agency": {
      "type": "string"
     },
     "sub_agency": {
      "type": "string"
     },
     "office": {
      "type": "string"
     },
     "incumbent": {
      "type": "string"
     },
     "state": {
      "type": "string"
     },
     "naics": {
      "type": "string"
     },
     "naics_title": {
      "type": "string"
     },
     "obligated": {
      "type": "number"
     },
     "potential_value": {
      "type": "number"
     },
     "current_end_date": {
      "type": "string"
     },
     "potential_end_date": {
      "type": "string"
     },
     "set_aside": {
      "type": "string"
     },
     "usaspending_url": {
      "type": "string"
     }
    }
   }
  }
 },
 "paths": {
  "/api/meta": {
   "get": {
    "operationId": "meta",
    "summary": "Data date, contract count, NAICS codes, agencies and states",
    "responses": {
     "200": {
      "description": "Metadata",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/api/match": {
   "get": {
    "operationId": "searchRecompetes",
    "summary": "Contracts ending within 12 months that match a filter",
    "security": [
     {},
     {
      "licence": []
     }
    ],
    "parameters": [
     {
      "name": "naics",
      "in": "query",
      "required": false,
      "description": "NAICS codes or prefixes (3-6 digits), comma-separated. Required unless agency is given.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "agency",
      "in": "query",
      "required": false,
      "description": "Agency slugs from /api/meta, comma-separated",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "state",
      "in": "query",
      "required": false,
      "description": "Two-letter states of performance, comma-separated",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "min",
      "in": "query",
      "required": false,
      "description": "Minimum value in USD",
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "max",
      "in": "query",
      "required": false,
      "description": "Maximum value in USD",
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "months",
      "in": "query",
      "required": false,
      "description": "Current end within this many months (1-12)",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "setaside",
      "in": "query",
      "required": false,
      "description": "Set-aside text contains, e.g. 8(a), SDVOSB",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "q",
      "in": "query",
      "required": false,
      "description": "Incumbent, PIID, NAICS title or office contains",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "format",
      "in": "query",
      "required": false,
      "description": "csv (Radar Pro only)",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Matches",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data_built": {
           "type": "string"
          },
          "count": {
           "type": "integer"
          },
          "potential_value_total": {
           "type": "number"
          },
          "tier": {
           "type": "string",
           "enum": [
            "free",
            "pro"
           ]
          },
          "shown": {
           "type": "integer"
          },
          "rows": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Contract"
           }
          },
          "upgrade": {
           "type": "object"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Missing NAICS/agency or a filter that is too broad"
     },
     "402": {
      "description": "CSV without a Pro key"
     }
    }
   }
  },
  "/api/filters": {
   "get": {
    "operationId": "listFilters",
    "summary": "Saved filters with feed links (Radar Pro)",
    "security": [
     {
      "licence": []
     }
    ],
    "responses": {
     "200": {
      "description": "Filters"
     },
     "401": {
      "description": "Missing or inactive key"
     }
    }
   },
   "post": {
    "operationId": "saveFilter",
    "summary": "Save a filter (max 25, Radar Pro)",
    "security": [
     {
      "licence": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "name": {
          "type": "string"
         },
         "naics": {
          "type": "string"
         },
         "agency": {
          "type": "string"
         },
         "state": {
          "type": "string"
         },
         "min": {
          "type": "number"
         },
         "months": {
          "type": "integer"
         },
         "setaside": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Saved"
     },
     "401": {
      "description": "Missing or inactive key"
     }
    }
   }
  },
  "/api/filters/{id}": {
   "delete": {
    "operationId": "deleteFilter",
    "summary": "Delete a saved filter",
    "security": [
     {
      "licence": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Deleted"
     }
    }
   }
  }
 }
}