{
  "openapi": "3.0.1",
  "info": {
    "title": "Spain Construction Leads — Licencias de Obra & Obras Públicas",
    "description": "Construction leads in Spain from official open data: Madrid building licences, Barcelona public-space works with contractor and budget, and PLACSP public works tenders and awards (CPV 45). Filter by city, type, budget and date. Schedule weekly with Only-new and pay only for new leads. $5 per 1,000.",
    "version": "0.1",
    "x-build-id": "GHWYiph1B3cSp67jb"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/icarodata~spain-construction-leads/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-icarodata-spain-construction-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/icarodata~spain-construction-leads/runs": {
      "post": {
        "operationId": "runs-sync-icarodata-spain-construction-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/icarodata~spain-construction-leads/run-sync": {
      "post": {
        "operationId": "run-sync-icarodata-spain-construction-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": "Sources",
            "type": "array",
            "description": "Official datasets to read. All by default.",
            "items": {
              "type": "string",
              "enum": [
                "madrid_licencias",
                "barcelona_obras",
                "placsp_obras"
              ],
              "enumTitles": [
                "Madrid — granted building licences",
                "Barcelona — public-space works (contractor & budget)",
                "PLACSP — public works tenders & awards (all Spain)"
              ]
            },
            "default": [
              "madrid_licencias",
              "barcelona_obras",
              "placsp_obras"
            ]
          },
          "leadTypes": {
            "title": "Lead types",
            "type": "array",
            "description": "Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "building_licence",
                "public_space_works",
                "public_works_tender",
                "public_works_award"
              ],
              "enumTitles": [
                "Building licence granted",
                "Public-space works in progress",
                "Public works tender (open for bids)",
                "Public works contract awarded (winning contractor)"
              ]
            },
            "default": []
          },
          "municipalities": {
            "title": "Municipalities",
            "type": "array",
            "description": "Optional city names, e.g. Madrid, Barcelona, Valencia, Sevilla. PLACSP covers every Spanish municipality; Madrid/Barcelona datasets are read only when those cities are included (or no city is set).",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "provinces": {
            "title": "Provinces",
            "type": "array",
            "description": "Optional province names (Madrid, Barcelona, Málaga…).",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "districts": {
            "title": "Districts",
            "type": "array",
            "description": "Optional districts, e.g. Eixample, Gràcia, Chamberí, Hortaleza.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "worksTypes": {
            "title": "Works types",
            "type": "array",
            "description": "Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "residential_works",
                "commercial_premises_works",
                "activity_opening",
                "first_occupancy",
                "temporary_activity",
                "urbanisation",
                "utilities",
                "sewerage",
                "transport_infrastructure",
                "building",
                "paving",
                "green_spaces",
                "mobility",
                "cranes",
                "street_lighting",
                "school_surroundings",
                "public_works",
                "works_concession",
                "other"
              ],
              "enumTitles": [
                "Residential works licence (Madrid)",
                "Commercial premises / activity works (Madrid)",
                "Activity opening licence (Madrid)",
                "First occupancy — new/finished building (Madrid)",
                "Temporary activity (Madrid)",
                "Urbanisation (Barcelona)",
                "Utilities: water, power, gas, telecom (Barcelona)",
                "Sewerage (Barcelona)",
                "Transport infrastructure (Barcelona)",
                "Building works (Barcelona)",
                "Paving (Barcelona)",
                "Green spaces (Barcelona)",
                "Mobility (Barcelona)",
                "Cranes (Barcelona)",
                "Street lighting (Barcelona)",
                "School surroundings (Barcelona)",
                "Public works contract (PLACSP)",
                "Works concession (PLACSP)",
                "Other"
              ]
            },
            "default": []
          },
          "keywords": {
            "title": "Keywords",
            "type": "array",
            "description": "Keep leads containing ANY keyword in title, description, address or company names (e.g. fachada, cubierta, rehabilitación, telecomunicacions).",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "excludeKeywords": {
            "title": "Exclude keywords",
            "type": "array",
            "description": "Drop leads containing ANY of these words.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "minBudget": {
            "title": "Minimum budget (EUR)",
            "minimum": 0,
            "type": "integer",
            "description": "Keep leads whose budget is at least this amount. Madrid licences publish no budget and are dropped when set, unless 'Keep leads without budget' is on."
          },
          "maxBudget": {
            "title": "Maximum budget (EUR)",
            "minimum": 0,
            "type": "integer",
            "description": "Keep leads whose budget is at most this amount."
          },
          "keepLeadsWithoutBudget": {
            "title": "Keep leads without budget",
            "type": "boolean",
            "description": "With a minimum budget set, still keep leads that publish no budget.",
            "default": false
          },
          "daysBack": {
            "title": "Days back",
            "minimum": 1,
            "maximum": 3650,
            "type": "integer",
            "description": "Look-back window on the lead date (licence granted, works start, tender published or contract awarded) when 'Since date' is empty. Madrid publishes monthly, so keep at least 31 days for Madrid.",
            "default": 30
          },
          "sinceDate": {
            "title": "Since date",
            "type": "string",
            "description": "Optional YYYY-MM-DD. Overrides 'Days back'."
          },
          "untilDate": {
            "title": "Until date",
            "type": "string",
            "description": "Optional YYYY-MM-DD (inclusive)."
          },
          "statuses": {
            "title": "Statuses",
            "type": "array",
            "description": "Optional: granted (Madrid), in_progress / finished / stopped (Barcelona), open / announced / pending_award / awarded / resolved (PLACSP).",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "applicantTypes": {
            "title": "Madrid applicant types",
            "type": "array",
            "description": "Optional filter for Madrid licences. Names are never published; for private individuals the street number is removed.",
            "items": {
              "type": "string",
              "enum": [
                "company",
                "homeowners_association",
                "public_body",
                "individual"
              ],
              "enumTitles": [
                "Company",
                "Homeowners' association",
                "Public body",
                "Private individual (street-level address only)"
              ]
            },
            "default": []
          },
          "withContractorOnly": {
            "title": "Only leads with a named contractor",
            "type": "boolean",
            "description": "Keep only leads with a contractor company (Barcelona works, PLACSP awards).",
            "default": false
          },
          "maxPlacspPages": {
            "title": "Max PLACSP feed pages per feed",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Each official PLACSP ATOM page holds up to 500 procedures of all sectors and takes ~20–60 s to read; 5 pages per feed ≈ the last 1–2 days. Raise it (up to 200) together with 'Max run time' for longer back-fills; the run stops earlier once 'Maximum leads' is reached.",
            "default": 5
          },
          "maxItems": {
            "title": "Maximum leads",
            "minimum": 1,
            "maximum": 20000,
            "type": "integer",
            "description": "Stop after saving this many leads. You pay only for saved leads.",
            "default": 100
          },
          "maxRunTimeSecs": {
            "title": "Max run time (seconds)",
            "minimum": 0,
            "maximum": 86400,
            "type": "integer",
            "description": "Internal time budget. When it is reached the Actor stops reading feeds and saves the leads found so far (the run still succeeds). Default 180 s keeps runs fast; set e.g. 1800 with more PLACSP pages for long back-fills, or 0 for no internal limit (the platform run timeout still applies).",
            "default": 180
          },
          "onlyNewSinceLastRun": {
            "title": "Only new since last run",
            "type": "boolean",
            "description": "Return only leads not delivered in a previous run with the same filters (state in the named key-value store 'spain-construction-leads-state').",
            "default": 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
                  },
                  "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}