{
  "openapi": "3.0.1",
  "info": {
    "title": "PxWeb Statistics Extractor",
    "description": "Point at ANY PxWeb statistical service (SCB Sweden, StatFi Finland, Norway, Iceland…): name a table and get flat, fully labeled statistics — one row per cell. Decodes index-encoded JSON-stat2, joining every dimension to its code + name. Discovery walks the subject tree. Pay per record.",
    "version": "0.1",
    "x-build-id": "OYZJ08JvaIxwPXKgT"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/datamule~pxweb-statistics-extractor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-datamule-pxweb-statistics-extractor",
        "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/datamule~pxweb-statistics-extractor/runs": {
      "post": {
        "operationId": "runs-sync-datamule-pxweb-statistics-extractor",
        "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/datamule~pxweb-statistics-extractor/run-sync": {
      "post": {
        "operationId": "run-sync-datamule-pxweb-statistics-extractor",
        "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",
        "required": [
          "serviceRoot"
        ],
        "properties": {
          "serviceRoot": {
            "title": "PxWeb API root URL",
            "type": "string",
            "description": "The REST API root of ANY PxWeb statistical service. Examples: https://api.scb.se/OV0104/v1/doris/en/ssd (Statistics Sweden) or https://pxdata.stat.fi/PxWeb/api/v1/en/StatFin (Statistics Finland). Also works with Norway, Iceland, Greenland and other PxWeb / PC-Axis dissemination platforms. No trailing slash needed."
          },
          "tablePath": {
            "title": "Table path (or navigation level)",
            "type": "string",
            "description": "The path, relative to the API root, to a leaf .px table to query, e.g. BE/BE0101/BE0101A/BefolkningNy (SCB Sweden population) or synt/12dj.px (StatFi births). Leave EMPTY (or point at a navigation level like BE) to DISCOVER: the actor lists the subject-tree nodes there so you can find tables. When it points at a leaf table the actor GETs its metadata and queries it."
          },
          "query": {
            "title": "Dimension selections (query)",
            "type": "object",
            "description": "Optional explicit selection of which dimension values to fetch. Two forms: a simple mapping {\"Region\": [\"00\"], \"Kon\": [\"1\", \"2\"], \"Tid\": [\"2023\"]}, or the native PxWeb array [{\"code\": \"Region\", \"selection\": {\"filter\": \"item\", \"values\": [\"00\"]}}]. Leave EMPTY to auto-select: all values of small mandatory dimensions, the last N periods of the time dimension, and aggregate over eliminable dimensions (keeps the cell count small and valid on any table)."
          },
          "lastNPeriods": {
            "title": "Last N periods (auto-query)",
            "minimum": 1,
            "type": "integer",
            "description": "When auto-selecting (no explicit query above), how many of the most recent time periods to fetch per series. Default 1 (the latest). Ignored when you supply an explicit query.",
            "default": 1
          },
          "discoveryRecurse": {
            "title": "Recurse when discovering",
            "type": "boolean",
            "description": "Discovery only (when the path points at a navigation level, not a leaf table). When ON, walk the navigation levels depth-first (bounded by Max depth) and emit every leaf .px table found, each with its full path. When OFF, list only the immediate child nodes.",
            "default": false
          },
          "maxDepth": {
            "title": "Max discovery depth",
            "minimum": 0,
            "type": "integer",
            "description": "Discovery recursion depth ceiling (only used with \"Recurse\"). Default 3. Higher values walk deeper subject trees but cost more navigation requests.",
            "default": 3
          },
          "maxRecords": {
            "title": "Max records",
            "minimum": 1,
            "type": "integer",
            "description": "Optional cap on the number of rows emitted (cells in data mode, nodes/tables in discovery mode). Each emitted row is one billable record. Leave empty to emit everything the query returns."
          },
          "bearer": {
            "title": "Bearer token",
            "type": "string",
            "description": "Optional bearer token for gated PxWeb services (sent as Authorization: Bearer ***). Not required for public dissemination services (SCB, StatFi…). Never logged."
          },
          "extraHeaders": {
            "title": "Extra request headers",
            "type": "object",
            "description": "Optional extra HTTP headers as a JSON object, e.g. {\"Ocp-Apim-Subscription-Key\": \"...\"} for gated services. Not required for public APIs. Header values are never logged."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}