import { Client, APIError } from "@oddswire/client";
const client = new Client({baseUrl: process.env.ODDSWIRE_BASE_URL ?? "http://127.0.0.1:9113", apiKey: process.env.ODDSWIRE_API_KEY});
try {
await client.getEntitlements(); // Free; does not grant access.
const namespace = process.env.ODDSWIRE_NAMESPACE;
if (!namespace) throw new Error("Choose an entitled ODDSWIRE_NAMESPACE.");
const fixtures = await client.listFixtures({namespace, limit: 1});
console.log("Fixture coverage:", fixtures.data!.missing);
const fixture = fixtures.data!.data[0];
if (fixture) {
const odds = await client.listOdds({namespace, fixture: String(fixture.fixture.id), limit: 3});
console.log("Price coverage:", odds.data!.missing);
for (const quote of odds.data!.data) {
// Inspect state, eligibility, confirmation age, units and settlement.
console.log(quote.quote_key, quote.delivery.price.observation.value);
}
} else console.log("No fixtures in the current scope.");
} catch (error) {
if (error instanceof APIError) console.error(error.status, error.code, error.requestId);
else console.error("Local configuration or transport failure.");
process.exitCode = 1;
}