Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including betfair with all npm packages installed. Try it out:

var betfair = require("betfair")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

betfair v0.7.8

Betfair JSON API

Betfair API-NG for Node.js



npm install betfair


git clone
cd betfair
npm install
npm run build

betrair API was completly rewritten in ES2015 and requires build step before usage


Login to Betfair

var betfair = require('betfair');
var session = new betfair.BetfairSession('yourApllicationKey');

session.login('name','password', function(err) {
    console.log(err ? "Login failed " + err : "Login OK");

Request countries list

var invocation = session.listCountries({filter: {}}, function(err,res) {
    if(err) {
        console.log('listCountries failed');
    } else {
        for(var index in res.response.result) {
            var item = res.response.result[index];
            console.log("country:%s markets:%s", item.counrtyCode, item.marketCount)

Logout from Betfair

session.logout(function(err) {
    console.log(err ? "Logout failed: " + err : "Logout OK");


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free