# Gomi Day Calendar API, bulk data and MCP Household garbage collection days for municipalities in Japan, by address, as JSON, iCalendar and an MCP server. Served by the site's Worker at `https://gomiscan.com`. - **No authentication.** No keys, logins or cookies. Read-only: every endpoint is `GET` (MCP uses `POST`). - **CORS** is open: `Access-Control-Allow-Origin: *`; preflight (`OPTIONS`) is answered. - **Caching:** `Cache-Control: public, max-age=3600` for data (search and lookups: 300 s; schedules never past midnight in Japan, because "from today" changes then; errors: 60 s; server errors: `no-store`). The Worker also keeps successful GETs in the edge cache for the same time, so repeated requests don't reach the database. That is the only abuse guard. Please cache on your side too. - **Machine-readable description:** OpenAPI 3.1 at [`/api/v1/openapi.json`](https://gomiscan.com/api/v1/openapi.json). This page is served at [`/api/v1/docs`](https://gomiscan.com/api/v1/docs) and linked from `/llms.txt` and the site footer. ## Versioning The path carries the major version: `/api/v1/…`. Within v1, fields may be **added** to any object at any time. They are never renamed or removed, and a field's meaning never changes. A breaking change gets a new prefix (`/api/v2`), and v1 keeps running alongside it. The bundle format behind `/bundle` has its own `schemaVersion` (currently 1, JSON Schema at `/api/v1/schema/bundle.v1.json`). The unversioned `GET /api/search?q=` from before v1 still works, with the same release gate (below). ## What is published The API serves the same data as the website's pages. Today that is **every built schedule**: we publish what we have built and take a municipality down if it asks us to. Each record still says where it stands: - `release` is `true` when the municipality's reuse terms are cleared (`terms` is `open` or `facts-free`) **and** the data is confirmed current (`currency.status` is `verified`), `false` otherwise. A `false` schedule is served too; check `terms` and `currency` before you reuse it, and defer to the municipality. - `scheduleAvailable` is whether a schedule is built (areas, the address → area mapping, dates, the bundle). Every built schedule is served, whatever its `release`, `terms` or `currency` (`docs/decisions.md`, 2026-11-23 "No release gate"). For a municipality without one, the schedule, lookup, towns and bundle endpoints answer `404 not_found`. `withheld` is always `null` and kept only for older clients. ## Attribution and timestamps Every response that carries schedule data (a municipality, schedule, lookup, towns, bundle, 粗大ごみ, and each search hit with an area) has an `attribution` object. Show the `sources[].license.attribution` text where the licence asks for it, and point people to the municipality's own announcements. | Field | Meaning | Where it comes from | |---|---|---| | `municipalityCode` | 6-digit 全国地方公共団体コード | `municipalities.code` | | `terms` | `open`, `facts-free`, `unconfirmed`, `restricted` (or `null` when nothing was researched) | `municipalities.terms`: the registry entry's terms, via the bundle index | | `release` | Published (see above) | `municipalities.release` | | `currency.status`, `currency.basis` | `verified` or `unverified`, and how we know. Passed through exactly as stored. `null` when there is no bundle | `municipalities.currency_status/basis` (registry `currency`) | | `bundle.version`, `bundle.generatedAt` | The pipeline's data version and build time | The bundle's own `version`/`generatedAt` (`municipalities.meta`) | | `sources[].id, url, format, license{name,url,attribution}` | Every source the bundle cites | Bundle `sources` (`municipalities.meta`) | | `sources[].fetchedAt` | When the copy we built from was fetched | Bundle `sources[].fetchedAt` | | `sources[].lastCheckedAt` | The pipeline watcher's last **successful** fetch of that URL | `source_checks.last_success_at` (from `packages/pipeline/data/state.json`, migration 0005) | | `sources[].lastCheckAttemptAt`, `lastCheckStatus` | The watcher's last attempt and its result (`ok` / `failed`) | `source_checks` | | `sources[].unchangedSinceFetch` | `true` if the bytes at the last check equal the bytes we built from; `false` if they differ; `null` if never checked. HTML pages often differ for trivial reasons (dates in footers), so `false` means "look", not "wrong" | `source_checks.checksum` vs bundle `sources[].checksum` | | `notice` | Standard wording: compiled data, defer to the municipality | fixed | Per area, `verifiedAt` (the date an area was hand-checked, when the pipeline records one) and `confidence` come from the area's provenance. `approximate: true` means the area's boundary is coarser than the source's (confidence below high). For 粗大ごみ, the attribution's currency is the fee schedule's own (`currency` with `effectiveFrom`/`until` is also in `data`), and `feeTable.asOf` is the source's printed date. There is no "date we last confirmed the schedule is current" separate from `currency.basis`. The registry records how currency was established (in words), not when. `fetchedAt` / `lastCheckedAt` are the closest machine-readable dates. ## Errors Every error has the same shape, with a stable `code`: ```json { "error": { "status": 404, "code": "not_found", "message": "No schedule is built for 131041 yet. …" } } ``` | status | code | when | |---|---|---| | 400 | `bad_request`, `invalid_code`, `invalid_prefecture`, `invalid_status`, `invalid_range`, `missing_query` | A parameter is wrong | | 404 | `not_found` | No such municipality, area or endpoint, or no schedule built for that municipality | | 405 | `method_not_allowed` | Anything but GET/HEAD/OPTIONS under `/api/v1` | | 500 | `internal_error` | Our fault | ## Endpoints Base: `https://gomiscan.com/api/v1`. Ids are stable: municipalities by their 6-digit code (wards of designated cities that have their own schedule have their own code and a `parentCode`), areas by the bundle's area `id`. | Endpoint | What | |---|---| | `GET /` | Index of endpoints | | `GET /prefectures` | The 47 prefectures, with municipality and schedule counts | | `GET /municipalities?prefecture=&status=&released=&name=` | Every municipality and ward row with coverage status. `prefecture`: code (`13`) or slug (`tokyo`). `status`: `schedule`, `schedule-unverified`, `sorting`, `researched`, `todo`. `released=true`: only published schedules | | `GET /municipalities/{code}` | One municipality: prefecture, parent/wards, sources; `categories` and `areas` (id, name, approximate, location, links) when released | | `GET /municipalities/{code}/areas/{areaId}/schedule?from=&to=` | Dates by category (`categories[].dates`) and as a list (`events`, with `origin` `rule`/`moved`/`added`). Default: today (Japan time) and the next 89 days. At most 366 days, not before today, at most 400 days ahead | | `GET /municipalities/{code}/lookup?address=` | An address within that municipality → `match` `area` / `choose` (with `choices`) / `partial` / `none` | | `GET /municipalities/{code}/towns` | The step-by-step picker's data: every town with kana/romaji and which area covers which 丁目/番 range | | `GET /municipalities/{code}/oversized` | 粗大ごみ: booking, payment, put-out rules, self-haul, what isn't accepted, items; exact fees only while verified and in effect (`feesShown`). A ward falls back to its city | | `GET /municipalities/{code}/bundle` | The whole released bundle (rules, areas with matchers, exceptions, holidays) | | `GET /bulk` | Every released bundle: code, version, download link | | `GET /search?q=` | Free text (Japanese, romaji in any order) or postal code → hits, exact areas first | | `GET /schema/bundle.v1.json` | JSON Schema of the bundle | | `GET /openapi.json` | OpenAPI 3.1 | Dates are computed from the municipality's own rules and exceptions by the same engine as the site and the app. Where the data stops, the API stops too. `warnings` explains it (`ScheduleEnds`: a category's data ends on `lastDate`; `HolidayCalendarNotCovered`: holidays are known only for part of the range). The API never extends a schedule past its data, and never gives dates before today, because the current rules don't say what the old schedule was. ### Machine-readable schedules - **JSON:** the schedule endpoint above. - **iCalendar:** `https://gomiscan.com/ics/{code}/{areaId}` (`?lang=en` for English names): the next 12 months, with a reminder the evening before. Each area's `links.ics`. - **Bulk JSON:** `/api/v1/bulk` lists every released bundle; `/api/v1/municipalities/{code}/bundle` downloads one, in the bundle schema with an `attribution` beside it. To mirror everything, walk `/bulk` and fetch each `links.bundle`. Compare `version` to skip unchanged bundles. ## MCP server A remote [Model Context Protocol](https://modelcontextprotocol.io) server on the same Worker: - **URL:** `https://gomiscan.com/mcp` - **Transport:** Streamable HTTP. Each JSON-RPC 2.0 message is `POST`ed and answered with `application/json`. The server is stateless: it sets no `Mcp-Session-Id`, offers no SSE stream (`GET /mcp` → 405), and keeps nothing between requests. Batches (arrays) are accepted. - **Protocol versions:** 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 (negotiated in `initialize`; an unsupported `MCP-Protocol-Version` header gets 400). - **Auth:** none. - **Capabilities:** `tools` only (no resources or prompts). | Tool | Arguments | Returns | |---|---|---| | `search_address` | `query` | As `/search`: municipality hits, with the area (or the choices) where published | | `get_schedule` | `municipality_code`, `area_id`, `count` (1–100, default 10), `from` (optional date) | The next N collections (date, weekday, category names), warnings, attribution | | `list_municipalities` | `prefecture`, `status`, `released_only`, `name`, `limit` (default 100), `offset` | As `/municipalities`, paged | | `get_municipality` | `code` | As `/municipalities/{code}` | | `get_oversized` | `code` | As `/municipalities/{code}/oversized` | | `list_prefectures` | — | As `/prefectures` | Each result has the JSON both as `structuredContent` and as one text content block. Errors from a tool (bad arguments, `not_found`) come back as `isError: true` results, so the model can read them. An unknown tool is a JSON-RPC error (`-32602`). ### Connecting a client - **Claude Code:** `claude mcp add --transport http gomi https://gomiscan.com/mcp` - **Claude (claude.ai / desktop):** Settings → Connectors → Add custom connector → URL `https://gomiscan.com/mcp`. - **Clients configured with JSON** (Cursor, VS Code, others that speak Streamable HTTP): ```json { "mcpServers": { "gomi": { "type": "http", "url": "https://gomiscan.com/mcp" } } } ``` Clients that only speak stdio can go through a bridge such as `npx mcp-remote https://gomiscan.com/mcp`. - **Try it:** `npx @modelcontextprotocol/inspector`, transport "Streamable HTTP", URL as above. Or with curl: ```sh curl -s https://gomiscan.com/mcp -H 'content-type: application/json' -H 'accept: application/json, text/event-stream' \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"search_address","arguments":{"query":"112-0004"}}}' ``` ## Samples From local dev (`vite dev`) on 2026-11-23, against the local D1. Trimmed where marked `…`. `GET /api/v1/search?q=112-0004`: a postal code whose town is split by 丁目: ```json { "data": { "query": "112-0004", "hits": [{ "municipality": { "code": "131059", "nameJa": "文京区", "status": "schedule", "release": true, "scheduleAvailable": true, "…": "…" }, "query": "後楽", "match": "choose", "area": null, "choices": [ { "id": "a9f453c6150", "nameJa": "後楽 1丁目", "links": { "schedule": "https://gomiscan.com/api/v1/municipalities/131059/areas/a9f453c6150/schedule", "ics": "https://gomiscan.com/ics/131059/a9f453c6150" } }, { "id": "aef7818e177", "nameJa": "後楽 2丁目", "links": { "…": "…" } } ], "attribution": { "…": "…" } }] }, "count": 1 } ``` `GET /api/v1/search?q=100-0005` → `match: "area"`, area 「丸の内一丁目~三丁目(カレンダー4)」 in 千代田区 (131016). `GET /api/v1/search?q=100-0001` → 千代田区 with `match: "municipality"`: no area names that town. `GET /api/v1/municipalities/131059/areas/a9f453c6150/schedule?from=2026-12-28&to=2027-01-08`: the New Year closure (12/31–1/3) shows up as missing days, not as invented ones: ```json { "data": { "municipality": { "code": "131059", "nameJa": "文京区", "nameEn": "Bunkyo City" }, "area": { "id": "a9f453c6150", "nameJa": "後楽 1丁目", "nameEn": null, "approximate": false, "confidence": "high", "verifiedAt": null, "location": null, "links": { "…": "…" } }, "range": { "from": "2026-12-28", "to": "2027-01-08", "timeZone": "Asia/Tokyo" }, "categories": [ { "id": "burnable", "kind": "burnable", "nameJa": "可燃ごみ", "nameEn": "Burnable", "note": "資源・ごみ収集日(資源とごみは収集日の朝8時までにお出しください)", "dates": ["2026-12-29", "2027-01-05", "2027-01-08"] }, { "id": "non-burnable", "kind": "nonBurnable", "nameJa": "不燃ごみ", "nameEn": "Non-burnable", "note": "…", "dates": ["2027-01-07"] }, { "id": "resources", "kind": "recyclables", "nameJa": "資源(古紙・びん・缶・ペットボトル)", "nameEn": "Recyclables", "note": "…", "dates": ["2026-12-30", "2027-01-06"] }, { "id": "plastic", "kind": "plastic", "nameJa": "資源(プラスチック)", "nameEn": "Plastic", "note": "…", "dates": [] } ], "events": [ { "date": "2026-12-29", "categoryId": "burnable", "origin": "rule" }, { "date": "2026-12-30", "categoryId": "resources", "origin": "rule" }, { "date": "2027-01-05", "categoryId": "burnable", "origin": "rule" }, "…" ], "warnings": [] }, "attribution": { "municipalityCode": "131059", "terms": "open", "release": true, "currency": { "status": "verified", "basis": "CSV Last-Modified 2026-03-23 (FY2026 update); New Year notice for FY2026 read" }, "bundle": { "version": "2026-11-21.2", "generatedAt": "2026-11-21T15:49:45.360Z" }, "sources": [ { "id": "bunkyo-csv", "url": "https://www.city.bunkyo.lg.jp/documents/6059/syusyubi.csv", "format": "csv", "license": { "name": "CC BY 4.0", "url": "https://creativecommons.org/licenses/by/4.0/deed.ja", "attribution": "出典:文京区「ごみと資源の収集日」(東京都オープンデータカタログサイト掲載、CC BY 4.0)" }, "fetchedAt": "2026-11-21T15:49:45.549Z", "lastCheckedAt": "2026-11-22T00:25:08.097Z", "lastCheckAttemptAt": "2026-11-22T00:25:08.097Z", "lastCheckStatus": "ok", "unchangedSinceFetch": true }, "…" ], "notice": "Compiled by Gomi Day Calendar (gomiscan.com) from what each municipality publishes. Credit the sources below as their licences require, and defer to the municipality's own announcements." } } ``` `GET /api/v1/municipalities/131130`: a held municipality (restricted terms), listed with no areas: ```json { "data": { "code": "131130", "nameJa": "渋谷区", "nameEn": "Shibuya City", "nameKana": "シブヤク", "status": "schedule", "release": false, "scheduleAvailable": true, "terms": "restricted", "currency": { "status": "verified", "basis": "Parsed live from the ward's current 収集日 page (FY2026)" }, "areaCount": 63, "version": "2026-11-21.3", "categories": [ "…" ], "areas": [ "…" ], "withheld": null, "oversized": { "available": false, "code": null, "links": {} }, "…": "…" }, "attribution": { "terms": "restricted", "release": false, "sources": [{ "id": "shibuya-html", "url": "https://www.city.shibuya.tokyo.jp/kurashi/gomi/kateigomi/gomid.html", "license": { "name": "渋谷区ホームページ(利用条件未確認、issue #2)", "url": null, "attribution": "出典:渋谷区「地域別収集曜日一覧」" }, "fetchedAt": "2026-11-21T17:14:57.338Z", "lastCheckedAt": "2026-11-22T00:25:19.498Z", "unchangedSinceFetch": false, "…": "…" }], "…": "…" } } ``` `GET /api/v1/municipalities/131041/areas/anything/schedule` (no schedule built yet): ```json { "error": { "status": 404, "code": "not_found", "message": "No schedule is built for 131041 yet. Its status and sources are at /api/v1/municipalities/131041." } } ``` MCP `initialize` (request `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}`): ```json { "jsonrpc": "2.0", "id": 1, "result": { "protocolVersion": "2025-06-18", "capabilities": { "tools": { "listChanged": false } }, "serverInfo": { "name": "gomi", "title": "Gomi Day Calendar (ごみの日カレンダー)", "version": "1.0.0", "websiteUrl": "https://gomiscan.com" }, "instructions": "Household garbage collection days for municipalities in Japan, by address. … call search_address … then get_schedule …" } } ``` MCP `tools/call` `get_schedule` `{"municipality_code":"131059","area_id":"a9f453c6150","count":4}` → `structuredContent.data`: ```json { "municipality": { "code": "131059", "nameJa": "文京区", "nameEn": "Bunkyo City" }, "area": { "id": "a9f453c6150", "nameJa": "後楽 1丁目", "…": "…" }, "from": "2026-11-23", "collections": [ { "date": "2026-11-24", "categoryId": "burnable", "origin": "rule", "weekday": "Tue", "categoryJa": "可燃ごみ", "categoryEn": "Burnable" }, { "date": "2026-11-25", "categoryId": "resources", "origin": "rule", "weekday": "Wed", "categoryJa": "資源(古紙・びん・缶・ペットボトル)", "categoryEn": "Recyclables" }, { "date": "2026-11-27", "categoryId": "burnable", "origin": "rule", "weekday": "Fri", "categoryJa": "可燃ごみ", "categoryEn": "Burnable" }, { "date": "2026-11-28", "categoryId": "plastic", "origin": "rule", "weekday": "Sat", "categoryJa": "資源(プラスチック)", "categoryEn": "Plastic" } ], "warnings": [] } ``` A municipality without a schedule through MCP: `get_schedule` for 131041 → `{"isError": true, "structuredContent": {"error": {"code": "not_found", …}}}`. ## Not included (yet) - No sorting lists (分別) in the API. They have their own terms and aren't in D1. - No per-request rate limiting. Caching is the only guard. Add Cloudflare rate-limiting rules if traffic needs it. - No SSE streaming, sessions, resources or prompts in MCP. Nothing here needs them. - The `.ics` feed belongs to the site and follows the site's preview switch. The API links to it only for released areas.