betfaiR

Having logged in using the betfair function, the environment contains the events method. This method can be used to get events and the number of markets for each event, when the event start, as well as other data that may be of interest.

usage

bf$events(filter = marketFilter())

arguments

param details
filter select desired markets, see marketFilter for various parameters to filter by, or the relevant help pages on Betfair. If nothing is entered, all events are returned

return

The function returns a dataframe of events (eg. Manchester United vs Arsenal), with data about the number of markets, start time, etc, a full list below:

variable details
event_id the event id
event_name the event name (eg. Manchester United vs Arsenal)
event_countryCode the ISO-2 code, ISO-2 codes are available on wiki, examples include GB, IE, US, etc
event_timezone the timezone in which the event is happening
event_venue the event venue (if applicable)
event_openDate the scheduled start of the event (format “YYYY-MM-DDT00:00:00.000Z”)
marketCount number of markets associated with this country

examples

library(betfaiR)
# login
bf <- betfair(usr = Sys.getenv("bf_usr"),
              pwd = Sys.getenv("bf_pwd"),
              key = Sys.getenv("bf_key"))
Login successful
# return all countries
tmp <- bf$events()
head(tmp)
  event_id                                 event_name event_timezone
1 28086700                 Hradec Kralove v Prostejov  Europe/London
2 28086701                          Opava v Vitkovice  Europe/London
3 28086702                  Vysocina Jihlava v Vlasim  Europe/London
4 28086703 Vitosha Bistritsa v PFC Hebar (Pazardzhik)  Europe/London
5 28086698                 Boca Juniors v San Lorenzo  Europe/London
6 28086699                   Pardubice v Dukla Prague  Europe/London
            event_openDate marketCount event_countryCode event_venue
1 2017-01-25T09:00:00.000Z          24              <NA>        <NA>
2 2017-01-25T10:00:00.000Z          24              <NA>        <NA>
3 2017-01-25T12:00:00.000Z          24              <NA>        <NA>
4 2017-01-25T12:00:00.000Z          24              <NA>        <NA>
5 2017-01-25T01:10:00.000Z          24                AR        <NA>
6 2017-01-25T10:00:00.000Z          24              <NA>        <NA>
# return all horse racing events
tmp <- bf$events(filter = marketFilter(eventTypeIds = 7))
head(tmp)
  event_id           event_name event_countryCode   event_timezone
1 28073772        Newb 11th Feb                GB    Europe/London
2 28074030        Donc 28th Jan                GB    Europe/London
3 28061486       Chelt 14th Mar                GB    Europe/London
4 28061487       Chelt 15th Mar                GB    Europe/London
5 28086841  Laun (AUS) 25th Jan                AU Australia/Sydney
6 27999667 Del Mar (US) 4th Nov                US       US/Eastern
            event_openDate marketCount event_venue
1 2017-02-11T15:35:00.000Z           1        <NA>
2 2017-01-28T15:40:00.000Z           1        <NA>
3 2017-03-14T13:30:00.000Z          13        <NA>
4 2017-03-15T13:30:00.000Z          11        <NA>
5 2017-01-25T06:55:00.000Z          18  Launceston
6 2017-11-03T04:00:00.000Z           1        <NA>
# return all horse racing events whose start date is beyond next week
tmp <- bf$events(filter = marketFilter(eventTypeIds = 7, from = Sys.Date() + 7))
head(tmp)
  event_id           event_name event_countryCode event_timezone
1 28073772        Newb 11th Feb                GB  Europe/London
2 28061486       Chelt 14th Mar                GB  Europe/London
3 28061487       Chelt 15th Mar                GB  Europe/London
4 27999667 Del Mar (US) 4th Nov                US     US/Eastern
5 28074870        Leop 12th Feb                IE  Europe/London
6 28061488       Chelt 16th Mar                GB  Europe/London
            event_openDate marketCount
1 2017-02-11T15:35:00.000Z           1
2 2017-03-14T13:30:00.000Z          13
3 2017-03-15T13:30:00.000Z          11
4 2017-11-03T04:00:00.000Z           1
5 2017-02-12T15:00:00.000Z           1
6 2017-03-16T13:30:00.000Z          10