This guide covers the JavaScript / TypeScript API exposed by the generated sport-sdk package.
The most important integration details for Web are:
CommonResult<T> (data, errorMessage, isSuccess)KtList values to JS arrays when neededbigint for most domain identifiers (sportId, seasonId, matchId, ...)Reference implementation:
jsApp/build/js/packages/sport-sdk/kotlin/sport-sdk.d.mtsInstall sport-sdk, call SportSdkJs.init(...) once with clientId, appKey, and appIdentifier, then verify the setup with SportSdkJs.getSports().
Use your team’s npm distribution channel or a locally packed .tgz during repository development.
Call SportSdkJs.init(...) before any data request and wait for the promise to resolve.
Convert KtList<T> values with asJsReadonlyArrayView() at your app boundary.
Most domain identifiers are bigint, not number.
If your team consumes a published package, install sport-sdk from your configured npm registry.
npm install sport-sdkIf the package is hosted in a private GitLab/npm registry, configure your .npmrc according to your organization’s release instructions before running .
CommonResult<T>Every SDK call returns a result wrapper. Always inspect:
result.isSuccessresult.dataresult.errorMessageKtList<T>SDK lists are Kotlin collections, not plain JS arrays. Convert them with asJsReadonlyArrayView().
bigintMost domain IDs are bigint. Keep them that way unless you are certain downcasting is safe.
KtList<T> conversion examplesconst sports = result.data?.asJsReadonlyArrayView() ?? [];
const categories = sport.categories.asJsReadonlyArrayView();
const tournaments = category.tournaments.asJsReadonlyArrayView();
const matches = tournament.matches.asJsReadonlyArrayView();bigint examplesconst sportId = 1n;
const seasonId = 123456789n;
const matchId = 987654321n;If you serialize these IDs, remember that JSON.stringify() does not support bigint directly without conversion.
Top-level function exports also exist, for example:
topLvlGetSportsList()topLvlGetSportMatchesForDate(timestamp)topLvlGetTournamentSeasons(uniqueTournamentId)import { SportSdkJs } from 'sport-sdk';
export async function loadSports(): Promise<void> {
const result = await SportSdkJs.getSports();
if (!result.isSuccess) {
console.error('Error loading sports:', result.
const statisticsResult = await SportSdkJs.getMatchStatistics(matchId);
const lineupsResult = await SportSdkJs.getMatchLineups(matchId);
const timelineResult = await SportSdkJs.getSoccerMatchTimelineEvents(matchId);
const statistics = statisticsResult.data?.asJsReadonlyArrayView() ?? [];
const lineups =
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { ClientConfig, SportSdkJs, Sport } from 'sport-sdk';
@Injectable({
export const environment = {
production: false,
sportSdk: {
clientId: YOUR_CLIENT_ID,
appKey: 'YOUR_APP_KEY',
appIdentifier: 'com.example.webapp',
},
};Whether you use Angular, React, Vue, or vanilla JS, wait for SportSdkJs.init(...) before making controller calls.
KtList at your app boundaryConvert SDK collections to plain arrays once, then pass arrays through your UI state/store.
bigint IDs as bigintDo not downcast IDs to number unless you are certain precision is safe.
getSportMatchesForDate(timestamp) expects milliseconds since epoch.
You are probably working with KtList<T>. Convert it first:
const items = result.data?.asJsReadonlyArrayView() ?? [];Check:
result.errorMessageBigIntMake sure your target runtime and bundler output support ES2020+ BigInt.
Check:
npm list sport-sdk.npmrc / registry auth.tgz path if using a file dependencyimport { ClientConfig, SportSdkJs } from 'sport-sdk';
const initialized = await SportSdkJs.init(
new ClientConfig(
YOUR_CLIENT_ID,
'YOUR_APP_KEY',
'com.example.webapp',
undefined,
false,
),
);
if (!initialized) {
throw new Error('Sport SDK failed to initialize');
}
const sports = (await SportSdkJs.getSports()).data?.asJsReadonlyArrayView() ?? [];
console.log(`Loaded ${sports.length} sports`);BigIntclientId, appKey, appIdentifierType expectations:
clientId = numberbigintnpm installimport { ClientConfig, SportSdkJs } from 'sport-sdk';
const initialized = await SportSdkJs.init(
new ClientConfig(
YOUR_CLIENT_ID,
'YOUR_APP_KEY',
'com.example.webapp',
undefined,
false,
),
);
if (!initialized) {
throw new Error('Sport SDK failed to initialize');
}
const result = await SportSdkJs.getSports();
if (result.isSuccess) {
const sports = result.data?.asJsReadonlyArrayView() ?? [];
console.log(`Loaded ${sports.length} sports`);
} else {
console.error(result.errorMessage);
}| Method | Returns |
|---|---|
SportSdkJs.getSports() | Promise<CommonResult<KtList<Sport>>> |
SportSdkJs.getSportCategories(sportId) | Promise<CommonResult<KtList<Sport>>> |
SportSdkJs.getSportMatchesForDate(timestamp) | Promise<CommonResult<KtList<Sport>>> |
SportSdkJs.getTournamentSeasons(uniqueTournamentId) | Promise<CommonResult<KtList<Season>>> |
SportSdkJs.getSeasonStanding(seasonId, isCurrentSeason?) | Promise<CommonResult<Standings>> |
SportSdkJs.getSeasonFixtures(seasonId, isCurrentSeason?) | Promise<CommonResult<KtList<Match>>> |
SportSdkJs.getMatchStatistics(matchId) | Promise<CommonResult<KtList<MatchStatistics>>> |
SportSdkJs.getMatchLineups(matchId) | Promise<CommonResult<MatchLineups>> |
SportSdkJs.getSoccerMatchTimelineEvents(matchId) | Promise<CommonResult<KtList<SoccerEvent>>> |
SportSdkJs.getTeamSquad(teamId, seasonId) | Promise<CommonResult<TeamSquad>> |
const seasonsResult = await SportSdkJs.getTournamentSeasons(uniqueTournamentId);
const standingsResult = await SportSdkJs.getSeasonStanding(seasonId, true);
const fixturesResult = await SportSdkJs.getSeasonFixtures(seasonId, true);
const seasons = seasonsResult.data?.asJsReadonlyArrayView() ?? [];
const fixtures = fixturesResult.data?.asJsReadonlyArrayView() ?? [];
const standings = standingsResult.data;import { APP_INITIALIZER, NgModule } from '@angular/core';
import { SportSdkService } from './sport-sdk.service';
export function initializeSdk(service: SportSdkService) {
return () => service.initialize();
}
@NgModule({
providers: [
{
provide: APP_INITIALIZER,
useFactory: initializeSdk,
deps: [SportSdkService],
multi: true,
},
],
})
export class AppModule {}const config = new ClientConfig(
environment.sportSdk.clientId,
environment.sportSdk.appKey,
environment.sportSdk.appIdentifier,
undefined,
false,
);Always inspect errorMessage. An empty result without error handling is the most common cause of confusing “nothing rendered” states.