--- status: accepted --- # Riot calls go through a relay that holds the production key This replaces the "personal Riot API key" part of ADR-0001; its two data sources stand. The app no longer sends a key: it calls a relay run by the maintainer, which holds Arena Tracker's production key, forwards only the app's six Riot calls and shares the quota between players (spec #144). Riot forbids opening an app to the public on a personal key and shipping a key inside a distributed binary, and a personal key (100 requests per 2 minutes) makes an import slow. The relay (`crates/relay`) is a request in, a request out: `/{routing value}{Riot path}`, a closed list of routing values and routes, no cache and nothing stored. It counts requests per routing value at the production limits and per client address, and answers 429 with Retry-After at once when either is full, or when Riot itself answered 429 for that routing value. A refused key (401, 403) becomes 503: it is the relay's problem, not the player's. A 403 on a Match's timeline is passed as is: Riot refuses some timelines on their own. The same process serves the Arena Tracker site (`site/`, #145), built into its binary, so there is one thing to deploy on the home server and the pages describe the service that serves them. Running it: `docs/service-relais.md`. ## Considered Options - **Each player's own personal key** (ADR-0001): not allowed for a public app, and a key to request, enter and renew for every player. - **The production key in the binary**: forbidden by Riot, and readable by anyone who has the app. - **The site apart, served by the reverse proxy**: one less job for the process that holds the key, but two things to deploy and keep in step. - **An async server (tokio, axum)**: more throughput than the quota allows; the relay uses threads and the `ureq` client the core already uses. ## Consequences - When the relay is down, imports stop; what is stored stays readable. - The relay sees each player's address and Riot IDs in transit; it logs only the type of call, the status and the duration. - A PUUID depends on the key's Riot application: switching to the production key changes every stored one. A sync and a Friend's import first ask Riot for the PUUID of the Riot ID, and move the stored Account to it only on proof: a stored published Match is listed for the new PUUID and the new PUUID has the same champion and Placement in it (the same participant, so not a mere co-participant of that Match). Without proof nothing changes. The follower's look-ups of a Match by id during a session do not check; they recover at the next sync (#150). - Not built yet: a cache of Matches (if the quota is reached), Riot's per-method limits (its 429 is respected).