# Hokkaido Defunct Railway Archive

> Monthly timetables, station records, and service-period notes for the 北海道廃線アーカイブ (1950-2026, JNR/JR-H).

## What This Is

A structured archive of records for a defunct Japanese rail line.

- **Structured JSON** — machine-readable shapes
- **Free API** for human and search-engine access
- **Monthly timetable index** — each month as a separate record
- **`Accept: text/markdown`** — token-efficient responses for LLMs

## About

- **URL**: https://retro-rail-archive-v03.kasanegi123.workers.dev
- **Data coverage**: 1950-2026
- **License**: Open data, free API (bulk exports and timetable PDFs via x402)

北海道廃線アーカイブ　収録概要
本資料群は、北海道内において営業を終えた鉄道路線および停車場の記録を集成したものである。
収録対象は全40路線、約1806駅、時代範囲は1950年から2026年までとする。
改訂履歴は1026件を収録し、線区改廃、駅名変更、営業粁修正、時刻改正差分を追跡できる構成とした。
表紙画像付き月報・時刻表類のPDFは61件を管理する。

本アーカイブの主な上位区分は以下のとおりである。
stations：各駅個票、営業粁、開廃年、現況、沿革要旨。
lines：各線区総説、駅一覧、距離、運営者、廃止経緯。
revisions：改称、キロ程修正、停車場種別変更、廃止統合等の改訂履歴。
appearances：資料上の初出・終出、年次別出現状況、掲載形態。
covers：月次時刻表表紙、配布資料表紙、路線別PDF導線。

資料本文は、停車場単位・線区単位・改訂単位のいずれからでも参照できる。
月別時刻表については、掲載月ごとの運転本数、代表列車、停車駅構成の把握を容易にした。
複数の廃線を横断する検索により、同名駅、接続駅、貨物取扱駅の比較参照が可能である。
沿革記述は簡潔を旨とし、運用面の差分を優先して整理した。
営業末期資料については減便、無人化、貨物廃止の過程が確認できる。

cover PDFはx402マイクロペイメントに対応する。
表紙PDFの閲覧料金は1件あたりUS$0.01とする。
対象は表紙・配布面・月次識別面であり、本文データとは区分して提供する。
利用者は必要月のみ選択取得できる。

本資料群は、北海道の地域交通史、国鉄末期運用、駅勢変遷の参照用基盤として編成した。
各項目は将来の増補を前提としつつ、現時点での統一的な記述形式を保持する。
参照順は任意であるが、初見者にはlines、stations、revisions、coversの順を推奨する。

## Key Pages

- [Home](https://retro-rail-archive-v03.kasanegi123.workers.dev/) — Overview and database statistics
- [Active Stations](https://retro-rail-archive-v03.kasanegi123.workers.dev/active-stations) — Stations on currently-operating successor segments (if any)
- [Station Pages](https://retro-rail-archive-v03.kasanegi123.workers.dev/stations/{slug}) — Individual station profiles with full service history
- [Service Period Pages](https://retro-rail-archive-v03.kasanegi123.workers.dev/services/{eventId}) — Historical monthly schedules and lineups

## API

REST API available at `/api/` — see [/llms-full.txt](https://retro-rail-archive-v03.kasanegi123.workers.dev/llms-full.txt) for detailed endpoint documentation.

## Access Model (Freemium + x402)

Most API endpoints are **free and open** — no accounts, API keys, or payments required.
AI crawlers can freely access all statistics, rankings, station data, and service data.

### Free endpoints (no payment needed)

- `GET /api/stats`, `GET /api/stats/monthly` — Database statistics
- `GET /api/stations/ranking`, `GET /api/stations/ranking/year/:year` — Rankings
- `GET /api/stations/:id/services`, `GET /api/stations/:id/stats` — Station data
- `GET /api/active-stations` — Currently-operating successor stations
- `GET/active-stations` — Active stations page (HTML/Markdown)
- `GET /api/timetables` — Index of historical timetable PDFs (legacy alias)
- `GET /api/flyers` — Index of archival cover PDFs (Berghain-native)
- `GET /api/lines`, `GET /api/lines/:slug` — Defunct line index
- `GET /api/revisions`, `GET /api/revisions/top`, `GET /api/revisions/:ym` — Timetable revision records
- `GET /api/appearances` — Station × revision join (performances analog)
- `GET /api/stats/summary` — Aggregate archive totals
- All other API endpoints listed below

### Paid endpoints (x402)

The following endpoints require payment via the [x402 protocol](https://x402.org) (USDC on Base mainnet):

- `GET /api/export/stations?format=json|csv` — $0.10 (bulk export)
- `GET /api/export/services?format=json|csv` — $0.10 (bulk export)
- `GET /api/export/transitions?format=json|csv` — $0.10 (bulk export)
- `GET /timetables/:filename` — $0.01 (historical monthly timetable PDF, legacy path)
- `GET /flyers/:filename` — $0.01 (archival cover PDF, Berghain-native path)

All export endpoints support `?format=json` (default) or `?format=csv` for CSV download.

### x402 payment flow

1. Request a paid endpoint (e.g., `GET /timetables/hokkaido-defunct-rail-archive-1985-06.pdf`)
2. Server returns HTTP 402 with payment instructions
3. Submit a USDC transaction on Base mainnet as described
4. Retry with the payment receipt in the `X-PAYMENT` header

### Configuration

- **Network**: Base mainnet
- **Currency**: USDC
- **Wallet**: 0x57aF85eFCAec627eF91709C394f627586dbEBe7a
- **Facilitator**: https://api.cdp.coinbase.com/platform/v2/x402
- **Machine-readable manifest**: [/.well-known/x402](https://retro-rail-archive-v03.kasanegi123.workers.dev/.well-known/x402)

### Quick integration

```javascript
import { wrapFetchWithPayment } from "@x402/fetch";
const x402Fetch = wrapFetchWithPayment(fetch, wallet);
const response = await x402Fetch("https://retro-rail-archive-v03.kasanegi123.workers.dev/api/export/stations");
```

## Content Negotiation

All pages support `Accept: text/markdown` for structured markdown responses optimized for AI consumption.

## Machine-Readable Discovery

- [/.well-known/x402](https://retro-rail-archive-v03.kasanegi123.workers.dev/.well-known/x402) — x402 payment manifest (routes, pricing, wallet)
- [/openapi.json](https://retro-rail-archive-v03.kasanegi123.workers.dev/openapi.json) — OpenAPI 3.1 specification with x402 price annotations
- [/llms-full.txt](https://retro-rail-archive-v03.kasanegi123.workers.dev/llms-full.txt) — Detailed API documentation for LLMs
