{
  "openapi": "3.0.1",
  "info": {
    "title": "US Building Permits Scraper — Construction & Contractor Leads",
    "description": "Fast, browser-free US building permits scraper & construction leads extractor. Pulls live municipal permits and deduplicated, activity-scored contractor leads (solar, roofing, HVAC, electrical, ADU) from 11 official Socrata open-data portals.",
    "version": "0.1",
    "x-build-id": "4PkLBFaLeeghdbwrh"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/olvi_tech~us-building-permits-contractors/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-olvi_tech-us-building-permits-contractors",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/olvi_tech~us-building-permits-contractors/runs": {
      "post": {
        "operationId": "runs-sync-olvi_tech-us-building-permits-contractors",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/olvi_tech~us-building-permits-contractors/run-sync": {
      "post": {
        "operationId": "run-sync-olvi_tech-us-building-permits-contractors",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "title": "Output Mode",
            "enum": [
              "permits",
              "contractors"
            ],
            "type": "string",
            "description": "Choose 'permits' for individual normalized building permit rows (all 11 cities) or 'contractors' for deduplicated, activity-scored active contractor leads (9 cities with contractor data; LA and SF are skipped automatically).",
            "default": "permits"
          },
          "cities": {
            "title": "Cities",
            "uniqueItems": true,
            "type": "array",
            "description": "Select one or more supported US municipal open-data portals, or choose 'All 11 US Cities'. Note: Los Angeles and San Francisco portals publish permits only (no contractor names).",
            "items": {
              "type": "string",
              "enum": [
                "all",
                "austin",
                "chicago",
                "nyc",
                "seattle",
                "mesa",
                "new_orleans",
                "cincinnati",
                "baton_rouge",
                "marin_county",
                "la",
                "sf"
              ],
              "enumTitles": [
                "All 11 US Cities",
                "Austin, TX (permits + contractors + phone)",
                "Chicago, IL (permits + contractors + phone)",
                "New York, NY (permits + contractors)",
                "Seattle, WA (permits + contractors)",
                "Mesa, AZ (permits + contractors)",
                "New Orleans, LA (permits + contractors)",
                "Cincinnati, OH (permits + contractors)",
                "Baton Rouge, LA (permits + contractors)",
                "Marin County, CA (permits + contractors)",
                "Los Angeles, CA (permits only)",
                "San Francisco, CA (permits only)"
              ]
            },
            "default": [
              "austin",
              "chicago",
              "nyc",
              "seattle"
            ]
          },
          "daysBack": {
            "title": "Days Back",
            "minimum": 1,
            "maximum": 365,
            "type": "integer",
            "description": "Number of days back from today to query (clamped 1-365). Ignored if 'Date From' is provided.",
            "default": 14
          },
          "dateFrom": {
            "title": "Date From (YYYY-MM-DD)",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Optional explicit ISO start date (YYYY-MM-DD). Overrides Days Back when set."
          },
          "keywords": {
            "title": "Keywords",
            "type": "array",
            "description": "Optional case-insensitive keywords matched against permit descriptions, work types, and contractor fields.",
            "items": {
              "type": "string"
            }
          },
          "trades": {
            "title": "Trade Filter",
            "uniqueItems": true,
            "type": "array",
            "description": "Optional list of classified construction trades to include. Leave empty to include all trades.",
            "items": {
              "type": "string",
              "enum": [
                "solar",
                "roofing",
                "hvac",
                "electrical",
                "plumbing",
                "adu",
                "remodel",
                "commercial",
                "other"
              ],
              "enumTitles": [
                "Solar / PV",
                "Roofing",
                "HVAC / Mechanical",
                "Electrical / EV Charger",
                "Plumbing / Gas",
                "ADU / Accessory Dwelling",
                "Remodel / Addition",
                "Commercial / Multi-family",
                "Other"
              ]
            }
          },
          "minValuation": {
            "title": "Minimum Valuation (USD)",
            "minimum": 0,
            "type": "number",
            "description": "Minimum project valuation in USD. Permits without reported valuation are excluded when > 0.",
            "default": 0
          },
          "maxResults": {
            "title": "Max Results (Billed Output Cap)",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Hard cap on total output items billed and pushed to the dataset.",
            "default": 200
          },
          "maxPermitsPerCity": {
            "title": "Max Permits Scanned Per City",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Upper scan ceiling per city portal (especially useful in 'contractors' mode to control aggregation depth).",
            "default": 2000
          },
          "deltaMode": {
            "title": "Delta Mode (Incremental Scheduled Runs)",
            "type": "boolean",
            "description": "When enabled, tracks per-city watermarks in a named Key-Value Store so scheduled runs emit only new permits without duplicates.",
            "default": false
          },
          "deltaStoreName": {
            "title": "Delta State Key-Value Store Name",
            "type": "string",
            "description": "Named Apify Key-Value Store used to persist per-city watermarks when Delta Mode is enabled.",
            "default": "us-permits-delta-state"
          },
          "socrataAppToken": {
            "title": "Socrata App Token (Optional)",
            "type": "string",
            "description": "Optional Socrata X-App-Token for higher municipal API throughput. Falls back to SOCRATA_APP_TOKEN environment variable."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}