This is an R Steam API client specifically designed for Valve's game Dota2.
To install the latest released version from CRAN you just need to run on your console:
install.packages('RDota2')
To install the development version you need to have the devtools
package installed. To install devtools type in your console: install.packages('devtools')
.
Then to install RDota2 run the following on your console:
devtools::install_github('lyzander/RDota2')
The typical workflow of RDota2 would include registering a key on R and then using the get_* family functions to access the API.
To register a key on R in order to use Steam API through RDota2 you firstly need to get a key from Steam. You will need a steam account in order to request a key. To get a key please visit Steam Community.
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:
#load installed package
library(RDota2)
#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 do the following (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:
#load installed package
library(RDota2)
#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.
get_heroes()
Each of the get_*
family functions has a key argument which should only be used if you work with multiple keys.
To read the tutorial and documentation for RDota2 please visit RDota2.
To find out about the Steam API Documentation you can visit Steam.
To see the released version you can visit CRAN.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.