riotapi

package module
v0.0.0-...-4a0a2c3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2017 License: MIT Imports: 10 Imported by: 0

README

riotapi

Golang implementation for Riot API

Status

Very Work In Progress

APIs Implemented

Rate Limiting

Riot Games has strict API limits for developer keys. As of April 26, 2017 these limits are:

  • 10 requests every 10 seconds
  • 500 requests every 10 minutes

The riotapi package allows the specification of a Throttled rate limiter to limit how frequently API calls are made to the Riot API.

Warning: by default calls to the riotapi package are not limited. If you use this package without specifying a rate limiter, you may unintentionally exceed the limits allowed by Riot and get your API access temporarily suspended or permanently banned. Please use caution!

An example rate limiter using the developer limits can be found in riotapi_test.go.

Testing

You will need to set the environment variable RIOTAPI_KEY to you Riot Developer API Key in order to run tests with go test. You can obtain your API Key from Riot at Riot's Developer Website.

As mentioned above, the tests specify a rate limiter using the developer limits API rate limits.

License

All files under this repository fall under the MIT License (see the file LICENSE).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAPIKeyRequired    = errors.New("Required APIKey is missing")
	ErrUnknownPlatformId = errors.New("Unknown platform id")
)
View Source
var Platforms = []Platform{
	{"NA1", "North America", "NA"},
	{"BR1", "Brazil", "BR"},
	{"EUN1", "EU Nordic & East ", "EUNE"},
	{"EUW1", "EU West", "EUW"},
	{"JP1", "Japan", "JP"},
	{"KR", "Korea", "KR"},
	{"LA1", "Latin America North", "LAN"},
	{"LA2", "Latin America South", "LAS"},
	{"OC1", "Oceania", "OCE"},
	{"PBE1", "PBE", "PBE"},
	{"RU", "Russia", "RU"},
	{"TR1", "Turkey", "TR"},
}

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey      string
	Summoner    *SummonerMethod
	League      *LeagueMethod
	MatchList   *MatchListMethod
	RateLimiter *throttled.GCRARateLimiter
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient initializes and returns a riotapi Client struct

type LeagueDTO

type LeagueDTO struct {
	// The league's queue type.
	Queue string `json:"queue"`

	// The league's tier.
	Tier string `json:"tier"`

	// Specifies the relevant participant that is a member of this league
	// (i.e., a requested summoner ID, a requested team ID, or the ID of
	// a team to which one of the requested summoners belongs). Only
	// present when full league is requested so that participant's entry
	// can be identified. Not present when individual entry is requested.
	ParticipantId string `json:"participantId,omitempty"`

	// This name is an internal place-holder name only. Display and
	// localization of names in the game client are handled client-side.
	Name string `json:"name,omitempty"`

	// The requested league entries.
	Entries []LeagueEntryDTO `json:"entries"`
}

LeagueDTO struct describes a response to a League api call

type LeagueEntryDTO

type LeagueEntryDTO struct {
	// Specifies if the participant is fresh blood.
	IsFreshBlood bool `json:"isFreshBlood"`

	// The league division of the participant.
	Division string `json:"division"`

	// The playstyle of the participant.
	Playstyle string `json:"playstyle"`

	// Mini series data for the participant. Only present if the participant
	// is currently in a mini series.
	MiniSeries *MiniSeriesDTO `json:"miniSeries,omitempty"`

	// The number of wins for the participant.
	Wins int `json:"wins"`

	// The number of losses for the participant.
	Losses int `json:"losses"`

	// The ID of the participant (i.e., summoner or team) represented by
	// this entry.
	PlayerOrTeamId string `json:"playerOrTeamId"`

	// The name of the the participant (i.e., summoner or team) represented
	// by this entry.
	PlayerOrTeamName string `json:"playerOrTeamName"`

	//  Specifies if the participant is on a hot streak.
	IsHotStreak bool `json:"isHotStreak"`

	//  Specifies if the participant is inactive.
	IsInactive bool `json:"isInactive"`

	// Specifies if the participant is a veteran.
	IsVeteran bool `json:"isVeteran"`

	// The league points of the participant.
	LeaguePoints int `json:"leaguePoints"`
}

LeagueEntryDTO describes an entry in response to a League api call

type LeagueMethod

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

func (*LeagueMethod) EntryBySummoner

func (m *LeagueMethod) EntryBySummoner(summonerId int64, platformId string) (LeagueResponseMap, error)

func (*LeagueMethod) PositionsBySummoner

func (m *LeagueMethod) PositionsBySummoner(summonerId int64, platformId string) (LeaguePositionSlice, error)

type LeaguePositionDTO

type LeaguePositionDTO struct {
	// Name of the League
	LeagueName string `json:"leagueName"`

	// Specifies if the participant is fresh blood.
	FreshBlood bool `json:"freshBlood"`

	// The league rank of the participant: I, II, III, IV, V
	Rank string `json:"rank"`

	// Mini series data for the participant. Only present if the participant
	// is currently in a mini series.
	MiniSeries *MiniSeriesDTO `json:"miniSeries,omitempty"`

	// The number of wins for the participant.
	Wins int `json:"wins"`

	// The number of losses for the participant.
	Losses int `json:"losses"`

	// The ID of the participant (i.e., summoner or team) represented by
	// this entry.
	PlayerOrTeamId string `json:"playerOrTeamId"`

	// The name of the the participant (i.e., summoner or team) represented
	// by this entry.
	PlayerOrTeamName string `json:"playerOrTeamName"`

	//  Specifies if the participant is on a hot streak.
	HotStreak bool `json:"hotStreak"`

	//  Specifies if the participant is inactive.
	Inactive bool `json:"inactive"`

	// Specifies if the participant is a veteran.
	Veteran bool `json:"veteran"`

	// The league points of the participant.
	LeaguePoints int `json:"leaguePoints"`
}

LeaguePositionDto describes a single position entry for a summoner in a League

type LeaguePositionSlice

type LeaguePositionSlice []LeaguePositionDTO

type LeagueResponseMap

type LeagueResponseMap map[string][]LeagueDTO

Map of summonerId (string version) to slice of LeagueDTO structures

type MatchListDto

type MatchListDto struct {
	Matches    []MatchReferenceDto `json:"matches,omitempty"`
	TotalGames int                 `json:"totalGames"`
	StartIndex int                 `json:"startIndex"`
	EndIndex   int                 `json:"endIndex"`
}

MatchList struct describes a response to a Match List api call

type MatchListMethod

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

func (*MatchListMethod) ByAccount

func (m *MatchListMethod) ByAccount(accountId int64, platformId string, options *MatchListOptions) (*MatchListDto, error)

type MatchListOptions

type MatchListOptions struct {
	// The end time to use for fetching games specified as epoch milliseconds.
	EndTime int64 `url:"endTime,omitempty"`

	// The end index to use for fetching games.
	EndIndex int `url:"endIndex,omitempty"`

	// Set of queue IDs for filtering matchlist.
	Queues []QueueType `url:"queue,omitempty"`

	// Set of season IDs for filtering matchlist.
	Seasons []int `url:"season,omitempty"`

	// The begin time to use for fetching games specified as epoch milliseconds.
	BeginTime int64 `url:"beginTime,omitempty"`

	// The begin index to use for fetching games.
	BeginIndex int `url:"beginIndex,omitempty"`

	// Comma-separated list of champion IDs to use for fetching games.
	Champions []int `url:"champion,omitempty"`
}

type MatchReferenceDto

type MatchReferenceDto struct {
	Lane       string `json:"lane"`
	Champion   int    `json:"champion"`
	PlatformId string `json:"platformId"`
	Timestamp  int64  `json:"timestamp"` // Epoch milliseconds
	Region     string `json:"region"`
	GameId     int64  `json:"gameId"`
	Queue      int    `json:"queue"`
	Role       string `json:"role"`
	Season     int    `json:"season"`
}

type MiniSeriesDTO

type MiniSeriesDTO struct {
	// String showing the current, sequential mini series progress where
	// 'W' represents a win, 'L' represents a loss, and 'N' represents a
	// game that hasn't been played yet.
	Progress string `json:"progress"`

	// Number of current losses in the mini series.
	Losses int `json:"losses"`

	// Number of wins required for promotion.
	Target int `json:"target"`

	// Number of current wins in the mini series.
	Wins int `json:"wins"`
}

type Platform

type Platform struct {
	Id       string // e.g. "NA1"
	Name     string // e.g. "North America"
	RegionId string // e.g. "NA"
}

Platform struct describes a Riot Platform

func GetPlatform

func GetPlatform(id string) *Platform

GetPlatform returns the platform description for a given platform id (case-insensitive)

func GetPlatformByRegion

func GetPlatformByRegion(region string) *Platform

GetPlatform returns the platform description for a given platform id (case-insensitive)

type QueueType

type QueueType int
const (
	CUSTOM                          QueueType = 0   // Custom games
	NORMAL_3x3                      QueueType = 8   // Normal 3v3 games
	NORMAL_5x5_BLIND                QueueType = 2   // Normal 5v5 Blind Pick games
	NORMAL_5x5_DRAFT                QueueType = 14  // Normal 5v5 Draft Pick games
	RANKED_SOLO_5x5                 QueueType = 4   // Ranked Solo 5v5 games
	RANKED_PREMADE_5x5              QueueType = 6   // Ranked Premade 5v5 games (Deprecated)
	RANKED_PREMADE_3x3              QueueType = 9   // Historical Ranked Premade 3v3 games (Deprecated)
	RANKED_FLEX_TT                  QueueType = 9   // Ranked Flex Twisted Treeline games
	RANKED_TEAM_3x3                 QueueType = 41  // Ranked Team 3v3 games (Deprecated)
	RANKED_TEAM_5x5                 QueueType = 42  // Ranked Team 5v5 games
	ODIN_5x5_BLIND                  QueueType = 16  // Dominion 5v5 Blind Pick games
	ODIN_5x5_DRAFT                  QueueType = 17  // Dominion 5v5 Draft Pick games
	BOT_5x5                         QueueType = 7   // Historical Summoner's Rift Coop vs AI games (Deprecated)
	BOT_ODIN_5x5                    QueueType = 25  // Dominion Coop vs AI games
	BOT_5x5_INTRO                   QueueType = 31  // Summoner's Rift Coop vs AI Intro Bot games
	BOT_5x5_BEGINNER                QueueType = 32  // Summoner's Rift Coop vs AI Beginner Bot games
	BOT_5x5_INTERMEDIATE            QueueType = 33  // Historical Summoner's Rift Coop vs AI Intermediate Bot games
	BOT_TT_3x3                      QueueType = 52  // Twisted Treeline Coop vs AI games
	GROUP_FINDER_5x5                QueueType = 61  // Team Builder games
	ARAM_5x5                        QueueType = 65  // ARAM games
	ONEFORALL_5x5                   QueueType = 70  // One for All games
	FIRSTBLOOD_1x1                  QueueType = 72  // Snowdown Showdown 1v1 games
	FIRSTBLOOD_2x2                  QueueType = 73  // Snowdown Showdown 2v2 games
	SR_6x6                          QueueType = 75  // Summoner's Rift 6x6 Hexakill games
	URF_5x5                         QueueType = 76  // Ultra Rapid Fire games
	ONEFORALL_MIRRORMODE_5x5        QueueType = 78  // One for All (Mirror mode)
	BOT_URF_5x5                     QueueType = 83  // Ultra Rapid Fire games played against AI games
	NIGHTMARE_BOT_5x5_RANK1         QueueType = 91  // Doom Bots Rank 1 games
	NIGHTMARE_BOT_5x5_RANK2         QueueType = 92  // Doom Bots Rank 2 games
	NIGHTMARE_BOT_5x5_RANK5         QueueType = 93  // Doom Bots Rank 5 games
	ASCENSION_5x5                   QueueType = 96  // Ascension games
	HEXAKILL                        QueueType = 98  // Twisted Treeline 6x6 Hexakill games
	BILGEWATER_ARAM_5x5             QueueType = 100 // Butcher's Bridge games
	KING_PORO_5x5                   QueueType = 300 // King Poro games
	COUNTER_PICK                    QueueType = 310 // Nemesis games
	BILGEWATER_5x5                  QueueType = 313 // Black Market Brawlers games
	SIEGE                           QueueType = 315 // Nexus Siege games
	DEFINITELY_NOT_DOMINION_5x5     QueueType = 317 // Definitely Not Dominion games
	ARURF_5X5                       QueueType = 318 // All Random URF games
	ARSR_5x5                        QueueType = 325 // All Random Summoner's Rift games
	TEAM_BUILDER_DRAFT_UNRANKED_5x5 QueueType = 400 // Normal 5v5 Draft Pick games
	TEAM_BUILDER_DRAFT_RANKED_5x5   QueueType = 410 // Ranked 5v5 Draft Pick games (Deprecated)
	TEAM_BUILDER_RANKED_SOLO        QueueType = 420 // Ranked Solo games from current season that use Team Builder matchmaking
	RANKED_FLEX_SR                  QueueType = 440 // Ranked Flex Summoner's Rift games
	ASSASSINATE_5x5                 QueueType = 600 // Blood Hunt Assassin games
	DARKSTAR_3x3                    QueueType = 610 // Darkstar games
)

type SummonerDTO

type SummonerDTO struct {
	// ID of the summoner icon associated with the summoner.
	ProfileIconId int `json:"profileIconId"`

	// Summoner name.
	Name string `json:"name"`

	// Summoner level associated with the summoner.
	SummonerLevel int64 `json:"summonerLevel"`

	// Date summoner was last modified specified as epoch milliseconds.
	// The following events will update this timestamp: profile icon change,
	// playing the tutorial or advanced tutorial, finishing a game, summoner name change
	RevisionDate int64 `json:"revisionDate"`

	// Summoner ID.
	Id int64 `json:"id"`

	// Account ID.
	AccountId int64 `json:"accountId"`
}

Platform struct describes a Riot Platform

type SummonerMethod

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

func (*SummonerMethod) ByName

func (m *SummonerMethod) ByName(name, platformId string) (*SummonerDTO, error)

Jump to

Keyboard shortcuts

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