The goal of fitzRoy has been to provide a consistent and easy to use interface for accessing data from various sources. As of version 0.3.3.9000 of fitzRoy, the package now contains a much more consistent API to do so. This is with the introduction of the main fetch_* functions.

Each function uses the same arguments and each argument should behave the same across all of the functions. While there may be some slight differences in behaviour between different sources of data, the goal will be to move towards a much more consistent pattern of behaviour.

Main functions

There are broadly 5 main functions

  • fetch_fixture - returns the fixture for a given round and season
  • fetch_lineup - returns the lineup any matches in a given round and season
  • fetch_results - returns the match results for a given round and season
  • fetch_ladder - returns the ladder for a given round and season
  • fetch_player_stats - returns the detailed player stats for a set of matches within a given round or season

Arguments

Each function accepts 4 arguments. These are consistent between functions and provide sane and common defaults. The common arguments are:

  • season - the season or seasons to return data from. If NULL (the default), will return the season that matches Sys.Date()
  • round_number- the round to return data from. If NULL (the default), will return data from all rounds
  • source - the source with which to return data from. Must be one of “AFL” (default), “footywire”, “fryzigg”, “afltables”, “squiggle”
  • comp - the competition to return data from. Must be one of “AFLM” (default) or “AFLW”. Not all data sources will have AFLW data.

Examples

Basic Usage

All of the functions behave the same. The following are some examples using the fetch_fixture function but can equally be applied to any of the family of fetch_ functions.

#> # A tibble: 198 x 46
#>       id providerId   utcStartTime       status  compSeason.id compSeason.provi…
#>    <int> <chr>        <chr>              <chr>           <int> <chr>            
#>  1  2991 CD_M2021014… 2021-03-18T08:25:… SCHEDU…            34 CD_S2021014      
#>  2  2986 CD_M2021014… 2021-03-19T08:50:… SCHEDU…            34 CD_S2021014      
#>  3  2992 CD_M2021014… 2021-03-20T02:45:… SCHEDU…            34 CD_S2021014      
#>  4  2993 CD_M2021014… 2021-03-20T05:35:… SCHEDU…            34 CD_S2021014      
#>  5  2994 CD_M2021014… 2021-03-20T08:25:… SCHEDU…            34 CD_S2021014      
#>  6  2987 CD_M2021014… 2021-03-20T08:45:… SCHEDU…            34 CD_S2021014      
#>  7  2990 CD_M2021014… 2021-03-21T02:10:… SCHEDU…            34 CD_S2021014      
#>  8  2989 CD_M2021014… 2021-03-21T04:20:… SCHEDU…            34 CD_S2021014      
#>  9  2988 CD_M2021014… 2021-03-21T07:10:… SCHEDU…            34 CD_S2021014      
#> 10  2999 CD_M2021014… 2021-03-25T08:20:… SCHEDU…            34 CD_S2021014      
#> # … with 188 more rows, and 40 more variables: compSeason.name <chr>,
#> #   compSeason.shortName <chr>, compSeason.currentRoundNumber <int>,
#> #   round.id <int>, round.providerId <chr>, round.abbreviation <chr>,
#> #   round.name <chr>, round.roundNumber <int>, round.byes <list>,
#> #   home.team.id <int>, home.team.providerId <chr>, home.team.name <chr>,
#> #   home.team.abbreviation <chr>, home.team.nickname <chr>,
#> #   home.team.teamType <chr>, home.team.club.id <int>,
#> #   home.team.club.providerId <chr>, home.team.club.name <chr>,
#> #   home.team.club.abbreviation <chr>, home.team.club.nickname <chr>,
#> #   away.team.id <int>, away.team.providerId <chr>, away.team.name <chr>,
#> #   away.team.abbreviation <chr>, away.team.nickname <chr>,
#> #   away.team.teamType <chr>, away.team.club.id <int>,
#> #   away.team.club.providerId <chr>, away.team.club.name <chr>,
#> #   away.team.club.abbreviation <chr>, away.team.club.nickname <chr>,
#> #   venue.id <int>, venue.providerId <chr>, venue.name <chr>,
#> #   venue.abbreviation <chr>, venue.location <chr>, venue.state <chr>,
#> #   venue.timezone <chr>, metadata.travel_link <chr>, compSeason.year <dbl>

This is the same as

fetch_fixture(season = 2021, comp = "AFLM", source = "AFL") 

We can return just one round instead of the whole fixture.

fetch_fixture(season = 2021, round_number = 2) %>%
  select(compSeason.name, round.name, home.team.name, away.team.name, venue.name)
#> # A tibble: 9 x 5
#>   compSeason.name       round.name home.team.name  away.team.name   venue.name  
#>   <chr>                 <chr>      <chr>           <chr>            <chr>       
#> 1 2021 Toyota AFL Prem… Round 2    Carlton         Collingwood      MCG         
#> 2 2021 Toyota AFL Prem… Round 2    Geelong Cats    Brisbane Lions   GMHBA Stadi…
#> 3 2021 Toyota AFL Prem… Round 2    Sydney Swans    Adelaide Crows   SCG         
#> 4 2021 Toyota AFL Prem… Round 2    Port Adelaide   Essendon         Adelaide Ov…
#> 5 2021 Toyota AFL Prem… Round 2    St Kilda        Melbourne        Marvel Stad…
#> 6 2021 Toyota AFL Prem… Round 2    Gold Coast Suns North Melbourne  Metricon St…
#> 7 2021 Toyota AFL Prem… Round 2    Hawthorn        Richmond         MCG         
#> 8 2021 Toyota AFL Prem… Round 2    Western Bulldo… West Coast Eagl… Marvel Stad…
#> 9 2021 Toyota AFL Prem… Round 2    Fremantle       GWS Giants       Optus Stadi…

We could also return the AFLW fixture instead.

fetch_fixture(season = 2021, comp = "AFLW") %>%
  select(compSeason.name, round.name, 
         home.team.name, away.team.name, 
         venue.name)
#> # A tibble: 63 x 5
#>    compSeason.name    round.name home.team.name  away.team.name  venue.name     
#>    <chr>              <chr>      <chr>           <chr>           <chr>          
#>  1 2021 NAB AFLW Com… Round 1    Carlton         Collingwood     Ikon Park      
#>  2 2021 NAB AFLW Com… Round 1    St Kilda        Western Bulldo… RSEA Park      
#>  3 2021 NAB AFLW Com… Round 1    Gold Coast Suns Melbourne       Metricon Stadi…
#>  4 2021 NAB AFLW Com… Round 1    West Coast Eag… Adelaide Crows  Mineral Resour…
#>  5 2021 NAB AFLW Com… Round 1    Geelong Cats    Kangaroos       GMHBA Stadium  
#>  6 2021 NAB AFLW Com… Round 1    Richmond        Brisbane Lions  Swinburne Cent…
#>  7 2021 NAB AFLW Com… Round 1    Fremantle       GWS Giants      Fremantle Oval 
#>  8 2021 NAB AFLW Com… Round 2    Western Bulldo… Carlton         Victoria Unive…
#>  9 2021 NAB AFLW Com… Round 2    Collingwood     Geelong Cats    Victoria Park  
#> 10 2021 NAB AFLW Com… Round 2    Melbourne       Richmond        Casey Fields   
#> # … with 53 more rows

Lastly - we can choose a different source. Note that the field names and even the names of the teams and/or venues will be different for difference sources.

fetch_fixture(2021, round_number = 1, source = "squiggle")
#> # A tibble: 198 x 24
#>       id hteam  ascore localtime  year is_grand_final updated ateam hscore date 
#>    <int> <chr>   <int> <chr>     <int>          <int> <chr>   <chr>  <int> <chr>
#>  1  6243 Adela…      0 2021-03-…  2021              0 2020-1… Geel…      0 2021…
#>  2  6245 Brisb…      0 2021-03-…  2021              0 2020-1… Sydn…      0 2021…
#>  3  6241 Colli…      0 2021-03-…  2021              0 2020-1… West…      0 2021…
#>  4  6244 Essen…      0 2021-03-…  2021              0 2020-1… Hawt…      0 2021…
#>  5  6247 Great…      0 2021-03-…  2021              0 2020-1… St K…      0 2021…
#>  6  6242 Melbo…      0 2021-03-…  2021              0 2020-1… Frem…      0 2021…
#>  7  6246 North…      0 2021-03-…  2021              0 2020-1… Port…      0 2021…
#>  8  6240 Richm…      0 2021-03-…  2021              0 2020-1… Carl…      0 2021…
#>  9  6248 West …      0 2021-03-…  2021              0 2020-1… Gold…      0 2021…
#> 10  6249 Carlt…      0 2021-03-…  2021              0 2020-1… Coll…      0 2021…
#> # … with 188 more rows, and 14 more variables: round <int>, tz <chr>,
#> #   hgoals <lgl>, roundname <chr>, is_final <int>, winner <lgl>,
#> #   complete <int>, winnerteamid <lgl>, abehinds <lgl>, ateamid <int>,
#> #   hteamid <int>, hbehinds <lgl>, agoals <lgl>, venue <chr>

It should also be noted that the various sources of data have their own functions that can be called directly.

# The following are the same
fetch_fixture(2021, round_number = 5, source = "squiggle")
fetch_fixture_squiggle(2021, round_number = 5)

Womens Data

With these new functions we now have access to consistent AFLW data for the first time!

At a high level, any fetch_ function will allow you to specify the that comp = "AFLW and will return data. Please note that Womens data only exists when source = "AFL", which is the default for all fetch_ functions.

Read the full AFL Womens Vingette for specific examples.