cito-lol-api 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cito API
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
- # Temporary Holding Version
1
+ # cito-lol-api
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Typed TypeScript and JavaScript SDK for League of Legends esports (LCK, LPL, LEC, LCS, MSI, Worlds): live matches, schedules, game telemetry, individual map odds, Kalshi/Polymarket odds boards, player props, and standings.
4
+
5
+ Zero runtime dependencies. Ships with native TypeScript declarations (`.d.ts`), dual ESM and CommonJS builds, automatic rate-limit header tracking, and built-in quantitative math helpers.
6
+
7
+ - **API Documentation:** [citoapi.com/docs](https://citoapi.com/docs?utm_source=npm&utm_medium=package&utm_campaign=cito-lol-api)
8
+ - **Get Free API Key:** [citoapi.com/signup](https://citoapi.com/signup?utm_source=npm&utm_medium=package&utm_campaign=cito-lol-api)
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install cito-lol-api
14
+ ```
15
+
16
+ ## Quick Start (TypeScript / ESM)
17
+
18
+ ```ts
19
+ import { LolApiClient, bo5WinProbability } from 'cito-lol-api';
20
+
21
+ const lol = new LolApiClient({ apiKey: process.env.CITO_API_KEY });
22
+
23
+ const kalshiBoard = await lol.getOdds({ bookmaker: 'kalshi', limit: 20 });
24
+ const seriesProb = bo5WinProbability(0.58);
25
+ console.log({ matches: kalshiBoard.data.length, bo5Prob: seriesProb });
26
+ ```
27
+
28
+ ## CommonJS Usage
29
+
30
+ ```js
31
+ const { LolApiClient } = require('cito-lol-api');
32
+ const client = new LolApiClient({ apiKey: process.env.CITO_API_KEY });
33
+ ```
34
+
35
+ ## Authentication
36
+
37
+ Set `CITO_API_KEY` in your environment or pass `{ apiKey }` to the constructor. All requests authenticate via the `X-API-Key` header against `https://api.citoapi.com/api/v1`.
38
+
39
+ ## Local Build & Tests
40
+
41
+ ```bash
42
+ npm install
43
+ npm run build
44
+ npm test
45
+ ```
46
+
47
+ ## License
48
+
49
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LolApiClient = void 0;
4
+ const http_js_1 = require("./http.js");
5
+ class LolApiClient {
6
+ http;
7
+ constructor(options = {}) {
8
+ this.http = new http_js_1.CitoHttpClient(options);
9
+ }
10
+ get lastRateLimit() {
11
+ return this.http.lastRateLimit;
12
+ }
13
+ getLiveMatches() {
14
+ return this.http.get('/lol/live', undefined, { unwrapData: false });
15
+ }
16
+ getUpcomingSchedule(filters = {}) {
17
+ return this.http.get('/lol/schedule/upcoming', {
18
+ hours: filters.hours ?? 72,
19
+ leagueSlug: filters.leagueSlug,
20
+ teamSlug: filters.teamSlug,
21
+ limit: filters.limit ?? 50,
22
+ });
23
+ }
24
+ getSchedule(limit = 50) {
25
+ return this.http.get('/lol/schedule', { limit });
26
+ }
27
+ getMatch(matchId) {
28
+ return this.http.get(`/lol/matches/${(0, http_js_1.encodeSeg)(matchId)}`);
29
+ }
30
+ getMatchGames(matchId) {
31
+ return this.http.get(`/lol/matches/${(0, http_js_1.encodeSeg)(matchId)}/games`);
32
+ }
33
+ getMatchPlayerStats(matchId) {
34
+ return this.http.get(`/lol/matches/${(0, http_js_1.encodeSeg)(matchId)}/player-stats`);
35
+ }
36
+ getOdds(filters = {}) {
37
+ return this.http.get('/lol/odds', {
38
+ bookmaker: filters.bookmaker,
39
+ market: filters.market,
40
+ league: filters.league,
41
+ limit: filters.limit ?? 50,
42
+ }, { unwrapData: false });
43
+ }
44
+ getPlayerProps(limit = 50) {
45
+ return this.http.get('/lol/props', { limit }, { unwrapData: false });
46
+ }
47
+ getMatchOdds(matchId) {
48
+ return this.http.get(`/lol/matches/${(0, http_js_1.encodeSeg)(matchId)}/odds`);
49
+ }
50
+ getMatchMapOdds(matchId) {
51
+ return this.http.get(`/lol/matches/${(0, http_js_1.encodeSeg)(matchId)}/odds/games`);
52
+ }
53
+ getMatchOddsHistory(matchId) {
54
+ return this.http.get(`/lol/matches/${(0, http_js_1.encodeSeg)(matchId)}/odds/history`);
55
+ }
56
+ getLeagues() {
57
+ return this.http.get('/lol/leagues');
58
+ }
59
+ getLeagueStandings(leagueId) {
60
+ return this.http.get(`/lol/leagues/${(0, http_js_1.encodeSeg)(leagueId)}/standings`);
61
+ }
62
+ getTeam(slug) {
63
+ return this.http.get(`/lol/teams/${(0, http_js_1.encodeSeg)(slug)}`);
64
+ }
65
+ getTeamRoster(slug) {
66
+ return this.http.get(`/lol/teams/${(0, http_js_1.encodeSeg)(slug)}/roster`);
67
+ }
68
+ getPlayer(idOrSlug) {
69
+ return this.http.get(`/lol/players/${(0, http_js_1.encodeSeg)(idOrSlug)}`);
70
+ }
71
+ }
72
+ exports.LolApiClient = LolApiClient;
73
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,uCAAkG;AAGlG,MAAa,YAAY;IACN,IAAI,CAAiB;IAEtC,YAAY,UAA6B,EAAE;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,wBAAc,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,mBAAmB,CAAC,UAA8B,EAAE;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE;YAC7C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,WAAW,CAAC,KAAK,GAAG,EAAE;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,QAAQ,CAAC,OAAe;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAA,mBAAS,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,aAAa,CAAC,OAAe;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAA,mBAAS,EAAC,OAAO,CAAC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,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAA,mBAAS,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,IAAA,mBAAS,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED,SAAS,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAA,mBAAS,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF;AApFD,oCAoFC"}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CitoHttpClient = exports.CitoApiError = exports.DEFAULT_BASE_URL = void 0;
4
+ exports.encodeSeg = encodeSeg;
5
+ exports.DEFAULT_BASE_URL = 'https://api.citoapi.com/api/v1';
6
+ class CitoApiError extends Error {
7
+ status;
8
+ code;
9
+ body;
10
+ constructor(message, status = 0, body = null, code) {
11
+ super(message);
12
+ this.name = 'CitoApiError';
13
+ this.status = status;
14
+ this.body = body;
15
+ if (code !== undefined) {
16
+ this.code = code;
17
+ }
18
+ else if (body && typeof body === 'object' && 'error' in body) {
19
+ const errObj = body.error;
20
+ this.code =
21
+ errObj && typeof errObj === 'object' && typeof errObj.code === 'string'
22
+ ? errObj.code
23
+ : null;
24
+ }
25
+ else {
26
+ this.code = null;
27
+ }
28
+ }
29
+ }
30
+ exports.CitoApiError = CitoApiError;
31
+ function parseIntHeader(val) {
32
+ if (!val)
33
+ return null;
34
+ const n = Number(val);
35
+ return Number.isFinite(n) ? Math.trunc(n) : null;
36
+ }
37
+ class CitoHttpClient {
38
+ apiKey;
39
+ baseUrl;
40
+ userAgent;
41
+ timeoutMs;
42
+ fetchImpl;
43
+ lastRateLimit = null;
44
+ constructor(options = {}) {
45
+ const envKey = typeof process !== 'undefined' && process.env ? (process.env.CITO_API_KEY ?? '') : '';
46
+ this.apiKey = (options.apiKey !== undefined ? options.apiKey : envKey).trim();
47
+ this.baseUrl = (options.baseUrl ?? exports.DEFAULT_BASE_URL).replace(/\/+$/, '');
48
+ this.userAgent = options.userAgent ?? 'cito-lol-api/1.0.0 (+https://citoapi.com)';
49
+ this.timeoutMs = options.timeoutMs ?? 15000;
50
+ this.fetchImpl = options.fetchImpl ?? fetch;
51
+ }
52
+ buildUrl(endpoint, query) {
53
+ const clean = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
54
+ const qs = new URLSearchParams();
55
+ if (query) {
56
+ for (const [k, v] of Object.entries(query)) {
57
+ if (v === undefined || v === null || v === '')
58
+ continue;
59
+ qs.append(k, String(v));
60
+ }
61
+ }
62
+ const suffix = qs.toString();
63
+ return `${this.baseUrl}${clean}${suffix ? `?${suffix}` : ''}`;
64
+ }
65
+ async get(endpoint, query, opts) {
66
+ if (!this.apiKey) {
67
+ throw new CitoApiError('Missing CITO_API_KEY. Pass { apiKey } or set process.env.CITO_API_KEY.', 401, null, 'MISSING_API_KEY');
68
+ }
69
+ const url = this.buildUrl(endpoint, query);
70
+ const controller = new AbortController();
71
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
72
+ try {
73
+ const res = await this.fetchImpl(url, {
74
+ method: 'GET',
75
+ headers: {
76
+ 'x-api-key': this.apiKey,
77
+ accept: 'application/json',
78
+ 'user-agent': this.userAgent,
79
+ },
80
+ signal: controller.signal,
81
+ });
82
+ this.lastRateLimit = {
83
+ tier: res.headers.get('x-cito-tier') ?? res.headers.get('x-plan-tier'),
84
+ limit: parseIntHeader(res.headers.get('x-ratelimit-limit') ?? res.headers.get('ratelimit-limit')),
85
+ remaining: parseIntHeader(res.headers.get('x-ratelimit-remaining') ?? res.headers.get('ratelimit-remaining')),
86
+ resetAt: res.headers.get('x-ratelimit-reset') ?? res.headers.get('ratelimit-reset'),
87
+ };
88
+ const rawText = await res.text();
89
+ let parsed = null;
90
+ if (rawText) {
91
+ try {
92
+ parsed = JSON.parse(rawText);
93
+ }
94
+ catch {
95
+ parsed = rawText;
96
+ }
97
+ }
98
+ if (!res.ok) {
99
+ const rec = parsed && typeof parsed === 'object' ? parsed : null;
100
+ const msg = (typeof rec?.message === 'string' ? rec.message : null) ??
101
+ `HTTP ${res.status} calling ${endpoint}`;
102
+ throw new CitoApiError(msg, res.status, parsed);
103
+ }
104
+ if (opts?.unwrapData !== false && parsed && typeof parsed === 'object' && 'data' in parsed) {
105
+ return parsed.data;
106
+ }
107
+ return parsed;
108
+ }
109
+ finally {
110
+ clearTimeout(timer);
111
+ }
112
+ }
113
+ }
114
+ exports.CitoHttpClient = CitoHttpClient;
115
+ function encodeSeg(value) {
116
+ return encodeURIComponent(String(value));
117
+ }
118
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":";;;AA0IA,8BAEC;AA5IY,QAAA,gBAAgB,GAAG,gCAAgC,CAAC;AAoBjE,MAAa,YAAa,SAAQ,KAAK;IAC5B,MAAM,CAAS;IACf,IAAI,CAAgB;IACpB,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,MAAM,GAAG,CAAC,EAAE,OAAgB,IAAI,EAAE,IAAoB;QACjF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;aAAM,IAAI,IAAI,IAAI,OAAO,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AE,CAAC;gBACZ,IAAI,CAAC;oBACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC/B,CAAC;gBAAC,MAAM,CAAC;oBACP,MAAM,GAAG,OAAO,CAAC;gBACnB,CAAC;YACH,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAkC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC9F,MAAM,GAAG,GACP,CAAC,OAAO,GAAG,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;oBACvD,QAAQ,GAAG,CAAC,MAAM,YAAY,QAAQ,EAAE,CAAC;gBAC3C,MAAM,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAClD,CAAC;YAED,IAAI,IAAI,EAAE,UAAU,KAAK,KAAK,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAK,MAAkC,EAAE,CAAC;gBACxH,OAAQ,MAAkC,CAAC,IAAS,CAAC;YACvD,CAAC;YACD,OAAO,MAAW,CAAC;QACrB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF;AAtFD,wCAsFC;AAED,SAAgB,SAAS,CAAC,KAAsB;IAC9C,OAAO,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./http.js"), exports);
18
+ __exportStar(require("./types.js"), exports);
19
+ __exportStar(require("./math.js"), exports);
20
+ __exportStar(require("./client.js"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,8CAA4B"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.americanToDecimal = americanToDecimal;
4
+ exports.decimalToAmerican = decimalToAmerican;
5
+ exports.impliedProbability = impliedProbability;
6
+ exports.overround = overround;
7
+ exports.removeVig = removeVig;
8
+ exports.kellyFraction = kellyFraction;
9
+ exports.expectedValue = expectedValue;
10
+ exports.bo3WinProbability = bo3WinProbability;
11
+ exports.bo5WinProbability = bo5WinProbability;
12
+ function americanToDecimal(american) {
13
+ if (!Number.isFinite(american) || american === 0 || (american > -100 && american < 100)) {
14
+ throw new Error('American odds must be <= -100 or >= +100');
15
+ }
16
+ return american > 0
17
+ ? Number((1 + american / 100).toFixed(6))
18
+ : Number((1 + 100 / Math.abs(american)).toFixed(6));
19
+ }
20
+ function decimalToAmerican(decimalOdds) {
21
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
22
+ throw new Error('Decimal odds must be > 1.0');
23
+ }
24
+ return decimalOdds >= 2
25
+ ? Math.round((decimalOdds - 1) * 100)
26
+ : Math.round(-100 / (decimalOdds - 1));
27
+ }
28
+ function impliedProbability(decimalOdds) {
29
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
30
+ throw new Error('Decimal odds must be > 1.0');
31
+ }
32
+ return Number((1 / decimalOdds).toFixed(6));
33
+ }
34
+ function overround(decimalPrices) {
35
+ if (!decimalPrices.length)
36
+ throw new Error('decimalPrices must not be empty');
37
+ const sum = decimalPrices.reduce((acc, p) => acc + impliedProbability(p), 0);
38
+ return Number((sum - 1).toFixed(6));
39
+ }
40
+ function removeVig(decimalPrices) {
41
+ if (!decimalPrices.length)
42
+ throw new Error('decimalPrices must not be empty');
43
+ const inv = decimalPrices.map((p) => {
44
+ if (!Number.isFinite(p) || p <= 1)
45
+ throw new Error('Every decimal price must be > 1.0');
46
+ return 1 / p;
47
+ });
48
+ const total = inv.reduce((a, b) => a + b, 0);
49
+ return inv.map((v) => Number((v / total).toFixed(6)));
50
+ }
51
+ function kellyFraction(winProb, decimalOdds, fraction = 1) {
52
+ if (!Number.isFinite(winProb) || winProb < 0 || winProb > 1) {
53
+ throw new Error('winProb must be between 0 and 1');
54
+ }
55
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
56
+ throw new Error('decimalOdds must be > 1.0');
57
+ }
58
+ if (!Number.isFinite(fraction) || fraction <= 0) {
59
+ throw new Error('fraction must be > 0');
60
+ }
61
+ const b = decimalOdds - 1;
62
+ const edge = (b * winProb - (1 - winProb)) / b;
63
+ return edge <= 0 ? 0 : Number((edge * fraction).toFixed(6));
64
+ }
65
+ function expectedValue(winProb, decimalOdds, stake = 1) {
66
+ if (!Number.isFinite(winProb) || winProb < 0 || winProb > 1) {
67
+ throw new Error('winProb must be between 0 and 1');
68
+ }
69
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
70
+ throw new Error('decimalOdds must be > 1.0');
71
+ }
72
+ return Number(((winProb * (decimalOdds - 1) - (1 - winProb)) * stake).toFixed(6));
73
+ }
74
+ function bo3WinProbability(p) {
75
+ if (!Number.isFinite(p) || p < 0 || p > 1)
76
+ throw new Error('p must be between 0 and 1');
77
+ return Number((p * p * (3 - 2 * p)).toFixed(6));
78
+ }
79
+ function bo5WinProbability(p) {
80
+ if (!Number.isFinite(p) || p < 0 || p > 1)
81
+ throw new Error('p must be between 0 and 1');
82
+ const q = 1 - p;
83
+ return Number((p ** 3 * (1 + 3 * q + 6 * q * q)).toFixed(6));
84
+ }
85
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/math.ts"],"names":[],"mappings":";;AAAA,8CAOC;AAED,8CAOC;AAED,gDAKC;AAED,8BAIC;AAED,8BAQC;AAED,sCAaC;AAED,sCAQC;AAED,8CAGC;AAED,8CAIC;AA3ED,SAAgB,iBAAiB,CAAC,QAAgB;IAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,IAAI,QAAQ,GAAG,GAAG,CAAC,EAAE,CAAC;QACxF,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,QAAQ,GAAG,CAAC;QACjB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,4BA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M,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,69 @@
1
+ import { CitoHttpClient, encodeSeg } from './http.js';
2
+ export class LolApiClient {
3
+ http;
4
+ constructor(options = {}) {
5
+ this.http = new CitoHttpClient(options);
6
+ }
7
+ get lastRateLimit() {
8
+ return this.http.lastRateLimit;
9
+ }
10
+ getLiveMatches() {
11
+ return this.http.get('/lol/live', undefined, { unwrapData: false });
12
+ }
13
+ getUpcomingSchedule(filters = {}) {
14
+ return this.http.get('/lol/schedule/upcoming', {
15
+ hours: filters.hours ?? 72,
16
+ leagueSlug: filters.leagueSlug,
17
+ teamSlug: filters.teamSlug,
18
+ limit: filters.limit ?? 50,
19
+ });
20
+ }
21
+ getSchedule(limit = 50) {
22
+ return this.http.get('/lol/schedule', { limit });
23
+ }
24
+ getMatch(matchId) {
25
+ return this.http.get(`/lol/matches/${encodeSeg(matchId)}`);
26
+ }
27
+ getMatchGames(matchId) {
28
+ return this.http.get(`/lol/matches/${encodeSeg(matchId)}/games`);
29
+ }
30
+ getMatchPlayerStats(matchId) {
31
+ return this.http.get(`/lol/matches/${encodeSeg(matchId)}/player-stats`);
32
+ }
33
+ getOdds(filters = {}) {
34
+ return this.http.get('/lol/odds', {
35
+ bookmaker: filters.bookmaker,
36
+ market: filters.market,
37
+ league: filters.league,
38
+ limit: filters.limit ?? 50,
39
+ }, { unwrapData: false });
40
+ }
41
+ getPlayerProps(limit = 50) {
42
+ return this.http.get('/lol/props', { limit }, { unwrapData: false });
43
+ }
44
+ getMatchOdds(matchId) {
45
+ return this.http.get(`/lol/matches/${encodeSeg(matchId)}/odds`);
46
+ }
47
+ getMatchMapOdds(matchId) {
48
+ return this.http.get(`/lol/matches/${encodeSeg(matchId)}/odds/games`);
49
+ }
50
+ getMatchOddsHistory(matchId) {
51
+ return this.http.get(`/lol/matches/${encodeSeg(matchId)}/odds/history`);
52
+ }
53
+ getLeagues() {
54
+ return this.http.get('/lol/leagues');
55
+ }
56
+ getLeagueStandings(leagueId) {
57
+ return this.http.get(`/lol/leagues/${encodeSeg(leagueId)}/standings`);
58
+ }
59
+ getTeam(slug) {
60
+ return this.http.get(`/lol/teams/${encodeSeg(slug)}`);
61
+ }
62
+ getTeamRoster(slug) {
63
+ return this.http.get(`/lol/teams/${encodeSeg(slug)}/roster`);
64
+ }
65
+ getPlayer(idOrSlug) {
66
+ return this.http.get(`/lol/players/${encodeSeg(idOrSlug)}`);
67
+ }
68
+ }
69
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAA8C,MAAM,WAAW,CAAC;AAGlG,MAAM,OAAO,YAAY;IACN,IAAI,CAAiB;IAEtC,YAAY,UAA6B,EAAE;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,mBAAmB,CAAC,UAA8B,EAAE;QAClD,OAAO,IAAI,C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AAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,YAAY,CAAC,OAAe;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,eAAe,CAAC,OAAe;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxE,CAAC;IAED,mBAAmB,CAAC,OAAe;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1E,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC;IAED,kBAAkB,CAAC,QAAgB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED,SAAS,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -0,0 +1,112 @@
1
+ export const DEFAULT_BASE_URL = 'https://api.citoapi.com/api/v1';
2
+ export class CitoApiError extends Error {
3
+ status;
4
+ code;
5
+ body;
6
+ constructor(message, status = 0, body = null, code) {
7
+ super(message);
8
+ this.name = 'CitoApiError';
9
+ this.status = status;
10
+ this.body = body;
11
+ if (code !== undefined) {
12
+ this.code = code;
13
+ }
14
+ else if (body && typeof body === 'object' && 'error' in body) {
15
+ const errObj = body.error;
16
+ this.code =
17
+ errObj && typeof errObj === 'object' && typeof errObj.code === 'string'
18
+ ? errObj.code
19
+ : null;
20
+ }
21
+ else {
22
+ this.code = null;
23
+ }
24
+ }
25
+ }
26
+ function parseIntHeader(val) {
27
+ if (!val)
28
+ return null;
29
+ const n = Number(val);
30
+ return Number.isFinite(n) ? Math.trunc(n) : null;
31
+ }
32
+ export class CitoHttpClient {
33
+ apiKey;
34
+ baseUrl;
35
+ userAgent;
36
+ timeoutMs;
37
+ fetchImpl;
38
+ lastRateLimit = null;
39
+ constructor(options = {}) {
40
+ const envKey = typeof process !== 'undefined' && process.env ? (process.env.CITO_API_KEY ?? '') : '';
41
+ this.apiKey = (options.apiKey !== undefined ? options.apiKey : envKey).trim();
42
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
43
+ this.userAgent = options.userAgent ?? 'cito-lol-api/1.0.0 (+https://citoapi.com)';
44
+ this.timeoutMs = options.timeoutMs ?? 15000;
45
+ this.fetchImpl = options.fetchImpl ?? fetch;
46
+ }
47
+ buildUrl(endpoint, query) {
48
+ const clean = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
49
+ const qs = new URLSearchParams();
50
+ if (query) {
51
+ for (const [k, v] of Object.entries(query)) {
52
+ if (v === undefined || v === null || v === '')
53
+ continue;
54
+ qs.append(k, String(v));
55
+ }
56
+ }
57
+ const suffix = qs.toString();
58
+ return `${this.baseUrl}${clean}${suffix ? `?${suffix}` : ''}`;
59
+ }
60
+ async get(endpoint, query, opts) {
61
+ if (!this.apiKey) {
62
+ throw new CitoApiError('Missing CITO_API_KEY. Pass { apiKey } or set process.env.CITO_API_KEY.', 401, null, 'MISSING_API_KEY');
63
+ }
64
+ const url = this.buildUrl(endpoint, query);
65
+ const controller = new AbortController();
66
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
67
+ try {
68
+ const res = await this.fetchImpl(url, {
69
+ method: 'GET',
70
+ headers: {
71
+ 'x-api-key': this.apiKey,
72
+ accept: 'application/json',
73
+ 'user-agent': this.userAgent,
74
+ },
75
+ signal: controller.signal,
76
+ });
77
+ this.lastRateLimit = {
78
+ tier: res.headers.get('x-cito-tier') ?? res.headers.get('x-plan-tier'),
79
+ limit: parseIntHeader(res.headers.get('x-ratelimit-limit') ?? res.headers.get('ratelimit-limit')),
80
+ remaining: parseIntHeader(res.headers.get('x-ratelimit-remaining') ?? res.headers.get('ratelimit-remaining')),
81
+ resetAt: res.headers.get('x-ratelimit-reset') ?? res.headers.get('ratelimit-reset'),
82
+ };
83
+ const rawText = await res.text();
84
+ let parsed = null;
85
+ if (rawText) {
86
+ try {
87
+ parsed = JSON.parse(rawText);
88
+ }
89
+ catch {
90
+ parsed = rawText;
91
+ }
92
+ }
93
+ if (!res.ok) {
94
+ const rec = parsed && typeof parsed === 'object' ? parsed : null;
95
+ const msg = (typeof rec?.message === 'string' ? rec.message : null) ??
96
+ `HTTP ${res.status} calling ${endpoint}`;
97
+ throw new CitoApiError(msg, res.status, parsed);
98
+ }
99
+ if (opts?.unwrapData !== false && parsed && typeof parsed === 'object' && 'data' in parsed) {
100
+ return parsed.data;
101
+ }
102
+ return parsed;
103
+ }
104
+ finally {
105
+ clearTimeout(timer);
106
+ }
107
+ }
108
+ }
109
+ export function encodeSeg(value) {
110
+ return encodeURIComponent(String(value));
111
+ }
112
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,gCAAgC,CAAC;AAoBjE,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,MAAM,CAAS;IACf,IAAI,CAAgB;IACpB,IAAI,CAAU;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CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,SAAS,CAAC,KAAsB;IAC9C,OAAO,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './http.js';
2
+ export * from './types.js';
3
+ export * from './math.js';
4
+ export * from './client.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,74 @@
1
+ export function americanToDecimal(american) {
2
+ if (!Number.isFinite(american) || american === 0 || (american > -100 && american < 100)) {
3
+ throw new Error('American odds must be <= -100 or >= +100');
4
+ }
5
+ return american > 0
6
+ ? Number((1 + american / 100).toFixed(6))
7
+ : Number((1 + 100 / Math.abs(american)).toFixed(6));
8
+ }
9
+ export function decimalToAmerican(decimalOdds) {
10
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
11
+ throw new Error('Decimal odds must be > 1.0');
12
+ }
13
+ return decimalOdds >= 2
14
+ ? Math.round((decimalOdds - 1) * 100)
15
+ : Math.round(-100 / (decimalOdds - 1));
16
+ }
17
+ export function impliedProbability(decimalOdds) {
18
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
19
+ throw new Error('Decimal odds must be > 1.0');
20
+ }
21
+ return Number((1 / decimalOdds).toFixed(6));
22
+ }
23
+ export function overround(decimalPrices) {
24
+ if (!decimalPrices.length)
25
+ throw new Error('decimalPrices must not be empty');
26
+ const sum = decimalPrices.reduce((acc, p) => acc + impliedProbability(p), 0);
27
+ return Number((sum - 1).toFixed(6));
28
+ }
29
+ export function removeVig(decimalPrices) {
30
+ if (!decimalPrices.length)
31
+ throw new Error('decimalPrices must not be empty');
32
+ const inv = decimalPrices.map((p) => {
33
+ if (!Number.isFinite(p) || p <= 1)
34
+ throw new Error('Every decimal price must be > 1.0');
35
+ return 1 / p;
36
+ });
37
+ const total = inv.reduce((a, b) => a + b, 0);
38
+ return inv.map((v) => Number((v / total).toFixed(6)));
39
+ }
40
+ export function kellyFraction(winProb, decimalOdds, fraction = 1) {
41
+ if (!Number.isFinite(winProb) || winProb < 0 || winProb > 1) {
42
+ throw new Error('winProb must be between 0 and 1');
43
+ }
44
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
45
+ throw new Error('decimalOdds must be > 1.0');
46
+ }
47
+ if (!Number.isFinite(fraction) || fraction <= 0) {
48
+ throw new Error('fraction must be > 0');
49
+ }
50
+ const b = decimalOdds - 1;
51
+ const edge = (b * winProb - (1 - winProb)) / b;
52
+ return edge <= 0 ? 0 : Number((edge * fraction).toFixed(6));
53
+ }
54
+ export function expectedValue(winProb, decimalOdds, stake = 1) {
55
+ if (!Number.isFinite(winProb) || winProb < 0 || winProb > 1) {
56
+ throw new Error('winProb must be between 0 and 1');
57
+ }
58
+ if (!Number.isFinite(decimalOdds) || decimalOdds <= 1) {
59
+ throw new Error('decimalOdds must be > 1.0');
60
+ }
61
+ return Number(((winProb * (decimalOdds - 1) - (1 - winProb)) * stake).toFixed(6));
62
+ }
63
+ export function bo3WinProbability(p) {
64
+ if (!Number.isFinite(p) || p < 0 || p > 1)
65
+ throw new Error('p must be between 0 and 1');
66
+ return Number((p * p * (3 - 2 * p)).toFixed(6));
67
+ }
68
+ export function bo5WinProbability(p) {
69
+ if (!Number.isFinite(p) || p < 0 || p > 1)
70
+ throw new Error('p must be between 0 and 1');
71
+ const q = 1 - p;
72
+ return Number((p ** 3 * (1 + 3 * q + 6 * q * q)).toFixed(6));
73
+ }
74
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/math.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAA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W,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,CAAS;IACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,CAAS;IACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACxF,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import { type BaseClientOptions, type RateLimitInfo } from './http.js';
2
+ import type { LolMatch, LolOddsBoardResponse, LolOddsFilters, LolUpcomingFilters } from './types.js';
3
+ export declare class LolApiClient {
4
+ private readonly http;
5
+ constructor(options?: BaseClientOptions);
6
+ get lastRateLimit(): RateLimitInfo | null;
7
+ getLiveMatches(): Promise<Record<string, unknown>>;
8
+ getUpcomingSchedule(filters?: LolUpcomingFilters): Promise<LolMatch[]>;
9
+ getSchedule(limit?: number): Promise<LolMatch[]>;
10
+ getMatch(matchId: string): Promise<LolMatch>;
11
+ getMatchGames(matchId: string): Promise<Record<string, unknown>[]>;
12
+ getMatchPlayerStats(matchId: string): Promise<Record<string, unknown>[]>;
13
+ getOdds(filters?: LolOddsFilters): Promise<LolOddsBoardResponse>;
14
+ getPlayerProps(limit?: number): Promise<Record<string, unknown>>;
15
+ getMatchOdds(matchId: string): Promise<Record<string, unknown>>;
16
+ getMatchMapOdds(matchId: string): Promise<Record<string, unknown>>;
17
+ getMatchOddsHistory(matchId: string): Promise<Record<string, unknown>[]>;
18
+ getLeagues(): Promise<Record<string, unknown>[]>;
19
+ getLeagueStandings(leagueId: string): Promise<Record<string, unknown>>;
20
+ getTeam(slug: string): Promise<Record<string, unknown>>;
21
+ getTeamRoster(slug: string): Promise<Record<string, unknown>>;
22
+ getPlayer(idOrSlug: string): Promise<Record<string, unknown>>;
23
+ }
@@ -0,0 +1,36 @@
1
+ export declare const DEFAULT_BASE_URL = "https://api.citoapi.com/api/v1";
2
+ export type QueryValue = string | number | boolean | null | undefined;
3
+ export type QueryParams = Record<string, QueryValue>;
4
+ export interface RateLimitInfo {
5
+ tier: string | null;
6
+ limit: number | null;
7
+ remaining: number | null;
8
+ resetAt: string | null;
9
+ }
10
+ export interface BaseClientOptions {
11
+ apiKey?: string;
12
+ baseUrl?: string;
13
+ fetchImpl?: typeof fetch;
14
+ userAgent?: string;
15
+ timeoutMs?: number;
16
+ }
17
+ export declare class CitoApiError extends Error {
18
+ readonly status: number;
19
+ readonly code: string | null;
20
+ readonly body: unknown;
21
+ constructor(message: string, status?: number, body?: unknown, code?: string | null);
22
+ }
23
+ export declare class CitoHttpClient {
24
+ readonly apiKey: string;
25
+ readonly baseUrl: string;
26
+ readonly userAgent: string;
27
+ readonly timeoutMs: number;
28
+ private readonly fetchImpl;
29
+ lastRateLimit: RateLimitInfo | null;
30
+ constructor(options?: BaseClientOptions);
31
+ buildUrl(endpoint: string, query?: QueryParams): string;
32
+ get<T>(endpoint: string, query?: QueryParams, opts?: {
33
+ unwrapData?: boolean;
34
+ }): Promise<T>;
35
+ }
36
+ export declare function encodeSeg(value: string | number): string;
@@ -0,0 +1,4 @@
1
+ export * from './http.js';
2
+ export * from './types.js';
3
+ export * from './math.js';
4
+ export * from './client.js';
@@ -0,0 +1,9 @@
1
+ export declare function americanToDecimal(american: number): number;
2
+ export declare function decimalToAmerican(decimalOdds: number): number;
3
+ export declare function impliedProbability(decimalOdds: number): number;
4
+ export declare function overround(decimalPrices: readonly number[]): number;
5
+ export declare function removeVig(decimalPrices: readonly number[]): number[];
6
+ export declare function kellyFraction(winProb: number, decimalOdds: number, fraction?: number): number;
7
+ export declare function expectedValue(winProb: number, decimalOdds: number, stake?: number): number;
8
+ export declare function bo3WinProbability(p: number): number;
9
+ export declare function bo5WinProbability(p: number): number;
@@ -0,0 +1,37 @@
1
+ export interface LolTeamRef {
2
+ slug: string;
3
+ name: string;
4
+ code?: string | null;
5
+ }
6
+ export interface LolMatch {
7
+ matchId: string;
8
+ state?: string;
9
+ strategy?: string;
10
+ startTime?: string | null;
11
+ league?: {
12
+ slug?: string;
13
+ name?: string;
14
+ };
15
+ team1?: LolTeamRef;
16
+ team2?: LolTeamRef;
17
+ [key: string]: unknown;
18
+ }
19
+ export interface LolUpcomingFilters {
20
+ hours?: number;
21
+ leagueSlug?: string;
22
+ teamSlug?: string;
23
+ limit?: number;
24
+ }
25
+ export interface LolOddsFilters {
26
+ bookmaker?: string;
27
+ market?: string;
28
+ league?: string;
29
+ limit?: number;
30
+ }
31
+ export interface LolOddsBoardResponse {
32
+ success?: boolean;
33
+ entityType?: string;
34
+ count?: number;
35
+ providers?: string[];
36
+ data: LolMatch[];
37
+ }
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "cito-lol-api",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Typed TypeScript and JavaScript SDK for League of Legends esports (LCK, LPL, LEC, LCS, MSI, Worlds): live matches, schedules, game telemetry, individual map odds, Kalshi/Polymarket odds boards, player props, and standings.",
5
+ "type": "module",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/esm/index.js",
13
+ "require": "./dist/cjs/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18.0.0"
23
+ },
24
+ "scripts": {
25
+ "build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && node scripts/postbuild.mjs",
26
+ "test": "node --test test/sdk.test.mjs && node test/cjs-smoke.cjs",
27
+ "prepublishOnly": "npm run build && npm test"
28
+ },
29
+ "keywords": [
30
+ "lol-api",
31
+ "league-of-legends",
32
+ "lck",
33
+ "lpl",
34
+ "lec",
35
+ "lol-odds",
36
+ "map-odds",
37
+ "esports-api",
38
+ "citoapi",
39
+ "typescript"
40
+ ],
41
+ "homepage": "https://citoapi.com/docs?utm_source=npm&utm_medium=package&utm_campaign=cito-lol-api",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/Cito-GG/cito-lol-api.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/Cito-GG/cito-lol-api/issues"
48
+ },
49
+ "author": "Cito API <support@citoapi.com>",
50
+ "license": "MIT",
51
+ "devDependencies": {
52
+ "@types/node": "^22.10.0",
53
+ "typescript": "^5.9.2"
54
+ }
55
+ }