feed365-api-harvest / 365-DOWNSTREAM-API.md
Shaurya2626's picture
Feed365 365races API harvest (redacted)
32cb649 verified
|
Raw
History Blame Contribute Delete
13.5 kB
# Feed365 — Downstream Aggregator API
Public multi-sport odds, scorecard, and live-TV feed for white-label aggregators and multi-platform downstreams.
| | |
|---|---|
| **Base URL** | `https://korewhitelabelmall.xyz` |
| **Prefix** | `/365` (alias `/api/365`) |
| **Contract** | Field-preserving raw payloads (`normalize: false`) |
| **Auth (all partner calls)** | `X-Aggregator-Key: <platform-key>` (also accepts `X-Api-Key`) |
| **Docs (public)** | `GET /365/docs` — no key |
| **Ops auth** | Ingest / heal / repair / session / leaks require **primary** `AGGREGATOR_API_KEY` (integrator slots denied) |
Production is fail-closed: without a configured key, partner routes return `503`; missing/wrong key returns `401`.
Do **not** rewrite or assume remapped field names. Use `_index` and documented ids for routing only.
---
## 1. Discovery
| Method | Path | Purpose |
|--------|------|---------|
| `GET` | `/365` | Service index |
| `GET` | `/365/health` | Liveness + `eventCount` |
| `GET` | `/365/catalog` | All sports with live `eventCount` + hrefs |
| `GET` | `/365/search?q=` | Search indexed events by name / teams / ids |
| `POST` | `/365/odds/unified` | Bulk market + fancy + scores by `matchIds` |
| `GET` | `/365/rotation` | Autorotate / pool health (ops) |
| `POST` | `/365/heal` | Clear cooldowns + reload cache |
| `POST` | `/365/repair` | Session repair (ops) |
---
## 2. Sport hierarchy (primary integration)
**Sport slugs:** `soccer`, `tennis`, `cricket`, `horse_racing`, `greyhound_racing`, `basketball`, `baseball`, `ice_hockey`, `american_football`, `mma`, `darts`, `snooker`, `golf`, `boxing`, `volleyball`, `rugby_union`, `rugby_league`, `athletics`, `motorsport`, `specials`, …
**Aliases:** `football` → soccer · `horseracing` / `horse-racing` → horse_racing · `nfl` → american_football · `dogs` → greyhound_racing · …
| Method | Path | Purpose |
|--------|------|---------|
| `GET` | `/365/{sport}` | Sport hub (counts + sample + child links) |
| `GET` | `/365/{sport}/inplay` | In-play only (`matchStatus` / live flags) |
| `GET` | `/365/{sport}/upcoming` | Upcoming (not in-play, not settled) |
| `GET` | `/365/{sport}/allevents` | All indexed events for sport |
| `GET` | `/365/{sport}/{eventId}` | Single event (raw) |
| `GET` | `/365/{sport}/{eventId}/markets` | Markets for event (socket ids) |
| `GET` | `/365/{sport}/{eventId}/{marketType}` | Filter by market type |
| `GET` | `/365/{sport}/{eventId}/{marketType}/{marketId}` | Exact market |
| `GET` | `/365/{sport}/{eventId},{marketType},{marketId}` | Compact comma form |
| `GET` | `/365/{sport}/{eventId}/odds` | Per-event odds compose (`markets`, scoped `fancy`/`bookmaker`, `source`) |
| `GET` | `/365/{sport}/{eventId}/scorecard` | Live scorecard / runner state (raw) |
| `GET` | `/365/{sport}/{eventId}/livetv` | Live TV / HLS links |
| `GET` | `/365/{sport}/{eventId}/fancy` | Fancy markets for **that** event (multi-id filter) |
| `GET` | `/365/{sport}/{eventId}/bookmaker` | Bookmaker markets for **that** event (multi-id filter) |
| `GET` | `/365/{sport}/{eventId}/premium` | Premium / Genius sportsbook markets for **that** event |
### Identifiers (from live feed)
| Field | Meaning |
|-------|---------|
| `eventId` | Event key |
| `BFI` / `gmid` / `match_id` | Alternate ids accepted by event matchers |
| `marketType` | e.g. `MATCH_ODDS`, `WIN`, `PLACE`, `OTHER_PLACE` |
| `marketId` | Exchange market id when present |
| `marketIndex` / `channel` | Socket routing ids |
| `runners[]` | Selections; back/lay ladders as `BO` / `LO` (untouched) |
| `_index` | Routing helper added by Feed365 (safe to use for links) |
| `source` | On `/odds`: `panel` \| `socket` \| `mixed` \| `index` \| `empty` |
### Per-event odds compose
`GET /365/{sport}/{eventId}/odds` resolves aliases (`eventId`, `BFI`, `gmid`, `match_id`, `marketId`, matchodds ids), fetches panel `/odds-by-market` **even when** the event is already indexed, filters fancy/bookmaker/genius leaks to that event (never full dumps), and falls back to the socket buffer when market odds are empty.
```http
GET /365/search?q=india
POST /365/odds/unified
Content-Type: application/json
{ "matchIds": ["35835250", "35818726"] }
```
Both return the Kore envelope (`ok`, `normalize: false`). Unified puts the bulk payload under `data`.
### Examples
```http
GET /365/catalog
GET /365/cricket/inplay
GET /365/cricket/upcoming
GET /365/tennis/allevents
GET /365/cricket/35830529/odds
GET /365/cricket/35830529/fancy
GET /365/cricket/35830529/bookmaker
GET /365/cricket/35830529/scorecard
GET /365/cricket/35830529/livetv
GET /365/socket/odds
```
Empty `eventCount` / `count: 0` for a sport means no live fixtures in the current snapshot — the route stays aggregator-ready.
### Odds display algorithm (panel → Feed365)
| Surface | Panel fields | Feed365 path |
|---------|--------------|--------------|
| Exchange ladders | `BO` / `LO` runner books | `/365/{sport}/{eventId}/odds``markets` |
| Fancy | `F[]` lines (`nation`, `b1`/`l1`, `sr`/`min`/`max`) | `/365/{sport}/{eventId}/fancy` |
| Bookmaker | `B[]` selections | `/365/{sport}/{eventId}/bookmaker` |
| Premium / Genius | `selection_data` / premium markets | `/365/{sport}/{eventId}/premium` |
Compose details live in `apps/api/src/lib/feed365-odds-compose.ts`. Fancy/BM routes also return an `algorithm` hint for integrators.
---
## 3. Casino (read-only inventory + launch shapes)
| Method | Path | Purpose |
|--------|------|---------|
| `GET` | `/365/casino` | Cached `/live-casinos-list` leak |
| `GET` | `/365/casino/providers` | Canonical providers (Evolution, CreedRoomz, Aura, Spade, Vivo, Supernowa, Pragmatic, Ezugi, …) |
| `GET` | `/365/casino/providers/{provider}` | Single provider metadata + panel routes |
| `GET` | `/365/casino/{provider}/games` | Games / lobby leak for provider |
| `GET` | `/365/casino/{provider}/launch` | Launch shape (`iframe` / `transfer-redirect` / `load-game`) — **no wallet debit** |
Providers are documented in `apps/api/src/lib/feed365-casino-catalog.ts`. Live HTML depends on authenticated leak ingest.
---
## 4. Bets (read-only)
| Method | Path | Purpose |
|--------|------|---------|
| `GET` | `/365/bets` | Opened / matched / unmatched / exposure / one-click **reads** + `placeBetShapes` reference |
**Mutation policy:** place-bet / wallet debit is **not** proxied through `/365`. `placeBetShapes` and `oddsDisplayAlgorithm` on `/365/bets` are documentation only (`mutation: false`).
---
## 5. Live updates
| Method | Path | Purpose |
|--------|------|---------|
| `GET` | `/365/socket` | Kore websocket hints (no upstream credentials) |
| `GET` | `/365/socket/odds` | **Primary** Feed365 buffered snapshot (poll 2–5s) |
| `WS` | `wss://korewhitelabelmall.xyz/ws/odds` | Optional platform live-wire (not full fancy/BM ladders) |
Recommended pattern:
1. Poll `/365/{sport}/inplay` every 2–5s **or**
2. Poll `/365/socket/odds` and merge by `eventId` (Feed365 depth bus), then refresh HTTP odds/scorecard; optional `/ws/odds` is platform live-wire only — **or**
3. Subscribe to Kore WS and refresh HTTP for scorecard / livetv on demand.
---
## 6. Bulk dump
| Method | Path | Purpose |
|--------|------|---------|
| `GET` | `/365/upstream` | Full catalog dump for batch ingest |
---
## 7. Reliability
| Feature | Behavior |
|---------|----------|
| **Autorotate** | Multi-base / multi-account pool |
| **Auto-repair** | Session refresh on miss |
| **Auto-heal** | Ingest clears cooldowns; `POST /365/heal` for ops |
---
## 8. Multi-downstream wiring (10+ platforms · 5L+ users)
**Critical rule:** end-user browsers must **not** call Feed365 directly.
```
[ 5L users ] → Platform A app/WS ─┐
[ 5L users ] → Platform B app/WS ─┼→ Platform backends (10–50 pollers)
[ 5L users ] → Platform C … ─┘ ↓
Feed365 /365/{sport}/inplay
(snapshot cache + CDN ~2s)
```
| Layer | Responsibility | Scale target |
|-------|----------------|--------------|
| End users | Hit **platform** app / WS only | 500k+ on platform infra |
| Platform backend | Poll Feed365, cache, fan-out | 2–5s interval |
| Feed365 | Shared B2B upstream | Tens of backends, not 500k clients |
### Env (platform backend)
```bash
FEED365_BASE=https://korewhitelabelmall.xyz/365
# Send on every poll:
# X-Aggregator-Key: <per-platform-key>
FEED365_INPLAY=https://korewhitelabelmall.xyz/365/{sport}/inplay
FEED365_EVENT=https://korewhitelabelmall.xyz/365/{sport}/{eventId}
FEED365_WS=wss://korewhitelabelmall.xyz/ws/odds
```
### Feed365 scale features
- **Freshness SLA** — when the live bridge is running, ingest age is typically **&lt; 2–3s** (hard stale flag at `FEED365_STALE_MS`, default 8s). Per-event odds older than `FEED365_EVENT_STALE_MS` (default 45s) are **dropped** from `/365/socket/odds`, catalog, and inplay — idle markets are never served as live. Check `freshness.stale` / `freshness.ageSec` / `freshness.events` on `/365/health`. If `status: "stale"`, do **not** treat odds as live.
- **Upstream split** — Mac/VPS HTTP upstream feeds lists + odds/BM/fancy; HLS livetv mint is ops-only (`/365/internal/tv-capture` claim + `races365-live-bridge.mjs --tv-claim`). Partners see `ok:true` + HLS or honest `tvAvailable:false` / queue notes — never silent empty success.
- **Live paths**`/365/*/inplay`, `/365/*/upcoming`, `/365/socket/odds`, `/365/health` use `Cache-Control: no-store` (no CDN serving old ticks).
- **1.5s snapshot cache** — sport indexes reused across requests (in-process only)
- **ETag on `/365/catalog`**`304` when unchanged
- **Rate limit** — per IP; integrator keys get higher priority / bypass soft limits
- **WebSocket** — one connection **per platform server**, then fan-out to users
### Poll budget guide
| Platforms | Sports | Interval | ≈ Feed365 RPS |
|-----------|--------|----------|----------------|
| 10 | 5 | 2s | ~25 |
| 25 | 8 | 2s | ~100 |
| 50 | 10 | 3s | ~167 |
### Ops keys (one per platform)
```bash
AGGREGATOR_API_KEY[REDACTED],plat_b,plat_c,...
AGGREGATOR_RATE_LIMIT_MAX=600
FEED365_SNAPSHOT_TTL_MS=1500
FEED365_CDN_MAX_AGE_SEC=0
FEED365_STALE_MS=8000
FEED365_EVENT_STALE_MS=45000
WS_MAX_CONNECTIONS_PER_IP=32
WS_MAX_CONNECTIONS_GLOBAL=500
```
Never ship aggregator keys to mobile/web clients.
### Minimal backend flow
```
GET /365/health # require status=live / freshness.stale=false
GET /365/catalog
GET /365/{sport}/inplay # every 1–2s while UI focused
GET /365/{sport}/{eventId}/odds # on demand / UI focus
GET /365/{sport}/{eventId}/livetv
```
Privileged ingest (server-side only):
```http
POST /365/ingest
X-Aggregator-Key: <key>
```
---
## 7. Bet trace → settlementId → result (+ partner wallet)
**Partner wallet is active** under `/365/wallet` (INR ledger per aggregator key). With `stake` set, `POST /settlement/trace` debits/locks stake; on `won`/`lost`/`void`/`push` wallet settles automatically. Optional webhook: `POST /365/wallet/webhook`.
| Method | Path | Purpose |
|--------|------|---------|
| `GET` | `/365/wallet` | Balance / locked / ledger |
| `POST` | `/365/wallet/credit` | Top-up |
| `POST` | `/365/wallet/webhook` | Settlement callback URL |
| `POST` | `/365/settlement/trace` | Register bet → `settlementId` (+ debit) |
| `GET` | `/365/settlement/:settlementId` | Poll (auto-refresh evidence) |
| `POST` | `/365/settlement/:settlementId/refresh` | Force re-resolve |
| `POST` | `/365/settlement/:settlementId/result` | Manual close (`won`/`lost`/`void`/`push`/`not_declared`) |
| `GET` | `/365/settlement?open=1` | List partner traces |
Full copy-paste pack (keys + verified payloads): `docs/aggregators/FEED365-COPY-PASTE-INTEGRATION.md`.
**Register body (required):** `betId`, `sport`, `eventId`, and at least one of `selectionId` / `selectionName`.
**Fancy:** also require `line` and/or `runs` and/or `sessionKey`.
**Optional:** `marketType`, `marketKind`, `marketId`, `side`, `odds`, `stake`, `extra`.
Idempotency: same partner key + same open `betId` reuses the existing `settlementId` (`reused: true`).
```http
POST /365/settlement/trace
X-Aggregator-Key: <key>
Content-Type: application/json
{
"betId": "plat-bet-001",
"sport": "cricket",
"eventId": "35839547",
"marketKind": "match_odds",
"selectionName": "Northamptonshire",
"side": "back",
"odds": 1.95,
"stake": 100
}
```
**Create** returns `status: "tracing"` plus the full bet snapshot and `settlementId`.
**Poll** returns `status: "result_not_declared_yet"` until evidence declares, then `won`/`lost`/`void`/`push`.
Evidence (auto): panel `scores-by-market`, socket CLOSED winners, fancy/BM leaks, catalog `matchodds` settle flags, ESPN/SportScore. Manual `/result` is the 100% fallback.
Alias (same store): `/api/settlement-trace` (+ `/docs`).
---
## 8. Response conventions
- Every JSON body includes `"normalize": false`.
- Prefer `ok: true|false` for success; use HTTP 404 for missing events, 503 when feed is degraded.
- Treat `raw` as opaque. Only rely on documented id fields for navigation.
- Live TV may return `ok: false` until a stream is minted for that `eventId`.
---
## 8. What not to do
- Do not scrape or hardcode third-party panel hosts in downstream apps.
- Do not normalize `BO`/`LO` ladders into a proprietary shape unless your product layer owns that mapping.
- Do not expose `/365/session` or ingest keys to end users.