# Japan Tokyo Open Data Catalog (CKAN API) (`jpopendata/japan-tokyo-opendata`) Actor

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.

- **URL**: https://apify.com/jpopendata/japan-tokyo-opendata.md
- **Developed by:** [JP Open Data](https://apify.com/jpopendata) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 record scrapeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Japan Tokyo Open Data Catalog (CKAN API)

**Search the Tokyo Metropolitan Government Open Data Catalog by keyword, publisher or category — then actually download a dataset's CSV rows as clean, structured JSON (Shift\_JIS handled automatically).**

This Actor is a thin, polite client for the **official CKAN API v3** (`catalog.data.metro.tokyo.lg.jp/api/3/action/`) behind the 東京都オープンデータカタログサイト (Tokyo Metropolitan Government Open Data Catalog). It is **not a scraper** — it calls the documented CKAN JSON API, needs **no API key**, and returns each result as a flat record with a legal envelope (`source` / `sourceUrl` / `license` / `retrievedAt`) on every item.

The catalogue as a whole is a directory, not a product. The value here is `get_records`: point it at a dataset and it fetches the actual CSV distribution and returns its rows — so you get the *data*, not just a link to it.

> **Unofficial tool.** Independently built and maintained. **Not affiliated with, endorsed by, or connected to the Tokyo Metropolitan Government** or any ward/municipal publisher. Catalogue content is provided under **CC BY 4.0** (東京都オープンデータ利用規約), which permits commercial reuse with attribution; the required 出典 statement **「出典：東京都オープンデータカタログサイト」** is embedded in the `license` of every record.

***

### Quick start — verified input

Copy, paste, run. This exact input is verified on the platform (SUCCEEDED, items > 0):

```json
{
  "mode": "search_datasets",
  "query": "保育"
}
```

Running with **no input at all** also works (same defaults). To download a dataset's rows, take a `datasetId` from the search output and run `{"mode": "get_records", "datasetId": "t131067d0000000225"}`.

### No API key required

The Tokyo Open Data CKAN API is public and unauthenticated. Just pick a mode and run. The Actor keeps a single connection, spaces requests ≥ 1.2 s apart, backs off exponentially on HTTP 429/5xx, and **fails visibly on a persistent block — it never attempts rate-limit evasion.**

### License & source-display obligation (出典表示義務)

The 東京都オープンデータ利用規約 states (原文): 「本サイトに存在する著作物……の著作権は、「注」があるものを除いて、クリエイティブ・コモンズ・ライセンス表示 4.0 国際のもとでライセンスされています。……複製、公衆送信、翻訳・変形等の翻案等、自由に利用できます。**商用利用も可能です。**」 — i.e. **CC BY 4.0 International**, commercial use permitted, with attribution.

- The credit **「出典：東京都オープンデータカタログサイト」** is embedded verbatim in the `license` field of every record. If you display or republish the data, keep that credit visible.
- **Per-dataset licenses are your responsibility.** Each dataset also reports its own license machine-readably in the `datasetLicense` field (typically `CC-BY-4.0`). Datasets marked 「注」 or carrying an individual license/terms are the user's responsibility to confirm. **The license and content of any individual dataset — including whether it contains personal data — must be checked by you before use.**

### Two modes

#### 1. `search_datasets` — find datasets (CKAN `package_search`)

Give a `query` (free text) and/or an `organization`, `tags`, or `group` filter, and get back matching datasets: `datasetId`, title, publisher, update date, the dataset's own license, a catalogue deep link, and the full `resources[]` list (each resource's CSV/XLSX **URL**, format and size). At least one filter is required (a targeted search, not a full-catalogue dump).

#### 2. `get_records` — download a dataset's CSV rows

Give a `datasetId` (from a `search_datasets` run) and the Actor resolves that dataset's CSV/TSV resources, downloads them, and returns **one record per CSV row** — the columns keyed by header, plus provenance (`datasetId`, `resourceName`, `resourceUrl`, `rowIndex`). Or pass a `resourceUrl` directly to fetch one specific distribution. Japanese municipal CSVs are frequently **Shift\_JIS**; `encoding: "auto"` (default) sniffs UTF-8 (incl. BOM) then falls back to Shift\_JIS, or force `utf-8` / `shift_jis`.

### Sample output

**search\_datasets** (dataset item):

```json
{
  "datasetId": "t131067d0000000225",
  "title": "保育施設",
  "organization": "台東区",
  "organizationId": "t131067",
  "datasetLicense": "CC-BY-4.0",
  "lastModified": "2025-12-12T08:10:50.232242",
  "datasetUrl": "https://catalog.data.metro.tokyo.lg.jp/dataset/t131067d0000000225",
  "numResources": 1,
  "resources": [
    { "name": "保育施設", "format": "CSV", "url": "https://www.city.taito.lg.jp/.../sisetu_03.csv", "size": 7168 }
  ],
  "groups": ["くらし・住まい", "子供・若者・教育"],
  "source": "東京都オープンデータカタログサイト / Tokyo Metropolitan Government Open Data Catalog (CKAN)",
  "sourceUrl": "https://portal.data.metro.tokyo.lg.jp/",
  "license": "出典：東京都オープンデータカタログサイト（https://portal.data.metro.tokyo.lg.jp/）。… CC BY 4.0 … Unofficial …",
  "retrievedAt": "2026-08-26T12:00:00.000Z"
}
```

**get\_records** (dataset item — one CSV row):

```json
{
  "datasetId": "t131067d0000000225",
  "datasetTitle": "保育施設",
  "resourceName": "保育施設",
  "resourceUrl": "https://www.city.taito.lg.jp/.../sisetu_03.csv",
  "rowIndex": 1,
  "fields": {
    "大分類": "区立保育園", "小分類": "区立保育園", "名称": "谷中保育園",
    "所在地": "上野桜木2丁目16番10号", "電話番号": "03-3828-3223",
    "X座標": "139.7714448", "Y座標": "35.72254338"
  },
  "source": "東京都オープンデータカタログサイト / Tokyo Metropolitan Government Open Data Catalog (CKAN)",
  "sourceUrl": "https://portal.data.metro.tokyo.lg.jp/",
  "license": "出典：東京都オープンデータカタログサイト … CC BY 4.0 … Unofficial …",
  "retrievedAt": "2026-08-26T12:00:00.000Z"
}
```

### Input reference

| Field | Mode | Description |
| --- | --- | --- |
| `mode` | both | `search_datasets` (default) or `get_records`. Case-insensitive; if you pass only a `datasetId`/`resourceUrl` the Actor switches to `get_records` for you. |
| `query` | search | Free-text query (CKAN `q`), Japanese works best, e.g. `保育`, `避難所`. |
| `organization` | search | CKAN organization name, e.g. `t131067` (台東区). |
| `tags` | search | Restrict to a CKAN tag. |
| `group` | search | Category/group name, e.g. `c016` (くらし・住まい). |
| `datasetId` | get\_records | Dataset name/slug to read, e.g. `t131067d0000000225` (from the search output). |
| `resourceUrl` | get\_records | Fetch a specific CSV resource URL directly. |
| `encoding` | get\_records | `auto` (default), `utf-8`, or `shift_jis` (`sjis`, `cp932` … accepted). |
| `maxItems` | both | Max records to output, 1–100000 (default 1000). |
| `maxApiRequests` | both | Hard per-run upstream request cap, 1–25 (default 10). |
| `proxyConfiguration` | both | Optional Apify proxy; default is a direct connection. |

At least one of `query` / `organization` / `tags` / `group` is required in `search_datasets` mode; `datasetId` or `resourceUrl` is required in `get_records` mode. Values are validated **before** the first request; an invalid value fails the run immediately with a message that lists the valid values.

#### Common input mistakes

| Mistake | Correct |
|---------|---------|
| `{"mode": "search_datasets"}` with no filter | add `"query": "保育"` (or `organization` / `tags` / `group`) |
| `{"mode": "search_datasets", "datasetId": "t131067d0000000225"}` | `"mode": "get_records"` — datasetId is a get\_records field |
| `{"mode": "get_records", "query": "保育"}` | get\_records needs `datasetId` or `resourceUrl`, not a query |
| `"datasetId": "https://catalog.data.metro.tokyo.lg.jp/dataset/t131067d0000000225"` | just the slug: `"t131067d0000000225"` |
| `"encoding": "euc-jp"` | `"auto"`, `"utf-8"` or `"shift_jis"` |
| `"maxItems": "all"` | a number, e.g. `1000` |

#### Empty results?

A run that finds nothing completes with 0 items and a warning in the log (not a failure). Typical causes: an English `query` (the catalogue is Japanese — try `保育` instead of `childcare`), a `tags`/`group`/`organization` value that is not an exact CKAN name, or a `get_records` dataset whose resources are all XLSX/PDF (only CSV/TSV are read — pass a `resourceUrl` to a CSV). Broaden the query or drop a filter and retry.

### Notes & limits

- `get_records` reads **CSV/TSV** resources. Non-CSV distributions (XLSX, PDF, etc.) are skipped — pass a `resourceUrl` to a CSV, or read the XLSX yourself.
- Resource files are hosted on the publishers' own servers (ward/city domains). A resource that responds with a redirect surfaces as an error (the Actor does not follow redirects to keep the request budget honest) — re-run with the final URL.
- `search_datasets` pages at up to 1000 datasets per request under `maxItems`.

### Disclaimer

1. **Unofficial** — not affiliated with, endorsed by, or connected to the Tokyo Metropolitan Government or any ward/municipal data publisher.
2. **Public data, your responsibility** — data is provided under CC BY 4.0 (東京都オープンデータ利用規約). Keep the 出典 credit visible. Each dataset's own license (`datasetLicense`) and content — including any personal data it may contain — are the user's responsibility to verify before use.
3. **Polite by design** — one connection, ≥ 1.2 s spacing, exponential backoff, a hard request budget, and a visible failure on a persistent block. No rate-limit evasion.
4. **No warranty** — provided "as is"; verify anything important against the source catalogue.

### Search terms

tokyo open data api, japan municipal data, tokyo government datasets english, CKAN japan, tokyo metropolitan open data, japan open data csv, 東京都 オープンデータ, japan city data api, tokyo ward datasets, japanese government open data

# Actor input Schema

## `mode` (type: `string`):

`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".

## `query` (type: `string`):

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` (type: `string`):

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` (type: `string`):

search\_datasets mode (optional): restrict to datasets carrying this CKAN tag (exact tag text, e.g. "保育所").

## `group` (type: `string`):

search\_datasets mode (optional): restrict to a category by its CKAN group name, e.g. "c016" (くらし・住まい) or "c019" (子供・若者・教育).

## `datasetId` (type: `string`):

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` (type: `string`):

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` (type: `string`):

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.

## `maxItems` (type: `integer`):

Maximum number of records (datasets or CSV rows) to output, 1-100000. PPE charges per record. Example: 1000.

## `maxApiRequests` (type: `integer`):

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.

## `proxyConfiguration` (type: `object`):

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.

## Actor input object example

```json
{
  "mode": "search_datasets",
  "query": "保育",
  "organization": "t131067",
  "tags": "保育所",
  "group": "c016",
  "datasetId": "t131067d0000000225",
  "resourceUrl": "https://www.city.taito.lg.jp/opendata/example.csv",
  "encoding": "auto",
  "maxItems": 1000,
  "maxApiRequests": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `records` (type: `string`):

Dataset metadata records (search\_datasets) or CSV-row records (get\_records), with source attribution (source, sourceUrl, license, retrievedAt) on every item.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "search_datasets",
    "query": "保育",
    "encoding": "auto",
    "maxItems": 1000,
    "maxApiRequests": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("jpopendata/japan-tokyo-opendata").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "search_datasets",
    "query": "保育",
    "encoding": "auto",
    "maxItems": 1000,
    "maxApiRequests": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("jpopendata/japan-tokyo-opendata").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "search_datasets",
  "query": "保育",
  "encoding": "auto",
  "maxItems": 1000,
  "maxApiRequests": 10
}' |
apify call jpopendata/japan-tokyo-opendata --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jpopendata/japan-tokyo-opendata"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WWQkXxWnYY5sz7bsN/builds/agYYuHB9FaIziyB2x/openapi.json
