Skip to content

Commit

Permalink
OpenDota API version 17.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
leamare committed Oct 13, 2018
1 parent 611d06d commit 9646785
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
16 changes: 15 additions & 1 deletion ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ API Endpoint | Function | Parameters
`GET /teams/{team_id}/players` | `team_players($team_id)` | `$team_id (int) = {team_id}`
`GET /teams/{team_id}/heroes` | `team_heroes($team_id)` | `$team_id (int) = {team_id}`

### Replays
### Replays

API Endpoint | Function | Parameters
-- | -- | --
Expand All @@ -154,8 +154,22 @@ API Endpoint | Function | Parameters
-- | -- | --
`GET /live` | `live()` | none

### Scenarios

API Endpoint | Function | Parameters
-- | -- | --
`GET /scenarios/itemTimings` | `scenarios_item_timings()` | `$item (string) = item` - Filter by item name e.g. "spirit_vessel"; `$hero_id (int) = hero_id` - Hero ID
`GET /scenarios/laneRoles` | `scenarios_lane_roles()` | `$lane_role (string) = lane_role` - Filter by lane role 1-4 (Safe, Mid, Off, Jungle); `$hero_id (int) = hero_id` - Hero ID
`GET /scenarios/misc` | `scenarios_misc()` | `$scenario (string) = scenario` - pos_chat_1min,neg_chat_1min,courier_kill,first_blood

### Schema

API Endpoint | Function | Parameters
-- | -- | --
`GET /schema` | `schema()` | none

### Admin

API Endpoint | Function | Parameters
-- | -- | --
`GET /admin/apiMetrics` | `api_metrics()` | none
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Simple OpenDota API library for PHP

### API version: 17.6.0
### API version: 17.6.1

Simple OpenDota API support realization for PHP.

Expand Down
49 changes: 43 additions & 6 deletions simple_opendota.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function __construct($cli_report_status=false, $hostname="", $cooldown=0, $api_k
if ($cooldown)
$this->api_cooldown = $cooldown/1000;
else if (!empty($this->api_key))
$this->api_cooldown = 0.2;
$this->api_cooldown = 0.25;
else
$this->api_cooldown = 1;

Expand All @@ -59,7 +59,7 @@ function __construct($cli_report_status=false, $hostname="", $cooldown=0, $api_k
private function get($url, $data = []) {
if (!empty($this->api_key))
$data['api_key'] = $this->api_key;

if (!empty($data)) {
$url .= "?".http_build_query($data);
}
Expand Down Expand Up @@ -93,13 +93,13 @@ private function get($url, $data = []) {
private function post($url, $data = []) {
if (!empty($this->api_key))
$url .= "?api_key=".$this->api_key;

$curl = curl_init($this->hostname.$url);

if ( $this->report_status ) {
echo("...");
}

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
Expand Down Expand Up @@ -401,9 +401,9 @@ public function public_matches($less_than_match_id = null, $sort = 0, $mode = 0)
$params['less_than_match_id'] = (int)$less_than_match_id;

if ( $sort == 1 )
$params['mme_ascending'] = "";
$params['mmr_ascending'] = "";
else if ( $sort == -1 )
$params['mme_descending'] = "";
$params['mmr_descending'] = "";

return $this->request("publicMatches", $mode, $params);
}
Expand Down Expand Up @@ -661,6 +661,35 @@ public function live($mode = 0) {
return $this->request("live", $mode);
}

# ********** Scenarios

public function scenarios_item_timings($item, $hero_id, $mode = 0) {
# GET /scenarios/itemTimings
# Win rates for certain item timings on a hero for items that cost at least 1400 gold
#
# $item (string) = item - Filter by item name e.g. "spirit_vessel"
# $hero_id (int) = hero_id - Hero ID
return $this->request("scenarios/itemTimings", $mode, [ "item" => $item, "hero_id" => $hero_id ]);
}

public function scenarios_lane_roles($lane_role, $hero_id, $mode = 0) {
# GET /scenarios/laneRoles
# Win rates for heroes in certain lane roles
#
# $lane_role (string) = lane_role - Filter by lane role 1-4 (Safe, Mid, Off, Jungle)
# $hero_id (int) = hero_id - Hero ID
return $this->request("scenarios/laneRoles", $mode, [ "lane_role" => $lane_role, "hero_id" => $hero_id ]);
}

public function scenarios_misc($scenario, $mode = 0) {
# GET /scenarios/misc
# Miscellaneous team scenarios
#
# $scenario (string) = scenario - pos_chat_1min,neg_chat_1min,courier_kill,first_blood
return $this->request("scenarios/misc", $mode, [ "scenario" => $scenario ]);
}


# ********** Schema

public function schema($mode = 0) {
Expand All @@ -669,6 +698,14 @@ public function schema($mode = 0) {
return $this->request("schema", $mode);
}

# ********** Admin

public function api_metrics($mode = 0) {
# GET /admin/apiMetrics
# Get API request metrics
return $this->request("admin/apiMetrics", $mode);
}

}

?>

0 comments on commit 9646785

Please sign in to comment.