RDota2 is an R Steam API client for Valve’s game Dota2.
In order to use the package you will need to have a Steam Key which you can get from Steam Community. You will also need a Steam account in order to request a key.
The typical workflow of RDota2 would include registering a key on R and then using the get_* family functions to access the API.
The typical way of working with RDota2 is to register a key on R (once in every section) and then that key will automatically be used within each one of the get_* family functions.
In order to register a key on R you need to use the
key_actions
function in the following way:
#register key on R. xxxxxx is the key you received from Steam.
key_actions(action = 'register_key', value = 'xxxxxxxx')
Instead of specifying the key on your console / script (where it would be visible to anyone), good practice dictates to save it in an environment variable. This is a very easy to do process and you only need to do it once. The key will always be made easily available in your R sessions after this. In order to store the key in an environment variable you would need to take the next steps (the following procedure has been taken from the appendix of Best practices for writing an API package):
normalizePath("~/")
in the R console.RDota_KEY=xxxxxxxx
, where RDota_KEY will be the name of the
R environment variable and xxxxxxxx will be your individual Steam API
Key. Make sure the last line in the file is empty (if it isn’t R will
silently fail to load the file). If you’re using an editor that shows
line numbers, there should be two lines, where the second one is
empty.Sys.getenv
.So, the best practice would be to register your key in the following way:
#register key on R. Sys.getenv('RDota_KEY') will retrieve the value of the
#RDota_KEY environment variable which is saved in your .Renviron file.
key_actions(action = 'register_key', value = Sys.getenv('RDota_KEY'))
#now you can use any of the get_* family functions without specifying a key e.g.
heroes <- get_heroes()
head(heroes$content)
Each of the get_*
family functions has a key argument
which should only be used if you work with multiple keys.
The get_* family functions are the functions used to access the API. They map the following API methods:
Dota 2 methods relating to match information:
Dota 2 methods relating to Dota 2 economy:
You can access the Steam API Documentation from this link.
All get_* functions have three common arguments that can be used:
Moreover, all get_* functions will return a dota_api
object that contains 3 elements:
By default when printing a dota_api
object only
the content element will be printed on screen.
The above are true for all the get_* functions, so they will not be analysed in detail in the individual function demonstration that follows.
get_league_listing
returns information about Dota
TV-supported leagues. The function does not require any extra arguments
and outputs a data.frame with the following columns:
Steam API Documentation: GetLeagueListing
get_live_league_games
returns information about the live
league games. The function does not require any extra arguments and
outputs a list (called games), of which each element is a game. Each
game contains the following information (some might be missing for some
games):
Steam API Documentation: GetLiveLeagueGames
#### List of 17
## $ players :List of 11
## ..$ :List of 4
## .. ..$ account_id: int 292934088
## .. ..$ name : chr "FACEIT.com | Shannon Bot"
## .. ..$ hero_id : int 0
## .. ..$ team : int 4
## ..$ :List of 4
## .. ..$ account_id: int 124344565
## .. ..$ name : chr "Ryadovoi Lebys"
## .. ..$ hero_id : int 91
## .. ..$ team : int 1
## ..$ :List of 4
## .. ..$ account_id: int 374473137
## .. ..$ name : chr "<U+041D><U+0410><U+0421><U+0415><U+041A><U+041E><U+041C><U+042B><U+0428>""| __truncated__
## .. ..$ hero_id : int 90
## .. ..$ team : int 1
## ..$ :List of 4
## .. ..$ account_id: int 53178236
## .. ..$ name : chr "Sedoy"
## .. ..$ hero_id : int 18
## .. ..$ team : int 0
## ..$ :List of 4
## .. ..$ account_id: int 84692724
## .. ..$ name : chr "PANDA"
## .. ..$ hero_id : int 110
## .. ..$ team : int 1
## ..$ :List of 4
## .. ..$ account_id: int 86840554
## .. ..$ name : chr "tmw"
## .. ..$ hero_id : int 15
## .. ..$ team : int 0
## ..$ :List of 4
## .. ..$ account_id: int 123787524
## .. ..$ name : chr "Shachlo"
## .. ..$ hero_id : int 60
## .. ..$ team : int 0
## ..$ :List of 4
## .. ..$ account_id: int 159020918
## .. ..$ name : chr "RodjER"
## .. ..$ hero_id : int 37
## .. ..$ team : int 0
## ..$ :List of 4
## .. ..$ account_id: int 148096933
## .. ..$ name : chr "number0"
## .. ..$ hero_id : int 47
## .. ..$ team : int 1
## ..$ :List of 4
## .. ..$ account_id: int 11550182
## .. ..$ name : chr "VANSKOR"
## .. ..$ hero_id : int 69
## .. ..$ team : int 0
## ..$ :List of 4
## .. ..$ account_id: int 86817707
## .. ..$ name : chr "72293768"
## .. ..$ hero_id : int 82
## .. ..$ team : int 1
## $ radiant_team :List of 4
## ..$ team_name: chr "FlipSid3 Tactics"
## ..$ team_id : int 2790766
## ..$ team_logo: num 2.78e+17
## ..$ complete : logi TRUE
## $ lobby_id : num 2.48e+16
## $ match_id : num 2.73e+09
## $ spectators : int 1256
## $ series_id : int 0
## $ game_number : int 0
## $ league_id : int 5027
## $ stream_delay_s : int 300
## $ radiant_series_wins: int 0
## $ dire_series_wins : int 0
## $ series_type : int 0
## $ league_series_id : int 0
## $ league_game_id : int 0
## $ stage_name : chr ""
## $ league_tier : int 3
## $ scoreboard :List of 4
## ..$ duration : num 1035
## ..$ roshan_respawn_timer: int 377
## ..$ radiant :List of 11
## .. ..$ score : int 13
## .. ..$ tower_state : int 1983
## .. ..$ barracks_state: int 63
## .. ..$ picks :List of 5
## truncated...
get_match_details
provides information about the game
and the players participating in a specific match. The function requires
a match_id
to be provided. The function ouputs a list which
contains information about the players and the match. The first element
of the content list contains information about the players. The
following details are included:
The rest of the elements of the content list contain information about the match. The following details are included:
Steam API Documentation: GetMatchDetails
#match list contains information about both players and the match
match_details <- get_match_details(match_id = 2686721815)$content
#match_details[[1]] is a list with all the players - usually 10
#match_details[[1]][[1]] is just one of the 10 players
str(match_details[[1]][[1]])
#information about the match
str(match_details[-1])
get_match_details
provides information about matches
according to a number of parameters. The available parameters are:
The content element of the list contains a list called matches. Each element of matches list is a match. Each match contains the following sections:
Steam API Documentation: GetMatchHistory
get_match_history_by_sequence_num
provides information
about matches ordered by a sequence number. The function can get
start_at_match_seq_num
and matches_requested
as arguments but both are optional. The function returns a list called
matches. Each match follows exactly the same structure as the match
retrieved from get_match_details
.
Please see that function for the exact details.
Steam API Documentation: GetMatchHistoryBySequenceNum
get_scheduled_league_games
returns a list of scheduled
league games coming up. The function can get two optional arguments
date_min
and date_max
specifying the time
period in which to get the games. The function returns a list called
games. Each game contains the following sections:
Steam API DOcumentation GetScheduledLeagueGames
get_team_info_by_team_id
provides informationa about a
team given a team id. The function can get two optional arguments.
start_at_team_id
specifies the team id to start returning
results from and teams_requested
specifies the number of
teams to return. The function returns a teams list of which each element
is a match. The following information for each match is provided:
Steam API Documentation: GetTeamInfoByTeamID
get_tournament_player_stats
provides information about
tournament players’ stats. It requires an account_id
and
optionally a league_id
(only the international is supported
i.e. 65006), a hero_id
or a time_frame
(this
is not functional just yet according to the Steam API Documentation).
The function returns a list that contains information about the matches
the player played and information about global stats.
Steam API Documentation: GetTournamentPlayerStats
get_top_live_game
returns the top live games by MMR. It
requires a partner
parameter (not optional) but the API
documentation does not specify what it actually is. Values of 1 or 2 or
3 seem to be working. The function returns a games_list
list which contains information about the top live games. The following
categories are returns for each game. They are not documented on the
API:
Steam API Documentation: GetTopLiveGame
get_game_items
returns information about Dota’s items.
The function does not require any extra arguments and outputs a
data.frame with the following columns:
Steam API Documentation: GetGameItems
get_heroes
returns information about Dota’s heroes. The
function does not require any extra arguments and outputs a data.frame
with the following columns:
Steam API Documentation: GetHeroes
get_rarities
returns information about Dota’s item
rarities. The function does not require any extra arguments and outputs
a data.frame with the following columns:
Steam API Documentation: GetRarities
get_tournament_prize_pool
returns information about
Dota’s tournament prizes. The function can take an optional
leagueid
argument (the league id to get the prize for) and
outputs a data.frame with the following columns:
Steam API Documentation: GetTournamentPrizePool
get_event_stats_for_account
returns an account’s event
stats. The function takes two arguments. An eventid
argument (the league id) and an accountid
argument (account
id to get stats for). A list will be returned but the contents of it are
not documented in the Steam API Documentation. The function returns a
list that contains:
Steam API Documentation: GetEventStatsForAccount
get_item_icon_path
returns the icon path for an item. It
requires an iconname
(The item icon name) and an
icontype
(the type of image - 0 is normal, 1 is large and 3
is ingame) argument. There is no documentation regarding this method in
the Steam API Documentation at the time of writing.
Steam API Documentation: GetItemIconPath
If you would like to make any recommendations or give feedback or report a bug please visit the development site on github.
You made it to the end of the documentation! Thanks for reading!