{
  "openapi": "3.0.1",
  "info": {
    "title": "US Water System & Utility Leads Scraper (EPA SDWIS)",
    "description": "Scrape every US public water system from the official EPA SDWIS database: utility name, admin contact, email, phone, address, population served, service connections, owner & source type, plus health-based violations. Filter by state, size & type. B2B water-utility leads + monitoring.",
    "version": "0.1",
    "x-build-id": "MeLjnXg3dUv7AXUAY"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/scrapesage~us-water-system-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-scrapesage-us-water-system-scraper",
        "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/scrapesage~us-water-system-scraper/runs": {
      "post": {
        "operationId": "runs-sync-scrapesage-us-water-system-scraper",
        "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/scrapesage~us-water-system-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-scrapesage-us-water-system-scraper",
        "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": {
          "states": {
            "title": "States",
            "type": "array",
            "description": "Filter by the water system's state — two-letter USPS codes, e.g. <code>CA</code>, <code>TX</code>, <code>NY</code>, <code>FL</code>. Leave empty to sweep all 50 states, DC and US territories (bounded by Max results).",
            "items": {
              "type": "string"
            }
          },
          "pwsTypes": {
            "title": "Water system types",
            "type": "array",
            "description": "Which kinds of public water system to include. <b>CWS</b> = Community (year-round residents — cities, towns, mobile-home parks, HOAs; the best B2B leads). <b>NTNCWS</b> = Non-Transient Non-Community (schools, factories, offices with their own supply). <b>TNCWS</b> = Transient Non-Community (gas stations, campgrounds, rest stops). Leave empty for all types.",
            "items": {
              "type": "string",
              "enum": [
                "CWS",
                "NTNCWS",
                "TNCWS"
              ],
              "enumTitles": [
                "Community (CWS)",
                "Non-Transient Non-Community (NTNCWS)",
                "Transient Non-Community (TNCWS)"
              ]
            },
            "default": [
              "CWS"
            ]
          },
          "activeOnly": {
            "title": "Active systems only",
            "type": "boolean",
            "description": "Only include water systems currently flagged as active in EPA's SDWIS (recommended for clean, contactable leads). Turn off to include inactive / historical systems.",
            "default": true
          },
          "ownerTypes": {
            "title": "Owner types",
            "type": "array",
            "description": "Keep only systems with the selected ownership. <b>Local government</b> (cities/towns/districts) and <b>Private</b> are the most actionable B2B buyers. Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "L",
                "P",
                "S",
                "F",
                "M",
                "N"
              ],
              "enumTitles": [
                "Local government",
                "Private",
                "State government",
                "Federal government",
                "Public/Private (mixed)",
                "Native American"
              ]
            }
          },
          "sourceTypes": {
            "title": "Water source",
            "type": "array",
            "description": "Filter by primary water source. <b>Ground water</b> (wells) vs <b>Surface water</b> (rivers/lakes/reservoirs) — relevant for treatment, equipment and testing vendors. Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "GW",
                "SW",
                "GU"
              ],
              "enumTitles": [
                "Ground water",
                "Surface water",
                "Ground water under surface influence"
              ]
            }
          },
          "cities": {
            "title": "Cities",
            "type": "array",
            "description": "Filter by the system's mailing city (case-insensitive), e.g. <code>Houston</code>, <code>Phoenix</code>, <code>Denver</code>. Combine with a state for accuracy.",
            "items": {
              "type": "string"
            }
          },
          "zipCodes": {
            "title": "ZIP codes (prefix)",
            "type": "array",
            "description": "Filter by the system's mailing ZIP — full ZIP (<code>85001</code>) or a prefix (<code>850</code> matches all 850xx).",
            "items": {
              "type": "string"
            }
          },
          "nameQuery": {
            "title": "System name contains",
            "type": "string",
            "description": "Only return systems whose name contains this text (case-insensitive), e.g. <code>city of</code>, <code>water district</code>, <code>utility</code>, <code>mobile home</code>, or a specific name."
          },
          "minPopulationServed": {
            "title": "Min population served",
            "type": "integer",
            "description": "Only systems serving at least this many people. Larger systems = larger budgets (e.g. set <code>10000</code> for mid/large utilities)."
          },
          "maxPopulationServed": {
            "title": "Max population served",
            "type": "integer",
            "description": "Only systems serving at most this many people (e.g. set <code>3300</code> to target small/rural systems)."
          },
          "minServiceConnections": {
            "title": "Min service connections",
            "type": "integer",
            "description": "Only systems with at least this many service connections (metered hookups)."
          },
          "wholesalersOnly": {
            "title": "Wholesalers only",
            "type": "boolean",
            "description": "Only systems flagged as water wholesalers (they sell treated water to other systems) — large infrastructure buyers.",
            "default": false
          },
          "servesSchoolOrDaycareOnly": {
            "title": "Serves school / daycare only",
            "type": "boolean",
            "description": "Only systems flagged as serving a school or daycare (relevant for lead-testing and compliance vendors).",
            "default": false
          },
          "withEmailOnly": {
            "title": "Has email only",
            "type": "boolean",
            "description": "Only return systems that publish an administrative contact email address.",
            "default": false
          },
          "withPhoneOnly": {
            "title": "Has phone only",
            "type": "boolean",
            "description": "Only return systems that publish an administrative contact phone number.",
            "default": false
          },
          "includeViolations": {
            "title": "Include compliance / violations",
            "type": "boolean",
            "description": "Enrich each returned system with its EPA drinking-water violation history — total & health-based violation counts, latest violation date, top contaminants and recent violation detail. Adds one request per returned system. Health-based violations = high service-intent (treatment, testing, engineering).",
            "default": false
          },
          "healthBasedViolationsOnly": {
            "title": "Has health-based violations only",
            "type": "boolean",
            "description": "Only return systems with at least one recent health-based violation (MCL / MRDL / treatment-technique). Requires \"Include compliance / violations\".",
            "default": false
          },
          "recentViolationYears": {
            "title": "Violation lookback (years)",
            "minimum": 1,
            "maximum": 30,
            "type": "integer",
            "description": "How many years back to count \"recent\" violations when compliance enrichment is on.",
            "default": 5
          },
          "includeGeographicArea": {
            "title": "Include counties / cities served",
            "type": "boolean",
            "description": "Enrich each returned system with the counties, cities and ZIP codes it serves (from SDWIS geographic-area data). Adds one request per returned system.",
            "default": false
          },
          "minLeadScore": {
            "title": "Min lead score",
            "type": "integer",
            "description": "Only return systems with a lead score (0–100) at or above this value."
          },
          "sortBy": {
            "title": "Sort order",
            "enum": [
              "leadScore",
              "populationHigh",
              "connectionsHigh",
              "recentViolation",
              "name",
              "source"
            ],
            "type": "string",
            "description": "<b>Lead score</b> = most contactable / highest-value first (recommended). <b>Largest population</b> / <b>Most connections</b> rank by system size. <b>Recent violation</b> ranks by latest violation (needs compliance enrichment). <b>Source order</b> = fastest on very large limits.",
            "default": "leadScore"
          },
          "maxResults": {
            "title": "Max results",
            "minimum": 1,
            "type": "integer",
            "description": "Maximum number of water system records to return in this run.",
            "default": 1000
          },
          "maxResultsPerState": {
            "title": "Max results per state",
            "type": "integer",
            "description": "Optional cap on records per state (useful for an even spread across a multi-state sweep). Leave empty for no per-state cap."
          },
          "deduplicateResults": {
            "title": "Deduplicate within a run",
            "type": "boolean",
            "description": "Skip duplicate systems (same PWSID) within this run (recommended).",
            "default": true
          },
          "monitorMode": {
            "title": "Monitoring mode — only new / changed systems",
            "type": "boolean",
            "description": "Remember which systems were already returned (in a named key-value store) and emit ONLY systems that are <b>new</b> or whose violation history changed since the last run — each tagged with a <code>monitorEvent</code> (<code>new</code> or <code>new_violation</code>). EPA refreshes SDWIS regularly; run on a Schedule to capture fresh systems & violations as leads. Works alongside Apify Schedules (the schedule starts the run; monitoring decides what's new).",
            "default": false
          },
          "monitorKey": {
            "title": "Monitor key",
            "type": "string",
            "description": "Names the memory used by monitoring mode. Use a distinct key per saved watch (e.g. per state or system type) so different monitors don't share state.",
            "default": "default"
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Optional proxy. The EPA SDWIS / Envirofacts API is queried directly and needs no proxy — leave this off for the fastest queries. Enable Apify Proxy only if your network requires it.",
            "default": {
              "useApifyProxy": false
            }
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}