Skip to content

Web API

SpaceSquare640 edited this page Jul 11, 2026 · 1 revision

Web API

The Flask app (poketrack/web/server.py) serves both the rendered HTML pages and a small JSON API used by the TypeScript front-end. Everything here is unauthenticated and intended for local/trusted-network use (there's no built-in auth layer) — see Deployment before exposing it publicly.

HTML pages

Route Method Description
/ GET Dashboard. Query params: q (search text), type (event type), fav=1 (favorites only)
/event/<event_id> GET Event detail page. 404 if the ID isn't in the local store
/settings GET Settings page
/settings POST Save settings (form-encoded; see fields below)

JSON API

GET /api/events

Returns the current (filtered) event list as JSON. Same query params as /: q, type, fav=1.

[
  {
    "event_id": "", "name": "", "event_type": "community-day",
    "type_label": "Community Day", "heading": "", "link": "", "image": "",
    "start": "2026-08-16T14:00:00", "end": "2026-08-16T17:00:00",
    "start_display": "Aug 16, 2026 · 14:00", "end_display": "Aug 16, 2026 · 17:00",
    "region": "Global", "status": "upcoming", "status_color": "#FBBF24",
    "region_label": "Global", "countdown": "Starts in 3d",
    "description": "", "favorite": false,
    "bosses": [], "promocodes": [], "has_spawns": false, "has_research": false,
    "badge": "Upcoming"
  }
]

POST /api/refresh

Triggers an immediate fetch from the configured source (bypassing the scheduler interval) and returns the outcome. Also fires notifications/ webhook/Telegram for any newly-detected events (trigger_side_effects=True).

{ "ok": true, "count": 40, "new": 2, "message": "Updated" }

POST /api/favorite

Form body: type=<event_type>. Toggles that event type's favorited state and returns the new state — used by the web UI so starring doesn't reload the page.

{ "type": "community-day", "favorite": true }

Calendar feed

GET /calendar.ics

Returns an iCalendar (.ics) document, Content-Type: text/calendar.

  • With ?id=<event_id> — a single event.
  • Without id — the current filtered view (q, type, fav=1 params apply, same as /).

Point a calendar app's "subscribe by URL" at this endpoint (with your preferred filter params) for events to sync automatically on that app's own refresh schedule.

Settings management

Route Method Description
/settings/export GET Downloads the current config as poketrack-config.json
/settings/import POST Multipart file upload (file field); deep-merges over current config
/set-language POST Form field language; redirects back
/set-regions POST Form field regions (repeated, one per selected checkbox); redirects to /
/favorite POST Form field type; non-JSON variant of /api/favorite, redirects back (no-JS fallback)

/settings POST fields

webhook_url, webhook_secret, notifications (checkbox), notify_favorites_only (checkbox), telegram_token, telegram_chat, time_format (24h/12h), timezone (IANA name or empty), source (leekduck/blog), refresh_interval_minutes (integer minutes).

Notes for integrators

  • All routes assume a single-user, trusted-network deployment — there's no session/auth model. Don't expose /settings or /api/refresh (which can be used to force-trigger fetches) to the open internet without putting your own auth layer in front.
  • The JSON API has no versioning or stability guarantee yet; it mirrors whatever the bundled TypeScript front-end needs. Treat it as an internal API that happens to be easy to script against, not a public contract.
  • See Architecture for how PokeTrackService (the shared controller behind every route) is structured, if you're extending the API.

Clone this wiki locally