{
  "openapi": "3.0.3",
  "info": {
    "title": "NAICS Code Finder — Semantic Industry Classification",
    "description": "Paste a company description and get ranked NAICS codes with 0–100 match ratings — semantic AI matching over all 2,125 official 2022 codes, plus keyword search, code lookup, and similar-industry discovery.",
    "version": "1.0.0"
  },
  "components": {
    "schemas": {}
  },
  "paths": {
    "/match": {
      "post": {
        "summary": "Semantic match: free text → NAICS codes with match ratings",
        "tags": [
          "NAICS"
        ],
        "description": "Paste a company description, capabilities statement, services list, or website copy and get ranked NAICS codes with a 0–100 match rating, strength band (excellent/strong/moderate/weak), the full sector→industry hierarchy for each hit, the official Census index activity that matched best, and matched index terms for explainability. Hybrid scoring (MiniLM sentence embeddings + IDF keyword overlap) over all 2,125 official 2022 NAICS codes and ~20k Census index activities, typical latency 30–80ms after warmup, and `level` picks the code granularity (6 = national industry, default).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 5000,
                    "example": "We install and repair residential HVAC systems, furnaces, and heat pumps"
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 25,
                    "default": 5,
                    "example": 5
                  },
                  "level": {
                    "type": "integer",
                    "enum": [
                      2,
                      3,
                      4,
                      5,
                      6
                    ],
                    "default": 6,
                    "example": 6
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Not found",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/search": {
      "get": {
        "summary": "Keyword search across all NAICS codes and index activities",
        "tags": [
          "NAICS"
        ],
        "description": "IDF-weighted keyword search over titles, official index activities, and descriptions at every level (sector to national industry). No ML model involved — sub-millisecond. Use it for autocomplete or when you already know roughly the right words.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 200
            },
            "example": "coffee shop",
            "in": "query",
            "name": "q",
            "required": true
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "integer",
              "enum": [
                2,
                3,
                4,
                5,
                6
              ]
            },
            "in": "query",
            "name": "level",
            "required": false
          }
        ],
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Not found",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/code": {
      "get": {
        "summary": "Look up one NAICS code: description, hierarchy, children, index activities",
        "tags": [
          "NAICS"
        ],
        "description": "Full official record for any 2–6 digit 2022 NAICS code — title, complete description, cross-references, parent chain from sector down, direct child codes, and every official Census index activity filed under it.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{2,6}$"
            },
            "example": "238220",
            "in": "query",
            "name": "code",
            "required": true
          }
        ],
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Not found",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/similar": {
      "get": {
        "summary": "Find NAICS codes most similar to a given code",
        "tags": [
          "NAICS"
        ],
        "description": "Nearest codes at the same level by precomputed sentence embeddings of the official titles+descriptions. Instant (no model call). Useful for broadening classification, finding adjacent industries, or building \"related industries\" features.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{2,6}$"
            },
            "example": "238220",
            "in": "query",
            "name": "code",
            "required": true
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 10
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Not found",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/dataset": {
      "get": {
        "summary": "Dataset metadata: NAICS version, source, code counts",
        "tags": [
          "NAICS"
        ],
        "description": "Metadata about the NAICS dataset, including version, source, total number of codes, counts per level, and total index activities.",
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Not found",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://web-toolbox-api-production.up.railway.app/naics",
      "description": "Production"
    }
  ]
}