Skip to contents

valorantr makes it easy to retrieve data from rib.gg’s API.

Events

We can retrieve tournaments (events) with a query string passed to get_events. If you’re query string doesn’t match something that the API recognized, a default set of results will be returned (determined by the API).

vct_champs_events <- get_events("VALORANT Champions 2022")

vct_champs_playoffs_events <- vct_champs_events |> 
  filter(name == "VALORANT Champions 2022 - Playoffs")
glimpse(vct_champs_playoffs_events)
#> Rows: 1
#> Columns: 30
#> $ id                <int> 1866
#> $ name              <chr> "VALORANT Champions 2022 - Playoffs"
#> $ shortName         <chr> "Playoffs"
#> $ description       <chr> NA
#> $ logoUrl           <chr> NA
#> $ regionId          <int> 7
#> $ countryId         <int> 218
#> $ startDate         <chr> "2022-09-09T15:46:00.000Z"
#> $ endDate           <chr> "2022-09-19T15:46:00.000Z"
#> $ prizePool         <int> NA
#> $ prizePoolCurrency <chr> "USD"
#> $ url               <chr> "https://liquipedia.net/valorant/VCT/2022/Champions"
#> $ imageUrl          <chr> NA
#> $ winnerStageCount  <int> NA
#> $ loserStageCount   <int> NA
#> $ live              <lgl> FALSE
#> $ rank              <int> 9
#> $ pmtJson           <lgl> NA
#> $ parent            <lgl> FALSE
#> $ parentId          <int> 1858
#> $ childLabel        <chr> "Playoffs"
#> $ keywords          <list> []
#> $ slug              <chr> "valorant-champions-2022-playoffs"
#> $ seriesCount       <int> 14
#> $ importance        <int> 0
#> $ type              <chr> "bracket"
#> $ vctRegions        <list> <"EMEA", "AMERICAS", "PACIFIC", NA>
#> $ divisions         <list> <"VCT", NA>
#> $ region            <df[,4]> <data.frame[1 x 4]>
#> $ country           <df[,6]> <data.frame[1 x 6]>

We can load pre-saved events saved in the events release in valorant-data with load_valorant("events).

presaved_events <- load_valorant("events")
nrow(presaved_events)
#> [1] 78
presaved_events |> 
  filter(id == vct_champs_playoffs_events$id) |> 
  glimpse()
#> Rows: 1
#> Columns: 29
#> $ id                <int> 1866
#> $ name              <chr> "VALORANT Champions 2022 - Playoffs"
#> $ shortName         <chr> "Playoffs"
#> $ description       <chr> NA
#> $ logoUrl           <chr> NA
#> $ regionId          <int> 7
#> $ countryId         <int> 218
#> $ startDate         <chr> "2022-09-09T15:46:00.000Z"
#> $ endDate           <chr> "2022-09-19T15:46:00.000Z"
#> $ prizePool         <int> NA
#> $ prizePoolCurrency <chr> "USD"
#> $ url               <chr> "https://liquipedia.net/valorant/VCT/2022/Champions"
#> $ imageUrl          <chr> NA
#> $ winnerStageCount  <int> NA
#> $ loserStageCount   <int> NA
#> $ live              <lgl> FALSE
#> $ rank              <int> 9
#> $ bracketJson       <df[,4]> <data.frame[1 x 4]>
#> $ pmtJson           <lgl> NA
#> $ parent            <lgl> FALSE
#> $ parentId          <int> 1858
#> $ childLabel        <chr> "Playoffs"
#> $ keywords          <list> []
#> $ slug              <chr> "valorant-champions-2022-playoffs"
#> $ seriesCount       <int> 14
#> $ importance        <int> 0
#> $ type              <chr> "bracket"
#> $ region            <df[,4]> <data.frame[1 x 4]>
#> $ country           <df[,6]> <data.frame[1 x 6]>

See all of the releases that can be read with load_valorant() here.

Some ID fields in the returned data may not be obvious. For example, what is regionId = 7? There are various get_all_{x}_names() functions written to help with ID-name mappings. In this case, get_all_region_names() is helpful.

get_all_region_names()
#>   regionId    regionName
#> 1        1        Europe
#> 2        2 North America
#> 3        3  Asia-Pacific
#> 4        4 Latin America
#> 5        5          MENA
#> 6        6        Oceana
#> 7        7 International

Series

We can retrieve all of the series played at an event with get_series.

cleanly_unnest_series <- function(series) {
  series |> 
    unnest_wider(c(team1, team2), names_sep = "_") |> 
    clean_names()
}

vct_champs_playoffs_series <- get_series(vct_champs_playoffs_events$id) |> 
  cleanly_unnest_series()
glimpse(vct_champs_playoffs_series)
#> Rows: 14
#> Columns: 67
#> $ id                   <int> 35364, 35365, 35331, 35313, 35332, 35309, 35252, …
#> $ event_id             <int> 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1…
#> $ team1id              <int> 6344, 6426, 17, 6344, 603, 286, 6426, 286, 224, 1…
#> $ team2id              <int> 6426, 286, 286, 6426, 17, 1625, 603, 6344, 1625, …
#> $ team1score           <int> 3, 3, 0, 2, 1, 2, 2, 0, 0, 2, 2, 2, 2, 0
#> $ team2score           <int> 1, 2, 2, 0, 2, 1, 1, 2, 2, 0, 0, 1, 0, 2
#> $ start_date           <chr> "2022-09-18T14:00:00.000Z", "2022-09-17T14:00:00.…
#> $ best_of              <int> 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
#> $ stage                <int> 4, 4, 3, 3, NA, 2, 2, 2, 1, 1, 1, 1, 1, 1
#> $ bracket              <chr> "winners", "losers", "losers", "winners", NA, "lo…
#> $ completed            <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…
#> $ live                 <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, …
#> $ win_condition        <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ vlr_id               <chr> "130685", "130691", "130690", "130684", NA, "1306…
#> $ vod_url              <chr> "https://www.twitch.tv/videos/1594403547?t=02h07m…
#> $ ggbet_id             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ pmt_status           <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ pmt_reddit_url       <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ pmt_json             <df[,4]> <data.frame[14 x 4]>
#> $ pickban              <list> [], [], [], [], [], [], [], [], [], [], [], [], […
#> $ event_name           <chr> "VALORANT Champions 2022 - Playoffs", "VALORANT C…
#> $ event_slug           <chr> "valorant-champions-2022-playoffs", "valorant-cha…
#> $ event_child_label    <chr> "Playoffs", "Playoffs", "Playoffs", "Playoffs", "…
#> $ event_logo_url       <chr> "https://i.imgur.com/eJZnat0.webp", "https://i…
#> $ event_region_id      <int> 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
#> $ parent_event_id      <int> 1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858, …
#> $ parent_event_name    <chr> "VALORANT Champions 2022", "VALORANT Champions 20…
#> $ parent_event_slug    <chr> "valorant-champions-2022", "valorant-champions-20…
#> $ team1_id             <int> 6344, 6426, 17, 6344, 603, 286, 6426, 286, 224, 1…
#> $ team1_name           <chr> "LOUD", "OpTic Gaming", "FunPlus Phoenix (Inactiv…
#> $ team1_short_name     <chr> "LOUD", "OPTC", "FPX", "LOUD", "XSET", "DRX", "OP…
#> $ team1_description    <chr> "", "", "FunPlus Phoenix (also known as FunPlus X…
#> $ team1_website_url    <chr> "https://loud.gg/", "https://opticgaming.gg/", "h…
#> $ team1_logo_url       <chr> "https://i.imgur.com/AiZFd1I.webp", "https://i.im…
#> $ team1_liquipedia_url <chr> "https://liquipedia.net/valorant/LOUD", "https://…
#> $ team1_twitter_url    <chr> "https://twitter.com/loudgg", "https://twitter.co…
#> $ team1_twitch_url     <chr> "https://www.twitch.tv/loud", "https://www.twitch…
#> $ team1_vlr_url        <chr> "https://www.vlr.gg/team/6961/loud", "https://www…
#> $ team1_youtube_url    <chr> "https://www.youtube.com/channel/UC7iwNp4GUynlGXv…
#> $ team1_founded_date   <chr> "2022-02-01T00:00:00+00:00", "2022-02-10T00:00:00…
#> $ team1_country_id     <int> 30, 226, 252, 30, 226, 113, 226, 113, 252, 252, 2…
#> $ team1_region_id      <int> 4, 2, 1, 4, 2, 3, 2, 3, 1, 1, 2, 2, 3, 4
#> $ team1_rank           <int> 1534, NA, NA, 1534, NA, 4, NA, 4, 7, NA, NA, NA, …
#> $ team1_region_rank    <int> 222, NA, NA, 222, NA, 2, NA, 2, 3, NA, NA, NA, 2,…
#> $ team1_aliases        <list<list>> [<NULL>], ["OpTic"], [<"FPX", "FunPlus">], [<NULL…
#> $ team1_vct_region     <chr> "AMERICAS", NA, NA, "AMERICAS", NA, "PACIFIC", NA…
#> $ team1_division       <chr> "VCT", NA, NA, "VCT", NA, "VCT", NA, "VCT", "VCT"…
#> $ team2_id             <int> 6426, 286, 286, 6426, 17, 1625, 603, 6344, 1625, …
#> $ team2_name           <chr> "OpTic Gaming", "DRX", "DRX", "OpTic Gaming", "Fu…
#> $ team2_short_name     <chr> "OPTC", "DRX", "DRX", "OPTC", "FPX", "FNC", "XSET…
#> $ team2_description    <chr> "", "Vision Strikers is a Korean VALORANT team fo…
#> $ team2_website_url    <chr> "https://opticgaming.gg/", "https://drx.gg…
#> $ team2_logo_url       <chr> "https://i.imgur.com/2nXAtuC.png", "https://i.img…
#> $ team2_liquipedia_url <chr> "https://liquipedia.net/valorant/OpTic_Gaming", "…
#> $ team2_twitter_url    <chr> "https://twitter.com/OpTic", "https://twitter.com…
#> $ team2_twitch_url     <chr> "https://www.twitch.tv/opticgaming", "https://www…
#> $ team2_vlr_url        <chr> "https://www.vlr.gg/team/8127/optic-gaming", "htt…
#> $ team2_youtube_url    <chr> "https://www.youtube.com/opticcraft", "https://ww…
#> $ team2_founded_date   <chr> "2022-02-10T00:00:00+00:00", "2020-06-01T15:26:00…
#> $ team2_country_id     <int> 226, 113, 113, 226, 252, 252, 226, 30, 252, 43, 2…
#> $ team2_region_id      <int> 2, 3, 3, 2, 1, 1, 2, 4, 1, 4, 1, 1, 1, 4
#> $ team2_rank           <int> NA, 4, 4, NA, NA, 1, NA, 1534, 1, 9, 1, 7, NA, 15…
#> $ team2_region_rank    <int> NA, 2, 2, NA, NA, 1, NA, 222, 1, 1, 1, 3, NA, 222
#> $ team2_aliases        <list<list>> ["OpTic"], ["DRX"], ["DRX"], ["OpTic"], [<"FPX", …
#> $ team2_vct_region     <chr> NA, "PACIFIC", "PACIFIC", NA, NA, "EMEA", NA, "AM…
#> $ team2_division       <chr> NA, "VCT", "VCT", NA, NA, "VCT", NA, "VCT", "VCT"…
#> $ matches              <list> [<data.frame[5 x 29]>], [<data.frame[5 x 29]>], […

We can filter for a specific series from the set of series.

optic_liquid_series <- vct_champs_playoffs_series |> 
  filter(team1_short_name == "OPTC", team2_short_name == "TL")
glimpse(optic_liquid_series)
#> Rows: 1
#> Columns: 67
#> $ id                   <int> 35225
#> $ event_id             <int> 1866
#> $ team1id              <int> 6426
#> $ team2id              <int> 224
#> $ team1score           <int> 2
#> $ team2score           <int> 1
#> $ start_date           <chr> "2022-09-10T14:00:00.000Z"
#> $ best_of              <int> 3
#> $ stage                <int> 1
#> $ bracket              <chr> "winners"
#> $ completed            <lgl> TRUE
#> $ live                 <lgl> FALSE
#> $ win_condition        <lgl> NA
#> $ vlr_id               <chr> "130680"
#> $ vod_url              <chr> "https://www.twitch.tv/videos/1587106175?t=01h06m…
#> $ ggbet_id             <lgl> NA
#> $ pmt_status           <lgl> NA
#> $ pmt_reddit_url       <lgl> NA
#> $ pmt_json             <df[,4]> <data.frame[1 x 4]>
#> $ pickban              <list> []
#> $ event_name           <chr> "VALORANT Champions 2022 - Playoffs"
#> $ event_slug           <chr> "valorant-champions-2022-playoffs"
#> $ event_child_label    <chr> "Playoffs"
#> $ event_logo_url       <chr> "https://i.imgur.com/eJZnat0.webp"
#> $ event_region_id      <int> 7
#> $ parent_event_id      <int> 1858
#> $ parent_event_name    <chr> "VALORANT Champions 2022"
#> $ parent_event_slug    <chr> "valorant-champions-2022"
#> $ team1_id             <int> 6426
#> $ team1_name           <chr> "OpTic Gaming"
#> $ team1_short_name     <chr> "OPTC"
#> $ team1_description    <chr> ""
#> $ team1_website_url    <chr> "https://opticgaming.gg/"
#> $ team1_logo_url       <chr> "https://i.imgur.com/2nXAtuC.png"
#> $ team1_liquipedia_url <chr> "https://liquipedia.net/valorant/OpTic_Gaming"
#> $ team1_twitter_url    <chr> "https://twitter.com/OpTic"
#> $ team1_twitch_url     <chr> "https://www.twitch.tv/opticgaming"
#> $ team1_vlr_url        <chr> "https://www.vlr.gg/team/8127/optic-gaming"
#> $ team1_youtube_url    <chr> "https://www.youtube.com/opticcraft"
#> $ team1_founded_date   <chr> "2022-02-10T00:00:00+00:00"
#> $ team1_country_id     <int> 226
#> $ team1_region_id      <int> 2
#> $ team1_rank           <int> NA
#> $ team1_region_rank    <int> NA
#> $ team1_aliases        <list<list>> ["OpTic"]
#> $ team1_vct_region     <chr> NA
#> $ team1_division       <chr> NA
#> $ team2_id             <int> 224
#> $ team2_name           <chr> "Team Liquid"
#> $ team2_short_name     <chr> "TL"
#> $ team2_description    <chr> "Team Liquid is a professional esports organizati…
#> $ team2_website_url    <chr> "https://www.teamliquid.com/"
#> $ team2_logo_url       <chr> "https://i.imgur.com/wpW5RtY.webp"
#> $ team2_liquipedia_url <chr> "https://liquipedia.net/valorant/Team_Liquid"
#> $ team2_twitter_url    <chr> "https://twitter.com/LiquidValorant"
#> $ team2_twitch_url     <chr> "https://www.twitch.tv/team/teamliquid"
#> $ team2_vlr_url        <chr> "https://www.vlr.gg/team/474/team-liquid"
#> $ team2_youtube_url    <chr> "https://www.youtube.com/teamliquid"
#> $ team2_founded_date   <chr> "2020-08-07T15:02:00+00:00"
#> $ team2_country_id     <int> 252
#> $ team2_region_id      <int> 1
#> $ team2_rank           <int> 7
#> $ team2_region_rank    <int> 3
#> $ team2_aliases        <list<list>> [<"TL", "LIQUID">]
#> $ team2_vct_region     <chr> "EMEA"
#> $ team2_division       <chr> "VCT"
#> $ matches              <list> [<data.frame[3 x 29]>]

We can use get_all_map_names() to identify which maps are played in the series.

optic_liquid_series |> 
  hoist(
    matches,
    matchId = 'id',
    mapId = 'mapId'
  ) |> 
  select(seriesId = id, matchId, mapId) |> 
  unnest_longer(c(matchId, mapId)) |> 
  inner_join(
    get_all_map_names(),
    by = 'mapId'
  )
#> # A tibble: 3 × 4
#>   seriesId matchId mapId mapName
#>      <int>   <int> <dbl> <chr>  
#> 1    35225   79016     8 breeze 
#> 2    35225   79017     3 bind   
#> 3    35225   79018     1 ascent

We can load pre-saved series with load_valorant("series").

presaved_series <- load_valorant("series")
nrow(presaved_series)
#> [1] 2409
presaved_series |> 
  filter(id == optic_liquid_series$id) |> 
  cleanly_unnest_series() |> 
  glimpse()
#> Rows: 1
#> Columns: 58
#> $ id                   <int> 35225
#> $ event_id             <int> 1866
#> $ team1id              <int> 6426
#> $ team2id              <int> 224
#> $ start_date           <chr> "2022-09-10T14:00:00.000Z"
#> $ best_of              <int> 3
#> $ stage                <int> 1
#> $ bracket              <chr> "winners"
#> $ completed            <lgl> TRUE
#> $ live                 <lgl> FALSE
#> $ win_condition        <lgl> NA
#> $ vlr_id               <chr> "130680"
#> $ vod_url              <chr> "https://www.twitch.tv/videos/1587106175?t=01h06m…
#> $ ggbet_id             <chr> NA
#> $ pmt_status           <chr> NA
#> $ pmt_reddit_url       <chr> NA
#> $ pmt_json             <df[,6]> <data.frame[1 x 6]>
#> $ event_name           <chr> "VALORANT Champions 2022 - Playoffs"
#> $ event_slug           <chr> "valorant-champions-2022-playoffs"
#> $ event_logo_url       <chr> "https://i.imgur.com/eJZnat0.webp"
#> $ parent_event_id      <int> 1858
#> $ parent_event_name    <chr> "VALORANT Champions 2022"
#> $ parent_event_slug    <chr> "valorant-champions-2022"
#> $ team1_id             <int> 6426
#> $ team1_name           <chr> "OpTic Gaming"
#> $ team1_short_name     <chr> "OPTC"
#> $ team1_description    <chr> ""
#> $ team1_website_url    <chr> "https://opticgaming.gg/"
#> $ team1_logo_url       <chr> "https://i.imgur.com/2nXAtuC.png"
#> $ team1_liquipedia_url <chr> "https://liquipedia.net/valorant/OpTic_Gaming"
#> $ team1_twitter_url    <chr> "https://twitter.com/OpTic"
#> $ team1_twitch_url     <chr> "https://www.twitch.tv/opticgaming"
#> $ team1_vlr_url        <chr> "https://www.vlr.gg/team/8127/optic-gaming"
#> $ team1_youtube_url    <chr> "https://www.youtube.com/opticcraft"
#> $ team1_founded_date   <chr> "2022-02-10T00:00:00+00:00"
#> $ team1_country_id     <int> 226
#> $ team1_region_id      <int> 2
#> $ team1_rank           <int> 2
#> $ team1_region_rank    <int> 1
#> $ team1_aliases        <list<list>> ["OpTic"]
#> $ team2_id             <int> 224
#> $ team2_name           <chr> "Team Liquid"
#> $ team2_short_name     <chr> "TL"
#> $ team2_description    <chr> "Team Liquid is a professional esports organizati…
#> $ team2_website_url    <chr> "https://www.teamliquid.com/"
#> $ team2_logo_url       <chr> "https://i.imgur.com/vAiJPS0.png"
#> $ team2_liquipedia_url <chr> "https://liquipedia.net/valorant/Team_Liquid"
#> $ team2_twitter_url    <chr> "https://twitter.com/LiquidValorant"
#> $ team2_twitch_url     <chr> "https://www.twitch.tv/team/teamliquid"
#> $ team2_vlr_url        <chr> "https://www.vlr.gg/team/474/team-liquid"
#> $ team2_youtube_url    <chr> "https://www.youtube.com/teamliquid"
#> $ team2_founded_date   <chr> "2020-08-07T15:02:00+00:00"
#> $ team2_country_id     <int> 252
#> $ team2_region_id      <int> 1
#> $ team2_rank           <int> 8
#> $ team2_region_rank    <int> 3
#> $ team2_aliases        <list<list>> [<"TL", "LIQUID">]
#> $ matches              <list> [<data.frame[3 x 28]>]

Matches

We can retrieve all of the “maps” played in a series (most are best of three).

optic_liquid_matches <- get_matches(optic_liquid_series$id)
names(optic_liquid_matches) <- make_clean_names(names(optic_liquid_matches))
str(optic_liquid_matches, max.level = 1)
#> List of 33
#>  $ id               : int 35225
#>  $ event_id         : int 1866
#>  $ team1id          : int 6426
#>  $ team2id          : int 224
#>  $ team1score       : int 2
#>  $ team2score       : int 1
#>  $ start_date       : chr "2022-09-10T14:00:00.000Z"
#>  $ best_of          : int 3
#>  $ stage            : int 1
#>  $ bracket          : chr "winners"
#>  $ completed        : logi TRUE
#>  $ live             : logi FALSE
#>  $ win_condition    : NULL
#>  $ vlr_id           : chr "130680"
#>  $ vod_url          : chr "https://www.twitch.tv/videos/1587106175?t=01h06m30s"
#>  $ ggbet_id         : NULL
#>  $ pmt_status       : NULL
#>  $ pmt_reddit_url   : NULL
#>  $ pmt_json         :List of 4
#>  $ pickban          : list()
#>  $ event_name       : chr "VALORANT Champions 2022 - Playoffs"
#>  $ event_slug       : chr "valorant-champions-2022-playoffs"
#>  $ event_child_label: chr "Playoffs"
#>  $ event_logo_url   : chr "https://i.imgur.com/eJZnat0.webp"
#>  $ event_region_id  : int 7
#>  $ parent_event_id  : int 1858
#>  $ parent_event_name: chr "VALORANT Champions 2022"
#>  $ parent_event_slug: chr "valorant-champions-2022"
#>  $ team1            :List of 19
#>  $ team2            :List of 19
#>  $ matches          :'data.frame':   3 obs. of  28 variables:
#>  $ stats            :List of 3
#>  $ player_stats     :'data.frame':   620 obs. of  23 variables:

We can load pre-saved matches with load_valorant("matches").

presaved_matches <- load_valorant("matches")
length(presaved_matches)
#> [1] 2409
set_names_from_id_element <- function(x) {
  match_ids <- x |> map_int(~pluck(.x, "id"))
  x |> set_names(match_ids)
}
presaved_matches <- set_names_from_id_element(presaved_matches)

presaved_matches[[as.character(optic_liquid_matches$id)]] |> 
  str(max.level = 1)
#> List of 28
#>  $ id             : int 35225
#>  $ eventId        : int 1866
#>  $ team1Id        : int 6426
#>  $ team2Id        : int 224
#>  $ startDate      : chr "2022-09-10T14:00:00.000Z"
#>  $ bestOf         : int 3
#>  $ stage          : int 1
#>  $ bracket        : chr "winners"
#>  $ completed      : logi TRUE
#>  $ live           : logi FALSE
#>  $ winCondition   : NULL
#>  $ vlrId          : chr "130680"
#>  $ vodUrl         : chr "https://www.twitch.tv/videos/1587106175?t=01h06m30s"
#>  $ ggbetId        : NULL
#>  $ pmtStatus      : NULL
#>  $ pmtRedditUrl   : NULL
#>  $ pmtJson        :List of 4
#>  $ eventName      : chr "VALORANT Champions 2022 - Playoffs"
#>  $ eventSlug      : chr "valorant-champions-2022-playoffs"
#>  $ eventLogoUrl   : chr "https://i.imgur.com/eJZnat0.webp"
#>  $ parentEventId  : int 1858
#>  $ parentEventName: chr "VALORANT Champions 2022"
#>  $ parentEventSlug: chr "valorant-champions-2022"
#>  $ team1          :List of 17
#>  $ team2          :List of 17
#>  $ matches        :'data.frame': 3 obs. of  27 variables:
#>  $ stats          :List of 3
#>  $ playerStats    :'data.frame': 620 obs. of  23 variables:

Players

We can retrieve players involved in the series with get_player.

optic_liquid_players <- optic_liquid_matches$player_stats |> 
  distinct(player_id = playerId) |> 
  pull(player_id) |> 
  map_dfr(get_player)
glimpse(optic_liquid_players)
#> Rows: 10
#> Columns: 22
#> $ id                    <int> 398, 750, 1690, 2056, 2483, 2716, 2841, 3211, 10…
#> $ ign                   <chr> "Marved", "dimasick", "ScreaM", "soulcas", "cras…
#> $ firstName             <chr> "Jimmy ", "Dmitriy ", "Adil", "Dom", "Austin", "…
#> $ lastName              <chr> "Nguyen", "Matvienko", "Benrlitom", "Sulcas", "R…
#> $ bio                   <chr> "Jimmy \"Marved\" Nguyen (born February 24, 2000…
#> $ countryId             <int> 38, 109, 21, 225, 226, 226, 38, 226, 72, 21
#> $ liquipediaUrl         <chr> "https://liquipedia.net/valorant/Marved", NA, "h…
#> $ twitchUrl             <chr> "https://www.twitch.tv/marved6", "https://www.tw…
#> $ twitterUrl            <chr> "https://twitter.com/Marved6", "https://twitter.…
#> $ imageUrl              <chr> "https://i.imgur.com/DYwGgCi.png", "https://i.im…
#> $ firestoreId           <chr> "7RC8SKxVDAcCRVyGyT6J", "EKfbL3XJAB7OylWeBWIq", …
#> $ teamPlayerHistoryId   <int> 59256, NA, 49755, 1883, 57181, 62381, 49480, 571…
#> $ teamId                <int> 388, NA, 7027, 224, 116, 9470, 116, 116, 224, 70…
#> $ startDate             <chr> "2023-03-13T00:00:00.000Z", NA, "2022-11-11T00:0…
#> $ role                  <chr> "player", NA, "player", "player", "player", "pla…
#> $ igl                   <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,…
#> $ previousRiotPlayerIds <list> <"NEb4WdiuTLdSeBCkAirEDdfN-ISo25r_L_N0j0CdESUe3W…
#> $ team                  <list> [388, "Sentinels", "SEN", "Sentinels is an Amer…
#> $ career                <list> [<data.frame[5 x 8]>], [<data.frame[7 x 8]>], […
#> $ news                  <list> [<data.frame[12 x 4]>], [<data.frame[2 x 4]>], …
#> $ instagramUrl          <chr> NA, NA, "https://www.instagram.com/screamdak1ng…
#> $ youtubeUrl            <chr> NA, NA, "https://www.youtube.com/ScreaMy", "http…

We can load pre-saved players with load_valorant("players").

presaved_players <- load_valorant("players")
nrow(presaved_players)
#> [1] 4412
presaved_players |> 
  filter(id %in% optic_liquid_players$id) |> 
  glimpse()
#> Rows: 10
#> Columns: 18
#> $ id                    <int> 398, 750, 1690, 2056, 2483, 2716, 2841, 3211, 10…
#> $ ign                   <chr> "Marved", "dimasick", "ScreaM", "soulcas", "cras…
#> $ firstName             <chr> "Jimmy ", "Dmitriy ", "Adil", "Dom", "Austin", "…
#> $ lastName              <chr> "Nguyen", "Matvienko", "Benrlitom", "Sulcas", "R…
#> $ bio                   <chr> "Jimmy \"Marved\" Nguyen (born February 24, 2000…
#> $ countryId             <int> 38, 109, 21, 225, 226, 226, 38, 226, 72, 21
#> $ instagramUrl          <chr> NA, NA, "https://www.instagram.com/screamdak1ng/…
#> $ liquipediaUrl         <chr> "https://liquipedia.net/valorant/Marved", NA, "h…
#> $ twitchUrl             <chr> "https://www.twitch.tv/marved6", "https://www.tw…
#> $ twitterUrl            <chr> "https://twitter.com/Marved6", "https://twitter.…
#> $ youtubeUrl            <chr> NA, NA, "https://www.youtube.com/ScreaMy", "http…
#> $ imageUrl              <chr> "https://i.imgur.com/DYwGgCi.png", "https://i.im…
#> $ firestoreId           <chr> "7RC8SKxVDAcCRVyGyT6J", "EKfbL3XJAB7OylWeBWIq", …
#> $ previousRiotPlayerIds <list> <"GcPwuG7vMwo9wHwd7VvAj4PNDxJE_Aa9REuzBgsR-8_xUX…
#> $ startDate             <chr> "2022-02-10T00:00:00.000Z", "2022-08-05T00:00:0…
#> $ role                  <chr> "player", "player", "player", "player", NA, "pla…
#> $ team                  <list> [6426, "OpTic Gaming", "OPTC", "", "https://opti…
#> $ news                  <list> [<data.frame[20 x 4]>], [<data.frame[25 x 4]>],…

Match details

We can retrieve details of a match (best-of-25 rounds).

optic_liquid_match_details <- optic_liquid_matches$matches$id |> 
  map(get_match_details)
str(optic_liquid_match_details, max.level = 2)
#> List of 3
#>  $ :List of 5
#>   ..$ id         : int 79016
#>   ..$ playerStats:'data.frame':  10 obs. of  12 variables:
#>   ..$ events     :'data.frame':  181 obs. of  19 variables:
#>   ..$ locations  :'data.frame':  1036 obs. of  6 variables:
#>   ..$ economies  :'data.frame':  200 obs. of  12 variables:
#>  $ :List of 5
#>   ..$ id         : int 79017
#>   ..$ playerStats:'data.frame':  10 obs. of  12 variables:
#>   ..$ events     :'data.frame':  199 obs. of  19 variables:
#>   ..$ locations  :'data.frame':  1155 obs. of  6 variables:
#>   ..$ economies  :'data.frame':  210 obs. of  12 variables:
#>  $ :List of 5
#>   ..$ id         : int 79018
#>   ..$ playerStats:'data.frame':  10 obs. of  12 variables:
#>   ..$ events     :'data.frame':  174 obs. of  19 variables:
#>   ..$ locations  :'data.frame':  1071 obs. of  6 variables:
#>   ..$ economies  :'data.frame':  210 obs. of  12 variables:

One of the interesting results is x-y coordinates of players.

optic_liquid_match_details_m3 <- optic_liquid_match_details[[3]]
glimpse(optic_liquid_match_details_m3$locations)
#> Rows: 1,071
#> Columns: 6
#> $ roundNumber     <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
#> $ playerId        <int> 398, 750, 1690, 2056, 2483, 2716, 2841, 3211, 10211, 1…
#> $ roundTimeMillis <int> 40570, 40570, 40570, 40570, 40570, 40570, 40570, 40570…
#> $ locationX       <dbl> 253.7364, 676.5586, 673.2531, 337.9559, 317.5478, 284.…
#> $ locationY       <dbl> 519.6171, 393.4316, 421.9599, 369.7179, 387.5391, 422.…
#> $ viewRadians     <dbl> 6.636822, 1.779514, 2.991358, NA, 7.822813, 6.891820, …

We can load pre-saved match details with load_valorant("match_details").

presaved_match_details <- load_valorant("match_details")
length(presaved_match_details)
#> [1] 5602
presaved_match_details <- set_names_from_id_element(presaved_match_details)
presaved_optic_liquid_match_details_m3 <- presaved_match_details[[as.character(optic_liquid_match_details_m3$id)]]
presaved_optic_liquid_match_details_m3 |> str(max.level = 1)
#> List of 4
#>  $ id       : int 79018
#>  $ events   :'data.frame':   174 obs. of  19 variables:
#>  $ locations:'data.frame':   1071 obs. of  6 variables:
#>  $ economies:'data.frame':   210 obs. of  10 variables:

We can use get_all_weapon_names(), get_all_agent_names(), get_all_role_names(), and get_all_armor_names() to augment the ID columns. Note that get_all_agent_names(), in addition to returning agentId and agentName, also returns roleId. (There is a 1-to-many mapping of agents to roles.)

presaved_optic_liquid_match_details_m3$economies |> 
  select(roundId, roundNumber, playerId, weaponId, agentId, armorId) |> 
  inner_join(get_all_weapon_names(), by = "weaponId") |> 
  inner_join(get_all_agent_names(), by = "agentId") |> 
  inner_join(get_all_role_names(), by = "roleId") |> 
  inner_join(get_all_armor_names(), by = "armorId") |> 
  glimpse()
#> Rows: 179
#> Columns: 12
#> $ roundId        <int> 1231423, 1231423, 1231424, 1231424, 1231424, 1231424, 1…
#> $ roundNumber    <int> 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4…
#> $ playerId       <int> 2483, 3211, 2483, 2841, 398, 1690, 3211, 2716, 2483, 75…
#> $ weaponId       <dbl> 11, 10, 18, 18, 5, 13, 18, 17, 4, 4, 18, 4, 5, 4, 4, 4,…
#> $ agentId        <dbl> 4, 16, 4, 19, 15, 7, 16, 17, 4, 11, 19, 17, 15, 16, 7, …
#> $ armorId        <dbl> 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2…
#> $ weaponName     <chr> "classic", "frenzy", "spectre", "spectre", "bulldog", "…
#> $ weaponCategory <chr> "sidearm", "sidearm", "smg", "smg", "rifle", "sidearm",…
#> $ agentName      <chr> "sova", "kayo", "sova", "fade", "astra", "phoenix", "ka…
#> $ roleId         <dbl> 1, 1, 1, 1, 3, 2, 1, 4, 1, 3, 1, 4, 3, 1, 2, 1, 1, 4, 1…
#> $ roleName       <chr> "initiator", "initiator", "initiator", "initiator", "co…
#> $ armorName      <chr> "light", "light", "heavy", "heavy", "heavy", "light", "…