Title: | Interface for OpenDota API |
---|---|
Description: | Enables the usage of the OpenDota API from <https://www.opendota.com/>, get game lists, and download JSON's of parsed replays from the OpenDota API. Also has functionality to execute own code to extract the specific parts of the JSON file. |
Authors: | Kari Gunnarsson |
Maintainer: | Kari Gunnarsson <[email protected]> |
License: | GPL |
Version: | 0.1.4 |
Built: | 2024-10-11 03:13:22 UTC |
Source: | https://github.com/karigunnarsson/opendotar |
Function that controls the delay between API calls to opendota, user can specify the wait_time, but opendota asks you to limit yourself to 1 call per second
api_delay(start_time, wait_time = 1)
api_delay(start_time, wait_time = 1)
start_time |
Time of last API call |
wait_time |
Desired wait time between API calls |
There is no return, it simply sleeps the system for whatever time needed to reach wait_time
## Not run: api_delay(start_time, wait_time) ## End(Not run)
## Not run: api_delay(start_time, wait_time) ## End(Not run)
Create an SQL query to opendotas API and extracts a list of games from the public_matches table. This is only a sample of matches, not all are included here. Returns a vector of match ID's ready for use in the get_games() function.
get_game_list(num_matches, from_time, to_time, min_mmr = 1, min_duration = 1200, num_open_profile = 0)
get_game_list(num_matches, from_time, to_time, min_mmr = 1, min_duration = 1200, num_open_profile = 0)
num_matches |
Number of matches you want to extract |
from_time |
Earliest time of match in YMD text format. |
to_time |
Latest start time of the match in YMD text format. |
min_mmr |
Minimum average MMR of the match (defaulted to 1) |
min_duration |
Minium match duration in seconds, defaulted to 1200 (20 minutes) |
num_open_profile |
Minium number of open profiles in the game. Higher number here gives higher percentage of games that are actually parsed. |
Returns data frame of results fulfilling the parameters input.
## Not run: match_ids <- get_game_list(num_matches = 100, from_time = "20170101" , to_time = "20170423", min_mmr = 4000) ## End(Not run)
## Not run: match_ids <- get_game_list(num_matches = 100, from_time = "20170101" , to_time = "20170423", min_mmr = 4000) ## End(Not run)
Takes a vector of numerical value match ID's of dota2 replays, and attempts to fetch them from the opendota API only parsed matches are output.
get_games(game_vec, wait_time = 1, output = "all", verbose = TRUE)
get_games(game_vec, wait_time = 1, output = "all", verbose = TRUE)
game_vec |
Numeric vector of match ID's |
wait_time |
how long to wait (in seconds) between each API call, default is 1 sec (opendota asks you not to send more than 1 call per second) |
output |
Defaulted to "all", which will extract entire JSON, if not all, it should have the path to an R file that will be sourced and create some output, not the R file must also output to output_list() |
verbose |
Give live information on status of parsing, if FALSE no text is output to console. |
Returns a list of objects, if output == "all" it's a list of JSON outputs.
## Not run: match_ids <- get_game_list(num_matches = 100, from_time = "20170101", to_time = "20170423", min_mmr = 4000) get_games(match_ids) ## End(Not run)
## Not run: match_ids <- get_game_list(num_matches = 100, from_time = "20170101", to_time = "20170423", min_mmr = 4000) get_games(match_ids) ## End(Not run)
Obtain the latest parsed games, this is a good function to use if you're not picky on which dates or MMR your data is, but want fast data. The latest games will always have parsed games opposed to the general game list gotten from get_game_list(), wich only contains 5 - 10 games.
get_latest_games(num_games, min_duration = 1200, wait_time = 1, output = "all")
get_latest_games(num_games, min_duration = 1200, wait_time = 1, output = "all")
num_games |
Min number of games you want to obtain (could get 1-10 more) |
min_duration |
Do you want to exclude games below a certain duration threshold? We default it to 1200seconds (20 minutes), as super short games often contain early abandons and griefers. |
wait_time |
Wait time between API calls, default to 1.00 (which is what opendota wants you to stay below, so don¨t change unless you have a good reason and talked to opendota about it). |
output |
Defaulted to "all", which will extract entire JSON, if not all, it should have the path to an R file that will be sourced and create some output, note the R file must also output to output_list() |
## Not run: parsed_games <- get_latest_games(100) ## End(Not run)
## Not run: parsed_games <- get_latest_games(100) ## End(Not run)