{
  "openapi": "3.0.1",
  "info": {
    "title": "Poland Local Statistics – GUS BDL API (Gmina, Powiat, TERYT)",
    "description": "Official GUS Bank Danych Lokalnych (BDL) API as flat rows for gmina, powiat and voivodeship: population, REGON, unemployment, budgets, housing. Includes TERYT codes. No scraping.",
    "version": "0.1",
    "x-build-id": "Y2oMZgm0KxBupVhxw"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/almmity~gus-bdl-poland-local-statistics/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-almmity-gus-bdl-poland-local-statistics",
        "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/almmity~gus-bdl-poland-local-statistics/runs": {
      "post": {
        "operationId": "runs-sync-almmity-gus-bdl-poland-local-statistics",
        "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/almmity~gus-bdl-poland-local-statistics/run-sync": {
      "post": {
        "operationId": "run-sync-almmity-gus-bdl-poland-local-statistics",
        "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": {
          "presets": {
            "title": "Ready-made indicators / Gotowe wskaźniki",
            "type": "array",
            "description": "Quick start without looking up variable IDs.",
            "items": {
              "type": "string",
              "enum": [
                "population",
                "firms_per_10k",
                "wage_vs_national",
                "unemployment_rate",
                "dwellings_per_1000",
                "budget_own_revenue_pc",
                "powiat_budget_own_revenue_pc"
              ],
              "enumTitles": [
                "Population total / Ludność ogółem (gmina)",
                "Firms in REGON per 10k residents / Podmioty REGON na 10 tys. ludności (gmina)",
                "Average gross wage vs national average, PL=100 / Wynagrodzenia w relacji do średniej krajowej (powiat)",
                "Registered unemployment rate (December) / Stopa bezrobocia rejestrowanego – grudzień (powiat)",
                "Dwellings completed per 1000 residents / Mieszkania oddane na 1000 ludności (gmina)",
                "Own budget revenue per capita / Dochody własne na 1 mieszkańca (gmina)",
                "Powiat budget own revenue per capita / Dochody własne budżetów powiatów na 1 mieszkańca (powiat)"
              ]
            },
            "default": []
          },
          "searchTerms": {
            "title": "Search variables by name / Szukaj zmiennych",
            "type": "array",
            "description": "Polish words work best (the BDL catalogue is in Polish), e.g. 'bezrobocia', 'REGON na 10 tys', 'mieszkania oddane', 'wynagrodzenia brutto'. Each term adds up to 'Max variables per search'. Matched variables are listed in the run log.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "maxVariablesPerSearch": {
            "title": "Max variables per search term",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "How many matching variables each search term may add (most relevant first).",
            "default": 10
          },
          "variableIds": {
            "title": "Variable IDs / ID zmiennych",
            "type": "array",
            "description": "Exact BDL variable IDs, e.g. 72305 (population total). Find them at bdl.stat.gov.pl or with 'Search variables'.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "unitLevel": {
            "title": "Territorial level / Poziom",
            "enum": [
              "0",
              "1",
              "2",
              "3",
              "4",
              "5",
              "6"
            ],
            "type": "string",
            "description": "Variables not published at this level are skipped with a warning.",
            "default": "2"
          },
          "parentUnitId": {
            "title": "Only inside this unit / Tylko w jednostce",
            "type": "string",
            "description": "Optional 12-digit BDL unit ID, e.g. 071400000000 = Mazowieckie. With level 6 this returns only gminas of that voivodeship.",
            "default": ""
          },
          "years": {
            "title": "Years / Lata",
            "type": "array",
            "description": "e.g. 2023, 2024. Empty = every year available (can be many rows).",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "lang": {
            "title": "Language of names",
            "enum": [
              "pl",
              "en"
            ],
            "type": "string",
            "description": "Language of subject and variable names where GUS provides translations.",
            "default": "pl"
          },
          "maxItems": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "0 = no limit.",
            "default": 10000
          },
          "clientId": {
            "title": "BDL API key (optional) / Klucz API",
            "type": "string",
            "description": "Free key from https://api.stat.gov.pl/Home/BdlApi raises GUS rate limits for big pulls (all ~4,200 gmina-level units, many years). Not needed for normal runs."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}