{
  "openapi": "3.0.1",
  "info": {
    "title": "Building Permit Contractor Leads: Active Contractors",
    "description": "Turn official building-permit open data into contractor lead lists: one row per contractor company with permits pulled, total and largest job value, trades, cities and recent jobs. 13 US and Canada city presets or any Socrata permit dataset, plus an only-new-contractors mode for weekly alerts.",
    "version": "0.1",
    "x-build-id": "uc7IWxyoYDcu7oMif"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/latamdatatools~building-permit-contractor-leads/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-latamdatatools-building-permit-contractor-leads",
        "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/latamdatatools~building-permit-contractor-leads/runs": {
      "post": {
        "operationId": "runs-sync-latamdatatools-building-permit-contractor-leads",
        "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/latamdatatools~building-permit-contractor-leads/run-sync": {
      "post": {
        "operationId": "run-sync-latamdatatools-building-permit-contractor-leads",
        "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": {
          "sources": {
            "title": "Cities (presets)",
            "type": "array",
            "description": "Official open-data portals with a contractor company column. Leave empty if you only use custom datasets.",
            "items": {
              "type": "string",
              "enum": [
                "chicago",
                "new-york-city",
                "seattle",
                "austin",
                "cincinnati",
                "cambridge",
                "marin-county",
                "baton-rouge",
                "new-orleans",
                "mesa",
                "buffalo",
                "orlando",
                "calgary"
              ],
              "enumTitles": [
                "Chicago, IL",
                "New York City, NY (DOB NOW)",
                "Seattle, WA",
                "Austin, TX",
                "Cincinnati, OH",
                "Cambridge, MA",
                "Marin County, CA",
                "Baton Rouge, LA",
                "New Orleans, LA",
                "Mesa, AZ",
                "Buffalo, NY",
                "Orlando, FL",
                "Calgary, AB (Canada)"
              ]
            },
            "default": [
              "austin",
              "seattle",
              "chicago"
            ]
          },
          "customDatasets": {
            "title": "Custom Socrata datasets (any city)",
            "type": "array",
            "description": "Any Socrata permit dataset with a contractor column. Required: domain and datasetId (the abcd-1234 id in the dataset URL). Columns are detected automatically from the dataset metadata; override with dateField, contractorField, valueField, addressField, permitIdField, typeField, descriptionField, tradeField. Optional: city, state, country, currency. Example: [{\"domain\": \"data.cincinnati-oh.gov\", \"datasetId\": \"uhjb-xac9\", \"city\": \"Cincinnati\", \"state\": \"OH\"}]",
            "default": []
          },
          "daysBack": {
            "title": "Days back",
            "minimum": 0,
            "maximum": 366,
            "type": "integer",
            "description": "Permits issued in the last N days (ignored if Issued from is set). 30-90 days gives the best contractor profiles.",
            "default": 30
          },
          "dateFrom": {
            "title": "Issued from (optional)",
            "type": "string",
            "description": "YYYY-MM-DD. Overrides Days back."
          },
          "dateTo": {
            "title": "Issued to (optional)",
            "type": "string",
            "description": "YYYY-MM-DD. Default: today."
          },
          "minJobValue": {
            "title": "Minimum job value per permit",
            "minimum": 0,
            "type": "integer",
            "description": "Only count permits with a declared job value of at least this amount (USD; CAD for Calgary)."
          },
          "includeWithoutValue": {
            "title": "Keep permits without a value",
            "type": "boolean",
            "description": "When a minimum value is set, also keep permits whose portal publishes no value.",
            "default": true
          },
          "propertyClass": {
            "title": "Property type",
            "enum": [
              "any",
              "residential",
              "commercial"
            ],
            "type": "string",
            "description": "Residential or commercial permits only (detected from the permit class/use).",
            "default": "any"
          },
          "workTags": {
            "title": "Work tags",
            "type": "array",
            "description": "Only permits tagged with at least one of these (detected from type and description). Example: roofing + solar for a roofing supplier.",
            "items": {
              "type": "string",
              "enum": [
                "new-construction",
                "addition-alteration",
                "demolition",
                "roofing",
                "solar",
                "electrical",
                "plumbing",
                "mechanical-hvac",
                "pool",
                "sign",
                "fence",
                "ev-charger",
                "adu",
                "windows-doors",
                "fire-protection",
                "elevator"
              ]
            },
            "default": []
          },
          "keywords": {
            "title": "Keywords",
            "type": "array",
            "description": "Only permits whose type, description or contractor name contains one of these words.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "outputMode": {
            "title": "Output",
            "enum": [
              "contractors",
              "permits",
              "both"
            ],
            "type": "string",
            "description": "Output",
            "default": "contractors"
          },
          "minPermitsPerContractor": {
            "title": "Minimum permits per contractor",
            "minimum": 1,
            "type": "integer",
            "description": "Skip contractors with fewer permits in the period (2-3 = active companies only).",
            "default": 1
          },
          "minTotalJobValue": {
            "title": "Minimum total job value per contractor",
            "minimum": 0,
            "type": "integer",
            "description": "Skip contractors whose permits add up to less than this."
          },
          "onlyNewContractors": {
            "title": "Only new contractors (alerts)",
            "type": "boolean",
            "description": "Remember every contractor delivered under the alert name and return only companies never seen before. Schedule it weekly to catch contractors that just started pulling permits in your area. The first run returns everyone.",
            "default": false
          },
          "alertName": {
            "title": "Alert name",
            "type": "string",
            "description": "Separate memory for each saved search when Only new contractors is on.",
            "default": "default"
          },
          "maxContractors": {
            "title": "Max contractors",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Upper limit of contractor rows returned (the most active contractors come first).",
            "default": 1000
          },
          "maxPermits": {
            "title": "Max permit rows",
            "minimum": 1,
            "maximum": 200000,
            "type": "integer",
            "description": "Only used when the output includes permit rows.",
            "default": 5000
          },
          "maxPagesPerSource": {
            "title": "Max pages per city (1,000 permits each)",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Safety limit per city: each page is 1,000 permits.",
            "default": 30
          },
          "socrataAppToken": {
            "title": "Socrata app token (optional)",
            "type": "string",
            "description": "Free token from any Socrata portal; only needed for very large pulls."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}