{
 "openapi": "3.1.0",
 "info": {
  "title": "AbateFind license API",
  "version": "1.0.0",
  "summary": "Read-only API over the official asbestos and lead abatement license lists of PA, VA, CA, WA and NC.",
  "description": "Public records republished from state agency lists. Every record has the agency list date and fetch date. AbateFind is not the licensing authority; confirm on the agency site. Rate limit 60 requests/min per IP. Cite as: AbateFind (abatefind.com), from the <agency> list dated <date>.",
  "contact": {
   "name": "Kvell Ventures, LLC",
   "email": "hello@abatefind.com",
   "url": "https://abatefind.com"
  },
  "termsOfService": "https://abatefind.com/legal/terms/"
 },
 "servers": [
  {
   "url": "https://abatefind.com"
  }
 ],
 "externalDocs": {
  "description": "Developer documentation",
  "url": "https://abatefind.com/developers/"
 },
 "paths": {
  "/api/v1/check": {
   "get": {
    "operationId": "checkLicense",
    "summary": "Check whether a firm is licensed",
    "description": "Best matches for a firm name with a plain-language verdict. No match does not mean unlicensed.",
    "parameters": [
     {
      "name": "name",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Firm name or part of it"
     },
     {
      "name": "state",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "PA",
        "VA",
        "CA",
        "WA",
        "NC"
       ]
      },
      "description": "Narrow to one state"
     },
     {
      "name": "city",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "City name or slug"
     },
     {
      "name": "license_number",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "License number as printed by the agency"
     }
    ],
    "responses": {
     "200": {
      "description": "Matches",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CheckResult"
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/firms": {
   "get": {
    "operationId": "searchFirms",
    "summary": "Search firms",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "Text matched against firm name and city"
     },
     {
      "name": "state",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "PA",
        "VA",
        "CA",
        "WA",
        "NC"
       ]
      },
      "description": "State code"
     },
     {
      "name": "city",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "City name or slug"
     },
     {
      "name": "license_number",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "Exact license number"
     },
     {
      "name": "service",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "asbestos-abatement",
        "asbestos-consulting",
        "lead-abatement",
        "lead-inspection"
       ]
      },
      "description": "Service"
     },
     {
      "name": "status",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "active",
        "expired",
        "revoked",
        "unknown"
       ]
      },
      "description": "Computed status"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 50,
       "default": 20
      },
      "description": "Page size"
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      },
      "description": "Offset"
     }
    ],
    "responses": {
     "200": {
      "description": "Firms",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/FirmList"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/firms/{id}": {
   "get": {
    "operationId": "getFirm",
    "summary": "One firm record",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Firm id (the slug in /firm/{id}/)"
     }
    ],
    "responses": {
     "200": {
      "description": "Firm record",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Firm"
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/states": {
   "get": {
    "operationId": "listStates",
    "summary": "State coverage",
    "responses": {
     "200": {
      "description": "States",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/sources": {
   "get": {
    "operationId": "listSources",
    "summary": "Official lists used",
    "responses": {
     "200": {
      "description": "Sources",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/.well-known/search": {
   "get": {
    "operationId": "searchForAgents",
    "summary": "Search for agents (Markdown)",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Query"
     }
    ],
    "responses": {
     "200": {
      "description": "Markdown results",
      "content": {
       "text/markdown": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  },
  "/mcp": {
   "post": {
    "operationId": "mcp",
    "summary": "Model Context Protocol endpoint (Streamable HTTP, JSON-RPC 2.0)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "JSON-RPC response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "202": {
      "description": "Notification accepted"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Problem": {
    "type": "object",
    "properties": {
     "type": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "status": {
      "type": "integer"
     },
     "detail": {
      "type": "string"
     }
    }
   },
   "License": {
    "type": "object",
    "properties": {
     "agency": {
      "type": "string"
     },
     "list": {
      "type": "string"
     },
     "type": {
      "type": "string"
     },
     "service": {
      "type": "string"
     },
     "number": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "active",
       "expired",
       "revoked",
       "unknown"
      ]
     },
     "renewal_unconfirmed": {
      "type": "boolean",
      "description": "The listed date passed after the agency list was published; renewal not yet confirmed"
     },
     "agency_status": {
      "type": [
       "string",
       "null"
      ]
     },
     "expires_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "list_dated": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "fetched_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "source_url": {
      "type": "string",
      "format": "uri"
     },
     "lookup_url": {
      "type": [
       "string",
       "null"
      ],
      "format": "uri"
     }
    }
   },
   "Firm": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "legal_name": {
      "type": [
       "string",
       "null"
      ]
     },
     "state": {
      "type": "string",
      "enum": [
       "PA",
       "VA",
       "CA",
       "WA",
       "NC"
      ]
     },
     "city": {
      "type": [
       "string",
       "null"
      ]
     },
     "verdict": {
      "type": "string",
      "enum": [
       "active",
       "renewal_unconfirmed",
       "expired",
       "revoked",
       "unconfirmed",
       "grouped_from_individuals",
       "unverified"
      ]
     },
     "answer": {
      "type": "string",
      "description": "One-sentence answer with agency, list date and source"
     },
     "services": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "licenses": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/License"
      }
     },
     "url": {
      "type": "string",
      "format": "uri"
     },
     "markdown_url": {
      "type": "string",
      "format": "uri"
     },
     "checked_on": {
      "type": "string",
      "format": "date"
     }
    }
   },
   "Meta": {
    "type": "object",
    "properties": {
     "total": {
      "type": "integer"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "data_checked_on": {
      "type": "string",
      "format": "date"
     },
     "coverage": {
      "type": "string"
     },
     "attribution": {
      "type": "string"
     }
    }
   },
   "FirmList": {
    "type": "object",
    "properties": {
     "data": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Firm"
      }
     },
     "meta": {
      "$ref": "#/components/schemas/Meta"
     }
    }
   },
   "CheckResult": {
    "type": "object",
    "properties": {
     "query": {
      "type": "object"
     },
     "answer": {
      "type": "string"
     },
     "matches": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Firm"
      }
     },
     "meta": {
      "$ref": "#/components/schemas/Meta"
     }
    }
   }
  }
 }
}
