Betfair Sports API for Node.js

Installation

npm install betfair-sports-api

Tutorial

There is the Betfair Sports API for Node.js Tutorial
that provides quick and easy start with the library. No Node.js and minimal JavaScript knowledge is required.
Please note that the tutorial is not finished yet, but is still very good for start.

session.open( function(err, invocation) {...} );

Issue the login invocation using login and password specified in newSession and
call the callback on completion. if err is null the login invocation was successful, otherwise err
describes error. You should not worry about the security token, it is remembered in session.header
property and used automatically in all the further invacations. Returns nothing.

session.close( function(err, invocation) {...} );

Issue the logout invocation and call the callback on completion.
if err is null the logout invocation was successful, otherwise err
describes error. Returns nothing.

var inv = session.keepAlive();

Creates a keepAlive invocation object. Use inv.execute( function(err,inv) {...} )
to send the keepAlive to server and get its result.

var inv = session.getAllMarkets(options)

Creates a getAllMarkets invocation object. Use inv.execute( function(err,inv) {...} )
to send the getAllMarkets to server and get its result.
The options are:

locale: String
The locale to use when returning results. If not specified, the default
locale for the user’s account is used.

eventTypeIds: Array
If set, the events types to return. If not specified, markets from all event types are returned.
For example [1, 2] will return only soccer and tennis markets.

fromDate: Date
If this is set, the response contains only markets where the market time is not before
the specified date. A null value indicated no limit.

toDate: Date
If this is set, the response contains only markets where the market time is not after
the specified date. A null value indicated no limit.

var inv = session.getMarket(marketId, options);

Creates a getMarket invocation object for market marketId. Use inv.execute( function(err,inv) {...} )
to send the getMarket to server and get its result.
The options are:

locale: String
The locale to use when returning results. If not specified, the default
locale for the user’s account is used.

includeCouponLinks: bool
If you set this parameter to true, the service response contains a list of any
coupons that include the market you have requested. If you set the parameter
to false, no coupon data is returned.

var inv = session.getMarketPricesCompressed(marketId, options);

Creates a getMarketPricesCompressed invocation object for market marketId.
Use inv.execute( function(err,inv) {...} ) to send the getMarketPricesCompressed to server
and get its result.
The options are:

currencyCode: String
The three letter ISO 4217 code. If not supplied, user’s currency is used

Creates a getCompleteMarketPricesCompressed invocation object for market marketId.
Use inv.execute( function(err,inv) {...} ) to send the getCompleteMarketPricesCompressed to server
and get its result.
The options are:

currencyCode: String
The three letter ISO 4217 code. If not supplied, user’s currency is used