@pandascore/odds-sdk
v0.0.13
Published
SDK to use Pandascore Betting Feed
Readme
PandaSDK
PandaSDK is made to interact with Pandascore Sportsbook. You can use various methods related to matches, markets, events, and more. You will be able to connect to our trading feed easily, get odds change, and use our Matches API.
Features
RabbitMQ feed integration - connect to the PandaScore AMQPS feed and receive structured JSON events.
Automatic reconnection & recovery — built-in heartbeat monitoring and recovery calls to fetch anything missed during disconnections.
Typed DTOs — first-class TypeScript types for feed payloads and HTTP responses.
HTTP clients — a MatchesClient with convenient methods for markets/matches recovery by timestamp/range.
Extensive logging — file + console logging with contextual metadata.
Table of Contents
Installation
You can install the SDK via npm:
npm install @pandascore/odds-sdkOr via yarn:
yarn add @pandascore/odds-sdkConfiguration
Before using the SDK, you need to configure it with your credentials:
import { PandaSDK } from '@pandascore/odds-sdk';
const MySDK = PandaSDK.initialize({
apiToken: '<your-api-token>', // your api token
apiBaseURL: '<your-api-base-url>', // ask your integration manager for the full base URL
feedHost: '<your-feed-host>', // ask your integration manager for the full feed URL
company_id: 0, // your PandaScore company ID
email: '<your-email>', // your registered email
password: '<your-password>', // your connection password
queues: [
{ queueName: 'my-queue', routingKey: '#' }, // add more bindings as needed
],
oddsFormat: ['american', 'fractional'], // optional; decimal odds are sent by default
logging: {
directory: './PandaScore_logs', // optional; file logs are written here
},
realTimeBetLogConfig: { // optional config
vhost: 'vhost-123',
email: '[email protected]',
password: 'secret',
hostname: 'feed.example.com',
},
});Usage
Getting Pandascore feed
To get all our messages, you can use:
MySDK.getRMQFeed((msg: any) => {
console.log('Received message from RabbitMQ:', msg);
});Publishing RTBL Bet
(Optional if you are subscribed to the package) To publish an RTBL bet:
async function main() {
try {
await MySDK.connectToRabbitMQ();
await MySDK.createChannel();
const betData: BetData = {
event_type: 'bet_placed',
bet: {
id: 'id-of-the-bet',
type: 'single',
user_id: 'user-if',
cash_amount: 100,
currency: 'USD',
placed_at: new Date().toISOString(),
selections: [
{
provider: 'PandaScore',
provider_market_id: 'market-id',
provider_selection_position: 1,
decimal_odds: 1.5,
},
],
},
};
MySDK.publishBet(
betData,
(error) => console.error('Error:', error.message),
(data) => console.log('Success:', data),
);
} catch (error) {
console.error('Error in main function:', error);
}
}
main();Getting a match detail
You can use fetchMatch to get detail for a single match.
const matchData = MySDK.fetchMatch('979621');
matchData
.then((data) => {
console.log('Results for a single match: ');
console.log(JSON.stringify(data));
})
.catch((error) => {
console.error(error);
});Getting markets for a match
You can use fetchMarkets to get all markets of a match.
const marketsData = MySDK.fetchMarkets('979621');
marketsData
.then((data) => {
console.log('Results for markets of a match: ');
console.log(data);
})
.catch((error) => {
console.error(error);
});Getting markets changed during a time range
You can use fetchMatchesRange to get all markets updated during a specified time range.
const oneHourAgoISO = new Date(new Date().getTime() - 60 * 60 * 1000).toISOString();
const dateNow = new Date().toISOString();
const marketsRange = MySDK.fetchMatchesRange(oneHourAgoISO, dateNow);
marketsRange
.then((data) => {
console.log('Results for range of markets: ');
console.log(data);
})
.catch((error) => {
console.error(error);
});