Populate all lines for a station in the Notion StationLine database.
The user will provide: $ARGUMENTS (a station name, e.g. "Shinjuku", "Shimbashi", "Ikebukuro")
Find the station in the Notion Stations database by matching the name. The station name format is "English 日本語" (e.g. "Shinjuku 新宿"). If the station doesn't exist, create it with a 🚉 emoji icon.
Check existing StationLine entries for the station to avoid creating duplicates.
Research all lines passing through this station by searching the web. For each line, find:
Determine badge style from the line code:
jre style (square badges)jre style (square badges)tssn style (circle badges)yk style (solid circle badges)Get or create lines in the Lines database. Set line icons to {BASE}/{style}/{code}.png?size=120.
Create StationLine entries for each line, with:
{BASE}/{style}/{code}/{number}.png?size=120Set icons on any existing StationLine entries that are missing badge icons.
Research the station's coordinates (latitude/longitude). Then set the Place property on all StationLine entries for this station (both new and existing) using the Notion private API (see "Setting Place on StationLine" below).
Show a summary of what was created.
Read the token from .env file (NOTION_TOKEN=...).
https://api.notion.com/v12022-06-28https://jdan--73a2eeba09df11f1a30442dde27851f2.web.val.run3076fc0faa7d8093b3afce6b0c25966d3076fc0faa7d8073b3eed1db67a8bcbc3076fc0faa7d80bda742cc7fa4041b06POST /pages
{
"parent": {"database_id": "<STATIONLINE_DB>"},
"icon": {"type": "external", "external": {"url": "<badge_url>"}},
"properties": {
"Name": {"title": [{"text": {"content": " "}}]},
"Station": {"relation": [{"id": "<station_id>"}]},
"Line": {"relation": [{"id": "<line_id>"}]},
"Stop": {"number": <stop_number>}
}
}
POST /pages
{
"parent": {"database_id": "<LINES_DB>"},
"icon": {"type": "external", "external": {"url": "<line_badge_url>"}},
"properties": {
"Name": {"title": [{"text": {"content": "Line Name"}}]}
}
}
The Place property (dsOX) on StationLine entries is not writable via the public Notion API. Use the private API instead. Read token_v2 from .env (NOTION_TOKEN_V2=...).
POST https://www.notion.so/api/v3/saveTransactionsFanout
Headers:
Content-Type: application/json
Cookie: token_v2=<NOTION_TOKEN_V2>
x-notion-space-id: e8bd2e4a-c367-4d7e-8c8b-ef47b27ac37a
x-notion-active-user-header: 84cb4838-4dc9-4d38-8cf8-c186b662dee9
notion-client-version: 23.13.20260214.1755
notion-audit-log-platform: web
Body:
{
"requestId": "<uuid>",
"transactions": [{
"id": "<uuid>",
"spaceId": "e8bd2e4a-c367-4d7e-8c8b-ef47b27ac37a",
"debug": {"userAction": "BlockPropertyValueOverlay.handlePlaceChange"},
"operations": [
{
"pointer": {"table": "block", "id": "<stationline_page_id>", "spaceId": "e8bd2e4a-c367-4d7e-8c8b-ef47b27ac37a"},
"path": ["properties", "dsOX"],
"command": "set",
"args": [["\u2023", [["plc", {"lat": <lat>, "lon": <lon>, "name": "<Station Name>"}]]]]
},
{
"pointer": {"table": "block", "id": "<stationline_page_id>", "spaceId": "e8bd2e4a-c367-4d7e-8c8b-ef47b27ac37a"},
"path": [],
"command": "update",
"args": {"last_edited_time": <epoch_ms>, "last_edited_by_id": "84cb4838-4dc9-4d38-8cf8-c186b662dee9", "last_edited_by_table": "notion_user"}
}
]
}],
"unretryable_error_behavior": "continue"
}
The name field should be the English station name (e.g. "Shinjuku Station"). The awsPlaceId and address fields are optional and can be omitted. Since all StationLine entries for one station share the same coordinates, look up the lat/lon once and apply to all entries.
urllib.request for all API calls (no external dependencies).01, 02).