betfair-promise
v1.0.2
Published
Betfair JSON API promisefied
Downloads
3
Readme
Betfair API-NG for Node.js promisified.
Based in AlgoTrader betfair project.
Installation
npm install betfair-promise --save
Synopsis
Login to Betfair
const betfair = require('betfair-promise');
const session = new betfair.BetfairSession("yourAppKey");
const testLoging = async () => {
try {
await session.login("yourUsername", "yourPassword");
await session.keepAlive();
await session.logout();
} catch(error) {
console.log("Something was wrong");
console.log(error);
}
};
testLoging();
If you need to set different Betfair endpoints (Spain, Italy ... check here: countries endpoints), init Betfair session with this options:
const betfair = require('betfair-promise');
// Spain URL's
const AUTH_URLS_ES = {
interactiveLogin: 'https://identitysso.betfair.es:443/api/login',
botLogin: 'https://identitysso-api.betfair.es:443/api/certlogin',
logout: 'https://identitysso.betfair.es:443/api/logout',
keepAlive: 'https://identitysso.betfair.es:443/api/keepAlive'
};
const session = new betfair.BetfairSession("yourAppKey", {authUrls: AUTH_URLS_ES});
Request countries list
const betfair = require('betfair-promise');
const session = new betfair.BetfairSession("yourAppKey");
const testListOfCountries = async () => {
await session.login("yourUsername", "yourPassword");
const listOfCountries = await betfair.getListOfCountries();
for(let country of listOfCountries) {
console.log("country:%s markets:%s", country.counrtyCode, country.marketCount);
}
};
testListOfCountries();