{
  "openapi": "3.0.1",
  "info": {
    "title": "US Public Library Leads Scraper (IMLS Directory)",
    "description": "Scrape every US public library from the official IMLS Public Libraries Survey: ~9,000 library systems + ~17,000 branch outlets with phone, full address, population served, budget, collections, programs, computers/Wi-Fi & a lead score. Filter by state, size & type. B2B leads + new-library monitoring.",
    "version": "0.1",
    "x-build-id": "K5r5aqzsAbmCLL4bm"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/scrapesage~us-library-leads-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-scrapesage-us-library-leads-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-library-leads-scraper/runs": {
      "post": {
        "operationId": "runs-sync-scrapesage-us-library-leads-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-library-leads-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-scrapesage-us-library-leads-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": {
          "recordType": {
            "title": "Record type",
            "enum": [
              "libraries",
              "outlets",
              "both"
            ],
            "type": "string",
            "description": "<b>Library systems</b> = one rich record per public library (Administrative Entity) with full operational, financial and contact data (recommended). <b>Outlets</b> = one record per physical branch/central/bookmobile with address, phone, square footage & hours. <b>Both</b> = systems and outlets together.",
            "default": "libraries"
          },
          "states": {
            "title": "States",
            "type": "array",
            "description": "Filter by the library's state — two-letter USPS codes, e.g. <code>TX</code>, <code>CA</code>, <code>NY</code>. Leave empty for all 50 states + territories.",
            "items": {
              "type": "string"
            }
          },
          "counties": {
            "title": "Counties",
            "type": "array",
            "description": "Filter by county name (case-insensitive, exact), e.g. <code>Travis</code>, <code>Cook</code>, <code>Los Angeles</code>.",
            "items": {
              "type": "string"
            }
          },
          "cities": {
            "title": "Cities",
            "type": "array",
            "description": "Filter by city (case-insensitive, exact city name), e.g. <code>Austin</code>, <code>Chicago</code>.",
            "items": {
              "type": "string"
            }
          },
          "zipCodes": {
            "title": "ZIP codes (prefix)",
            "type": "array",
            "description": "Filter by ZIP — full ZIP (<code>78701</code>) or a prefix (<code>787</code> matches all 787xx).",
            "items": {
              "type": "string"
            }
          },
          "localeCategories": {
            "title": "Locale (urbanicity)",
            "type": "array",
            "description": "Filter by NCES locale category of the library's location.",
            "items": {
              "type": "string",
              "enum": [
                "City",
                "Suburb",
                "Town",
                "Rural"
              ],
              "enumTitles": [
                "City",
                "Suburb",
                "Town",
                "Rural"
              ]
            }
          },
          "beaRegions": {
            "title": "BEA regions",
            "type": "array",
            "description": "Filter by Bureau of Economic Analysis region code (library systems only).",
            "items": {
              "type": "string",
              "enum": [
                "01",
                "02",
                "03",
                "04",
                "05",
                "06",
                "07",
                "08",
                "09"
              ],
              "enumTitles": [
                "01 — New England",
                "02 — Mid East",
                "03 — Great Lakes",
                "04 — Plains",
                "05 — Southeast",
                "06 — Southwest",
                "07 — Rocky Mountains",
                "08 — Far West",
                "09 — Outlying Areas"
              ]
            }
          },
          "legalBasis": {
            "title": "Governance / legal basis",
            "type": "array",
            "description": "Filter library systems by their legal/governance basis. Useful for targeting government-run vs district vs non-profit libraries.",
            "items": {
              "type": "string",
              "enum": [
                "CI",
                "CO",
                "CC",
                "LD",
                "MJ",
                "SD",
                "NL",
                "NP",
                "OT"
              ],
              "enumTitles": [
                "CI — Municipal government",
                "CO — County/parish",
                "CC — City/county",
                "LD — Library district",
                "MJ — Multi-jurisdictional",
                "SD — School district",
                "NL — Native American tribal",
                "NP — Non-profit association",
                "OT — Other"
              ]
            }
          },
          "outletTypes": {
            "title": "Outlet types (for Outlets / Both)",
            "type": "array",
            "description": "Filter physical outlets by type. Only applies to outlet records.",
            "items": {
              "type": "string",
              "enum": [
                "CE",
                "BR",
                "BS",
                "BM"
              ],
              "enumTitles": [
                "CE — Central library",
                "BR — Branch library",
                "BS — Bookmobile",
                "BM — Books-by-mail only"
              ]
            }
          },
          "minPopulationServed": {
            "title": "Min population served",
            "minimum": 0,
            "type": "integer",
            "description": "Only return library systems whose legal-service-area population is at least this large (e.g. <code>10000</code>). Targets bigger, higher-budget accounts."
          },
          "maxPopulationServed": {
            "title": "Max population served",
            "minimum": 0,
            "type": "integer",
            "description": "Only return library systems serving at most this many people."
          },
          "minTotalRevenue": {
            "title": "Min total revenue ($)",
            "minimum": 0,
            "type": "integer",
            "description": "Only return library systems with at least this much total annual revenue (operating budget signal)."
          },
          "minVisits": {
            "title": "Min annual visits",
            "minimum": 0,
            "type": "integer",
            "description": "Only return library systems with at least this many annual in-person visits (foot-traffic signal)."
          },
          "minTotalStaff": {
            "title": "Min total staff (FTE)",
            "minimum": 0,
            "type": "integer",
            "description": "Only return library systems with at least this many total FTE staff."
          },
          "minBranches": {
            "title": "Min branch libraries",
            "minimum": 0,
            "type": "integer",
            "description": "Only return library systems with at least this many branch libraries."
          },
          "minSquareFeet": {
            "title": "Min square footage (outlets)",
            "minimum": 0,
            "type": "integer",
            "description": "Only return outlets with at least this much floor area. Only applies to outlet records."
          },
          "multiOutletOnly": {
            "title": "Multi-outlet systems only",
            "type": "boolean",
            "description": "Only return library systems that operate more than one outlet (central + branches). A signal of larger, multi-location accounts.",
            "default": false
          },
          "withPhoneOnly": {
            "title": "With phone number only",
            "type": "boolean",
            "description": "Only return records that have a phone number on file (~99% of libraries do).",
            "default": false
          },
          "excludeTemporarilyClosed": {
            "title": "Exclude temporarily-closed",
            "type": "boolean",
            "description": "Skip libraries/outlets flagged as temporarily closed in the survey year. On by default for a clean, contactable list.",
            "default": true
          },
          "minLeadScore": {
            "title": "Min lead score",
            "minimum": 0,
            "maximum": 100,
            "type": "integer",
            "description": "Only return records with a derived lead score (0–100) at or above this value."
          },
          "sortBy": {
            "title": "Sort order",
            "enum": [
              "leadScore",
              "populationHigh",
              "revenueHigh",
              "visitsHigh",
              "squareFeetHigh",
              "name",
              "state",
              "source"
            ],
            "type": "string",
            "description": "<b>Lead score</b> = highest-value accounts first (recommended). Population / Revenue / Visits = biggest libraries first. Square footage = biggest outlets first. Name / State = alphabetical. Source = file order (fastest).",
            "default": "leadScore"
          },
          "maxResults": {
            "title": "Max results",
            "minimum": 1,
            "type": "integer",
            "description": "Maximum number of records to return in this run. The full survey holds ~9,000 library systems and ~17,000 outlets.",
            "default": 1000
          },
          "maxResultsPerState": {
            "title": "Max results per state",
            "minimum": 1,
            "type": "integer",
            "description": "Optional — cap the number of records per state for an even national spread. Leave empty for no per-state cap."
          },
          "deduplicate": {
            "title": "Deduplicate",
            "type": "boolean",
            "description": "Remove duplicate records by unique IMLS identifier (FSCS key, plus outlet sequence for branches).",
            "default": true
          },
          "includeRawFields": {
            "title": "Include raw source fields",
            "type": "boolean",
            "description": "Attach the complete raw IMLS survey row as <code>sourceFields</code> on every record so no data is lost. Turn off for a smaller, tidier output.",
            "default": true
          },
          "monitorMode": {
            "title": "Monitoring mode — only new records",
            "type": "boolean",
            "description": "Remember which libraries/outlets were already returned (in a named key-value store) and emit ONLY records that are new since the last run — each tagged <code>monitorEvent: \"new\"</code>. IMLS refreshes the survey annually; run this on a Schedule to capture newly-added libraries as fresh 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) so different monitors don't share state.",
            "default": "default"
          },
          "dataFileUrl": {
            "title": "Data file URL (advanced)",
            "type": "string",
            "description": "Advanced: override the IMLS PLS public-use CSV ZIP URL. Leave empty to auto-resolve the latest fiscal year from the IMLS website."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "The actor downloads the official IMLS data file directly and needs no proxy in almost all cases — leave this off for the fastest, free download. If a direct download ever fails, the actor automatically retries through Apify Residential (US) proxy as a fallback.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}