TapIn Pokémon

WebSocket messages

The live channel: every message the client sends and the server pushes.

Everything that happens in real time (encounters, battles, challenges, trades, tournaments, flyovers) travels over one WebSocket at /pokemon-ws?token=<ID token>. Messages are JSON objects with a t field naming the message. Open one socket per tab; a trainer may have many tabs, and battle updates reach all of them. When the sign-in token refreshes, reconnect with the new one.

The first message on a new socket is welcome. Send context right after it and again whenever the page, the visibility or the local hour changes: the server uses it to place encounters (full screen or as a side panel on a live page), to pick the community's wild pool and to know the time of day.

These tables are generated from the ClientMessage and ServerMessage unions in net/protocol.ts.

Client to server

tFields
contextcontext: ClientContext
battle-actionbattleId: string; turn: number; action: BattleAction
battle-forfeitbattleId: string
challengetoUserId: string; communityHandle: string | null
challenge-responsechallengeId: string; accept: boolean
gym-challengecommunityHandle: string
encounter-dismissbattleId: string
debug-encounterspeciesId: number | null
tournament-opencommunityHandle: string
tournament-entertournamentId: string; team: string[]
tournament-leavetournamentId: string
tournament-starttournamentId: string
tournament-canceltournamentId: string
tournament-finaltournamentId: string; hostTeam: string[] | null
stage-decisiontournamentId: string; invited: boolean
legendary-eventcommunityHandle: string; speciesId: number
flyover-engageflyoverId: string
pingnone

Server to client

tFields
welcomeme: MeResponse; serverTime: number
trainertrainer: TrainerState
encounterbattle: BattleView; display: "fullscreen" | "panel"
battle-startbattle: BattleView; deadline: number | null
battle-updatebattle: BattleView; events: BattleEvent[]; deadline: number | null
battle-endbattle: BattleView; events: BattleEvent[]; rewards: BattleRewards | null
challenge-incomingchallenge: ChallengeView
challenge-closedchallengeId: string; reason: "declined" | "expired" | "cancelled" | "accepted" | "busy"
tradetrade: TradeView
tournamenttournament: TournamentView
stage-requesttournamentId: string; winner: TrainerSummary
stage-resulttournamentId: string; invited: boolean
legendarycommunityHandle: string; speciesId: number; by: TrainerSummary
toastlevel: "info" | "success" | "warning"; text: string
errorcode: string; message: string
flyoverflyover: FlyoverView
flyover-closedflyoverId: string; reason: "engaged" | "expired" | "stolen"
pongserverTime: number

TapIn Pokémon is an unofficial fan project. Pokémon and all related names and artwork are trademarks and © of Nintendo, Game Freak and Creatures. Legal

On this page