tango

package module
v0.0.0-...-8cd742b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2015 License: MIT Imports: 9 Imported by: 0

README

Tango GoDoc

Complete wrapper for Valve's DOTA 2 Web API exposed cleanly to Go.

Supports all available WebAPI methods except for GetTournamentPlayerStats and GetTournamentPrizePool as they both only work for LeagueID=65006, which is The International 2013.

Example

package main

import (
    "fmt"
	"log"

	"github.com/fortytw2/tango"
)

var matchID = 271145478

func main() {
	api := tango.NewWebAPI("API KEY")

	m, err := api.GetMatch(matchID)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("DOTA 2 Match", matchID)
	fmt.Println("Winner -", m.Victor)

	fmt.Println("Radiant Heroes")
	for _, player := range m.Radiant {
		fmt.Println(player.Hero.LocalizedName)
	}

	fmt.Println("Dire Heroes")
	for _, player := range m.Dire {
		fmt.Println(player.Hero.LocalizedName)
	}
}

Should be very straightforward to use, check Godoc for complete documentation and open an issue here on GitHub if anything goes wrong.

LICENSE

MIT, see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WebAPI

type WebAPI struct {
	// contains filtered or unexported fields
}

WebAPI just wraps the parsing functionality found in requests/ in an easy to use API

func NewWebAPI

func NewWebAPI(key string) *WebAPI

NewWebAPI creates a new instance of WebAPI, with the given steam development key held internally. http://steamcommunity.com/dev/registerkey

func (*WebAPI) GetMatch

func (wa *WebAPI) GetMatch(id int) (*dota.Match, error)

GetMatch returns a *dota.Match parsed out of the Dota2 WebAPI.

func (*WebAPI) GetPlayerMatchIDs

func (wa *WebAPI) GetPlayerMatchIDs(playerID int, since time.Time) ([]int, error)

GetPlayerMatchIDs gets all of a players matchIDs since a certain time, because this requires potentially a large number of HTTP requests, the function will block for a while. Unfortunately, Valve currently restricts the GetMatchHistory endpoint to a mere 500 entries, returning the last match repeated if you try to go further. It appears there are solutions for this, just need to implement them here - this code isn't the greatest anyways...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL