Code Samples
Node.js Example
const amqp = require('amqplib');
const config = {
hostname: 'hyper-livescore.lsports.eu',
port: 5671,
username: 'YOUR_USERNAME',
password: 'YOUR_PASSWORD',
protocol: 'amqps'
};
const packageId = 'YOUR_PACKAGE_ID';
const queueName = `_${packageId}_`;
// Store for fixtures
const fixturesStore = new Map();
async function connectFixtures() {
const conn = await amqp.connect({ ...config, vhost: 'Fixtures' });
const channel = await conn.createChannel();
await channel.prefetch(100);
channel.consume(queueName, (msg) => {
if (msg) {
const message = JSON.parse(msg.content.toString());
const fixture = message.body;
// Store fixture by fixtureId
fixturesStore.set(fixture.fixtureId, fixture);
console.log(`Fixture update: ${fixture.fixtureId} - ${fixture.participants?.map(p => p.name).join(' vs ')}`);
channel.ack(msg);
}
});
console.log('Connected to Fixtures feed');
}
async function connectIncidents() {
const conn = await amqp.connect({ ...config, vhost: 'Incidents' });
const channel = await conn.createChannel();
await channel.prefetch(100);
channel.consume(queueName, (msg) => {
if (msg) {
const message = JSON.parse(msg.content.toString());
const incident = message.body;
// Get fixture context
const fixture = fixturesStore.get(incident.fixtureId);
console.log(`Incident: ${incident.name} (${incident.kind}) - Fixture: ${fixture?.participants?.map(p => p.name).join(' vs ') || incident.fixtureId}`);
console.log(` Confidence: ${(incident.confidence * 100).toFixed(0)}%`);
if (incident.values) {
console.log(` Score: ${incident.values.map(v => v.value).join(' - ')}`);
}
channel.ack(msg);
}
});
console.log('Connected to Incidents feed');
}
async function main() {
try {
await connectFixtures();
await connectIncidents();
} catch (error) {
console.error('Connection error:', error);
process.exit(1);
}
}
main();Python Example
C# Example
Best Practices
Related Documentation
Last updated
Was this helpful?