Skip to contents

cf_open() retrieves data from the CrossFit Open API, lightly pre-processed. If you need low level access to the API, use cf_request().

If no data is returned by the API, an empty tibble with zero columns and zero rows is returned.

You'll typically need to use tidyr::unnest_wider() and tidyr::hoist() to further process this data.

This function will automatically paginate through the data. To avoid overloading the API, it will not perform more than 100 requests per minute.

Usage

cf_open(
  year,
  ...,
  division = cf_division$Men,
  scale = cf_scale$rx,
  affiliate = NULL,
  n_pages = NULL,
  progress = TRUE
)

Arguments

year

The year to retrieve data for. Note that not all parameters will be valid for past years.

...

These dots are for future extensions and must be empty.

division

The division to retrieve data for. One of the values in cf_division.

scale

The workout scale to retrieve data for. One of the values in cf_scale.

affiliate

An optional integer ID to only retrieve data about a particular affiliate.

n_pages

An optional integer to limit the number of pages returned. Each page will have a maximum of 100 rows returned. This is useful if you just want to explore the data without downloading all of it. If not specified, this will download all available data.

progress

Should a progress bar be shown for longer downloads?

Value

A tibble.

Examples

library(tidyr)
library(dplyr)

top_100 <- cf_open(2022, n_pages = 1)

top_100 %>%
  unnest_wider(entrant) %>%
  hoist(scores, one = 1) %>%
  select(competitorName, one) %>%
  unnest_wider(one) %>%
  select(competitorName, score, breakdown)
#> # A tibble: 100 × 3
#>    competitorName  score   breakdown                                            
#>    <chr>           <chr>   <chr>                                                
#>  1 Saxon Panchik   3800000 "12 rounds +\n3 wall walks\n12 db snatches\n5 box ju…
#>  2 Matt Poulin     3640000 "12 rounds +\n3 wall walks\n1 db snatches\n"         
#>  3 Justin Medeiros 3720000 "12 rounds +\n3 wall walks\n9 db snatches\n"         
#>  4 Colten Mertens  3610000 "12 rounds +\n1 wall walk\n"                         
#>  5 Phil Toon       3630000 "12 rounds +\n3 wall walks\n"                        
#>  6 Victor Ljungdal 3900000 "13 rounds\n"                                        
#>  7 Jay Crouch      3630000 "12 rounds +\n3 wall walks\n"                        
#>  8 Scott Tetlow    3500000 "11 rounds +\n3 wall walks\n12 db snatches\n5 box ju…
#>  9 Cédric Lapointe 3880000 "12 rounds +\n3 wall walks\n12 db snatches\n13 box j…
#> 10 Dallin Pepper   3690000 "12 rounds +\n3 wall walks\n6 db snatches\n"         
#> # … with 90 more rows

# CrossFit Huntersville
affiliate <- 16292

cf_open(2022, division = cf_division$Women, affiliate = affiliate) %>%
  unnest_wider(entrant) %>%
  hoist(scores, two = 2) %>%
  select(competitorName, two) %>%
  unnest_wider(two) %>%
  select(competitorName, score, breakdown)
#> # A tibble: 10 × 3
#>    competitorName     score   breakdown                                         
#>    <chr>              <chr>   <chr>                                             
#>  1 Kiera Caveny-Cox   1930000 "2nd round of 4 +\n3 deadlifts\n2 bar-facing burp…
#>  2 Jackie Asbury      1610000 "2nd round of 7 +\n3 deadlifts\n"                 
#>  3 Devan Olschewske   1540000 "2nd round of 8 +\n7 deadlifts\n3 bar-facing burp…
#>  4 Erika Siedlaczek   1450000 "2nd round of 8 +\n1 deadlift\n"                  
#>  5 Aurianna Alexander 1360000 "2nd round of 9 +\n8 deadlifts\n"                 
#>  6 Kim McDonald       1410000 "2nd round of 9 +\n8 deadlifts\n5 bar-facing burp…
#>  7 Becky Goodrich     1090000 "Round of 9 +\n10 deadlifts\n9 bar-facing burpees…
#>  8 Moogie Fountain    1220000 "Round of 10 +\n9 deadlifts\n3 bar-facing burpees…
#>  9 Amanda Gorrod      1090000 "Round of 9 +\n10 deadlifts\n9 bar-facing burpees…
#> 10 Angela Garlock     1430000 "2nd round of 9 +\n8 deadlifts\n7 bar-facing burp…