{
  "openapi": "3.0.1",
  "info": {
    "title": "Japan Tokyo Open Data Catalog (CKAN API)",
    "description": "Unofficial client for the Tokyo Metropolitan Government Open Data Catalog (CKAN API v3, no key). Search datasets by keyword/publisher/category, or download a dataset's CSV records as structured JSON (Shift_JIS aware). CC BY 4.0.",
    "version": "0.1",
    "x-build-id": "agYYuHB9FaIziyB2x"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/jpopendata~japan-tokyo-opendata/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-jpopendata-japan-tokyo-opendata",
        "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/jpopendata~japan-tokyo-opendata/runs": {
      "post": {
        "operationId": "runs-sync-jpopendata-japan-tokyo-opendata",
        "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/jpopendata~japan-tokyo-opendata/run-sync": {
      "post": {
        "operationId": "run-sync-jpopendata-japan-tokyo-opendata",
        "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": {
          "mode": {
            "title": "Mode",
            "enum": [
              "search_datasets",
              "get_records"
            ],
            "type": "string",
            "description": "`search_datasets` (default) finds datasets (CKAN package_search) and returns their metadata incl. resource CSV URLs — set at least one of query / organization / tags / group. `get_records` downloads a dataset's CSV resource(s) and returns the rows as structured JSON — set datasetId or resourceUrl. Example: \"search_datasets\".",
            "default": "search_datasets"
          },
          "query": {
            "title": "Search keyword (search_datasets)",
            "type": "string",
            "description": "search_datasets mode: free-text query over dataset titles/descriptions (CKAN `q`), Japanese works best, e.g. \"保育\" (childcare), \"避難所\" (evacuation shelters), \"人口\". At least one of query / organization / tags / group is required in search_datasets mode."
          },
          "organization": {
            "title": "Organization (search_datasets)",
            "type": "string",
            "description": "search_datasets mode (optional): restrict to a publisher by its CKAN organization name, e.g. \"t131067\" (台東区 / Taito City). Find names in a search_datasets run (the `organizationId` field)."
          },
          "tags": {
            "title": "Tag (search_datasets)",
            "type": "string",
            "description": "search_datasets mode (optional): restrict to datasets carrying this CKAN tag (exact tag text, e.g. \"保育所\")."
          },
          "group": {
            "title": "Category / group (search_datasets)",
            "type": "string",
            "description": "search_datasets mode (optional): restrict to a category by its CKAN group name, e.g. \"c016\" (くらし・住まい) or \"c019\" (子供・若者・教育)."
          },
          "datasetId": {
            "title": "Dataset ID (get_records)",
            "type": "string",
            "description": "get_records mode (REQUIRED there unless resourceUrl is given): the CKAN dataset name/slug to read, e.g. \"t131067d0000000225\" — take it from a search_datasets run (the `datasetId` field). The Actor resolves the dataset's CSV/TSV resources and downloads their rows."
          },
          "resourceUrl": {
            "title": "Resource CSV URL (get_records)",
            "type": "string",
            "description": "get_records mode (alternative to datasetId): fetch this specific CSV resource URL directly (an absolute http(s) URL from a dataset's `resources[].url`)."
          },
          "encoding": {
            "title": "CSV encoding (get_records)",
            "enum": [
              "auto",
              "utf-8",
              "shift_jis"
            ],
            "type": "string",
            "description": "get_records mode: character encoding of the CSV body. `auto` (default) sniffs UTF-8 (incl. BOM) then falls back to Shift_JIS — many Japanese municipal CSVs are Shift_JIS. Spellings such as \"utf8\", \"Shift-JIS\", \"sjis\", \"cp932\" are accepted.",
            "default": "auto"
          },
          "maxItems": {
            "title": "Max items",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Maximum number of records (datasets or CSV rows) to output, 1-100000. PPE charges per record. Example: 1000.",
            "default": 1000
          },
          "maxApiRequests": {
            "title": "Max upstream requests per run",
            "minimum": 1,
            "maximum": 25,
            "type": "integer",
            "description": "Hard safety cap on upstream requests per run, 1-25 (search pages 1000 datasets per request; get_records may fetch several resources). Politeness (1 connection, >= 1.2 s spacing, exponential backoff on 429/5xx) is enforced in code. Example: 10.",
            "default": 10
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Apify proxy settings. Default is NO proxy (direct connection) — a public API rarely needs one. The Actor backs off exponentially on 429/5xx and fails visibly on a persistent block; it never attempts rate-limit evasion.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}