{
 "openapi": "3.1.0",
 "info": {
  "title": "Plainlist US business data API",
  "version": "1.0.0",
  "description": "Search US businesses by category and place. 50 lookups a day free per IP; $19/month for 10000 with a key. Every result carries source, licence and directory_url; link directory_url when showing a result.",
  "contact": {
   "email": "t@mrcto.ai"
  }
 },
 "servers": [
  {
   "url": "https://data.mrcto.ai"
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Optional. Paid key, pl_..."
   }
  },
  "schemas": {
   "Business": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "street": {
      "type": [
       "string",
       "null"
      ]
     },
     "city": {
      "type": [
       "string",
       "null"
      ]
     },
     "state": {
      "type": "string"
     },
     "zip": {
      "type": [
       "string",
       "null"
      ]
     },
     "phone": {
      "type": [
       "string",
       "null"
      ]
     },
     "website": {
      "type": [
       "string",
       "null"
      ]
     },
     "category": {
      "type": "object",
      "properties": {
       "slug": {
        "type": "string"
       },
       "label": {
        "type": "string"
       }
      }
     },
     "source": {
      "type": "string"
     },
     "source_url": {
      "type": [
       "string",
       "null"
      ]
     },
     "licence": {
      "type": "string"
     },
     "record_date": {
      "type": [
       "string",
       "null"
      ]
     },
     "directory_url": {
      "type": [
       "string",
       "null"
      ]
     },
     "list_url": {
      "type": "string"
     }
    }
   },
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "string"
     },
     "message": {
      "type": "string"
     }
    }
   }
  }
 },
 "security": [
  {},
  {
   "bearer": []
  }
 ],
 "paths": {
  "/v1/categories": {
   "get": {
    "operationId": "listCategories",
    "summary": "List categories",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": false,
      "description": "Filter text",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Max 200",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "description": "",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Categories"
     }
    }
   }
  },
  "/v1/search": {
   "get": {
    "operationId": "searchBusinesses",
    "summary": "Search businesses in one category",
    "parameters": [
     {
      "name": "category",
      "in": "query",
      "required": true,
      "description": "Slug or plain name",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "state",
      "in": "query",
      "required": false,
      "description": "Two-letter code",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "city",
      "in": "query",
      "required": false,
      "description": "City name",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "zip",
      "in": "query",
      "required": false,
      "description": "5-digit ZIP",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "q",
      "in": "query",
      "required": false,
      "description": "Name contains",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "1-50",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "description": "",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Results",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "total_matches": {
           "type": "integer"
          },
          "results": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Business"
           }
          },
          "attribution": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/businesses/{id}": {
   "get": {
    "operationId": "getBusiness",
    "summary": "Get one business",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Business"
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/count": {
   "get": {
    "operationId": "countBusinesses",
    "summary": "Count businesses",
    "parameters": [
     {
      "name": "category",
      "in": "query",
      "required": true,
      "description": "Slug or plain name",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "state",
      "in": "query",
      "required": false,
      "description": "",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "city",
      "in": "query",
      "required": false,
      "description": "",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Count"
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 }
}