The marketFilter function is used to build an object to filter and select the desired markets. This function is used in a number of methods, including competitions, countries, events, eventTypes, marketCatalogue, and marketTypes.
See examples.
m <- marketFilter(bspOnly = NULL, competitionIds = NULL, eventIds = NULL, eventTypeIds = NULL,
                  exchangeIds = NULL, inPlayOnly = NULL, marketBettingTypes = NULL,
                  marketCountries = NULL, marketIds = NULL, from = NULL, to = NULL,
                  marketTypeCodes = NULL, textQuery = NULL, turnInPlayEnabled = NULL,
                  venues = NULL, withOrders = NULL)| param | type | details | example | 
|---|---|---|---|
| bspOnly | boolean | restrict to BSP (Betfair Starting Price) markets only TRUE, or non-BSP marketsFALSE. If not specified then returns both BSP and non-BSP markets | TRUE | 
| competitionIds | string | restrict markets by the competitions associated with the competition id | "123456" | 
| eventIds | string | restrict markets by the event id | "767956" | 
| eventTypeIds | numeric | restrict markets by event type, ie. Football, Hockey, Horse Racing, etc | "1" | 
| exchangeIds | string | restrict markets by the exchange where the market operates. As of Jun 11, 2015, not available | |
| inPlayOnly | boolean | restrict to markets that are currently in play TRUE, or not currently in playFALSE. If not specified then returns both. | TRUE | 
| marketBettingTypes | string | restrict to markets that match the betting type or the market, ie. Odds, Asian Handicap Singles, Asian Handicap Doubles. See section marketBettingTypes in BettingEnums or the relevant section of Betfair help pages | "ODDS" | 
| marketCountries | string | restrict to markets that are in the specified country or countries | "GB" | 
| marketIds | numeric | restrict to markets by market Id | "1.2345678" | 
| from | string | start time after specified date, format date as “YYYY-MM-DD” or with a time “YYYY-MM-DD 00:00:00” | "2015-09-23" | 
| to | string | start time before specified date, format date as “YYYY-MM-DD” or with a time “YYYY-MM-DD 00:00:00” | "2015-09-24" | 
| marketTypeCodes | numeric | restrict to markets that match the type of the market, ie. MATCH_ODDS, HALF_TIME_SCORE. You should use this instead of relying on the market name as the market type codes are the same in all locales. | "MATCH_ODDS" | 
| textQuery | string | restrict markets by any text associated with the market such as Name, Event, Competition, etc. You can include a wildcard (*) character, as long as it is not the first character | "Capital One Cup" | 
| turnInPlayEnabled | boolean | restrict to markets that will turn in play TRUE, or will not turn in playFALSE. If not specified returns both | TRUE | 
| venues | string | restrict markets by the venue. Currently, as of Jun 11, 2015, only Horse Racing and Greyhound markets have venues. | "Haydock" | 
| withOrders | string | restrict to markets that you have one or more orders in place, see section OrderStatus in BettingEnums or the relevant section of Betfair help pages | "EXECUTABLE" | 
library(betfaiR)
# login
bf <- betfair(usr = Sys.getenv("bf_usr"),
              pwd = Sys.getenv("bf_pwd"),
              key = Sys.getenv("bf_key"))Login successful# build filter object, for all football markets
obj <- marketFilter(eventTypeIds = 1)
# use obj in query
res <- bf$competitions(filter = obj)
head(res)  competition_id       competition_name marketCount competitionRegion
1          12801            Spanish Cup         202               ESP
2         832265 Brazilian Pernambucano          24               BRA
3             11   Dutch Jupiler League         196               NLD
4             15      Bulgarian Premier           1               BGR
5             23       Danish Superliga          15               DNK
6         821269       Tercera Division          24               ESP# or use marketFilter inside a method
res <- bf$competitions(filter = marketFilter(eventTypeIds = 1, marketCountries = "GB"))
head(res)  competition_id                           competition_name marketCount
1        2608550                                   Specials           3
2        6447264      Northern Premier League Challenge Cup          48
3        6435559            Gloucester Senior Challenge Cup          24
4          42886                                  FA Trophy           8
5        4644737 Northern Premier League Division One South          24
6         409743                               Scottish Cup          58
  competitionRegion
1               GBR
2               GBR
3               GBR
4               GBR
5               GBR
6               GBR