Lucra Sports Tournaments API
Modular tournament management endpoints. Unlike the legacy API which returns everything in a single call, the v2 API separates concerns into dedicated resources: | Resource | Path | Purpose | |----------|------|---------| | **Tournaments** | `/tournaments` | CRUD operations, cancel, complete | | **Leaderboard** | `/tournaments/:id/leaderboard` | Paginated participant rankings and scores | | **Rewards** | `/tournaments/:id/rewards` | Prize tier configuration and winner assignment | --- ## Key Differences from Legacy API ### Separate Resources The legacy `GET /pool-tournament/:id` returns the tournament, reward structure, and full user leaderboard in one response. The v2 API splits these into three independent endpoints so clients only fetch what they need. ### Update and Complete are Separate The legacy complete endpoint accepts tournament field updates (title, fee, etc.) in the same request body as the completion action. In v2, update the tournament first via `PATCH /tournaments/:id`, then complete via `POST /tournaments/:id/complete`. ### Reward Assignment is Explicit The legacy complete endpoint accepts a `paymentStructure` with `userId` to assign winners and complete in one step. In v2, assign rewards first via `PUT /tournaments/:id/rewards`, then complete the tournament separately. --- ## Tournament Types ### CASH_FIXED Prize pool is defined upfront. Values in the reward tiers represent absolute monetary amounts. ### CASH_PERCENTAGE Prize pool is calculated from total entry fees. Values in reward tiers represent percentages that must sum to exactly 100. --- ## Sign-Up Window Tournaments can optionally define a sign-up window using `signUpStart` and `signUpEnd`. When set, participants can only join during this window. If omitted, sign-ups follow the default behavior (open from creation until the tournament expires). | Constraint | Rule | |-----------|------| | `signUpEnd` ≤ `expiresAt` | Sign-ups must close before tournament expiration | | `signUpStart` ; rel="next", ; rel="first" ``` **Available link relations:** | Rel | Description | |-----|-------------| | `next` | Next page of results (omitted on the last page) | | `prev` | Previous page of results (omitted on the first page) | | `first` | First page of results | **Parsing the Link header:** ```typescript function parseLinkHeader(header: string): Record { return Object.fromEntries( header.split(', ').map((part) => { const [url, rel] = part.split('; '); return [ rel.replace('rel="', '').replace('"', ''), url.slice(1, -1), ]; }), ); } // Usage const links = parseLinkHeader(response.headers.link); if (links.next) { // fetch next page } ```