hirezapi

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// yyyyMMdd
	DateFormat string = "20060102"

	// yyyyMMddHHmmss
	TimeFormat string = "20060102150405"

	// PortalIDs (Gaming Platforms)
	HiRez, Steam, PS4, XBOX, Switch, Discord, Epic string = "1", "5", "9", "10", "22", "25", "28"

	// Language Codes
	English    string = "1"
	German     string = "2"
	French     string = "3"
	Chinese    string = "5"
	Spanish    string = "7"
	SpanishLAM string = "9"
	Portuguese string = "10"
	Russian    string = "11"
	Polish     string = "12"
	Turkish    string = "13"

	// League Tiers
	Bronze5, Bronze4, Bronze3, Bronze2, Bronze1           string = "1", "2", "3", "4", "5"
	Silver5, Silver4, Silver3, Silver2, Silver1           string = "6", "7", "8", "9", "10"
	Gold5, Gold4, Gold3, Gold2, Gold1                     string = "11", "12", "13", "14", "15"
	Platinum5, Platinum4, Platinum3, Platinum2, Platinum1 string = "16", "17", "18", "19", "20"
	Diamond5, Diamond4, Diamond3, Diamond2, Diamond1      string = "21", "22", "23", "24", "25"
	Masters, Grandmaster                                  string = "26", "27"

	// Smite Match Queue IDs
	Adventures             string = "495"
	Arena                  string = "435"
	ArenaAIEasy            string = "457"
	ArenaAIMedium          string = "468"
	ArenaChallenge         string = "438"
	ArenaPracticeEasy      string = "443"
	ArenaPracticeMedium    string = "472"
	ArenaTraining          string = "483"
	ArenaTutorial          string = "462"
	Assault                string = "445"
	AssaultAIEasy          string = "481"
	AssaultAIMedium        string = "454"
	AssaultChallenge       string = "446"
	AssaultPracticeEasy    string = "479"
	AssaultPracticeMedium  string = "480"
	BasicTutorial          string = "436"
	Clash                  string = "466"
	ClashAIEasy            string = "478"
	ClashAIMedium          string = "469"
	ClashChallenge         string = "467"
	ClashPracticeEasy      string = "470"
	ClashPracticeMedium    string = "477"
	ClashTutorial          string = "471"
	ConqeustChallenge      string = "429"
	Conquest               string = "426"
	ConquestAIEasy         string = "476"
	ConquestAIMedium       string = "461"
	ConquestPracticeEasy   string = "458"
	ConquestPracticeMedium string = "475"
	ConquestRanked         string = "451"
	ConquestTutorial       string = "463"
	Joust                  string = "448"
	Joust1v1Ranked         string = "440"
	Joust3v3Ranked         string = "450"
	Joust3v3Training       string = "482"
	JoustAIEasy            string = "474"
	JoustAIMedium          string = "456"
	JoustChallenge         string = "441"
	JoustPracticeEasy      string = "464"
	JunglePracicePreselect string = "496"
	JunglePracitceMedium   string = "473"
	JunglePractice         string = "444"
	MatchOfTheDay          string = "434"
	Siege                  string = "459"
	SiegeChallenge         string = "460"

	// Paladins Match Queue IDs
	ClassicSiege                       string = "465"
	CustomOnslaughtForemansRise        string = "462"
	CustomOnslaughtMagistratesArchives string = "464"
	CustomOnslaughtPrimalCourt         string = "455"
	CustomOnslaughtSnowfallJunction    string = "454"
	CustomSiegeBrightmarsh             string = "458"
	CustomSiegeFishMarket              string = "431"
	CustomSiegeFrogIsle                string = "433"
	CustomSiegeFrozenGuard             string = "432"
	CustomSiegeIceMines                string = "439"
	CustomSiegeJaguarFalls             string = "438"
	CustomSiegeSerpentBeach            string = "440"
	CustomSiegeSplitstoneQuarry        string = "459"
	CustomSiegeStoneKeep               string = "423"
	CustomSiegeTimberMill              string = "430"
	CustomTDMForemansRise              string = "471"
	CustomTDMMagistrateArchives        string = "472"
	CustomTDMTradeDistrict             string = "468"
	LiveBattleGroundsDuo               string = "475"
	LiveBattleGroundsQuad              string = "476"
	LiveBattlegroundsSolo              string = "474"
	LiveCasual                         string = "424"
	LiveCompetitive                    string = "428"
	LiveOnslaught                      string = "452"
	LiveOnslaughtPractice              string = "453"
	LiveSiegePractice                  string = "425"
	LiveTeamDeathmatch                 string = "469"
	LiveTeamDeathmatchPractice         string = "470"
	LiveTestMaps                       string = "445"
)

Variables

This section is empty.

Functions

func Contains

func Contains(a []string, b string) bool

func FormatTime

func FormatTime(t time.Time) string

func IsNotRanked

func IsNotRanked(queueID string) bool

func IsPaladinsPath

func IsPaladinsPath(basePath string) bool

IsPaladinsPath checks that the client BasePath is for Paladins

func IsSmitePath

func IsSmitePath(basePath string) bool

IsNotSmitePath checks that the client BasePath is for Smite

Types

type APIClient

type APIClient struct {
	DeveloperID  string
	AuthKey      string
	BasePath     string
	RespType     string
	SessionID    string
	SessionStamp string
}

APIClient is the implementation of the HiRezAPI interface.

func (*APIClient) ChangeBasePath

func (a *APIClient) ChangeBasePath(url MustBeURL)

ChangeBasePath modifies the base path if you want to query a different platform.

func (*APIClient) ChangeResponseType

func (a *APIClient) ChangeResponseType(respType MustBeResponseType)

ChangeResponseType modifies the response type if you want to switch between JSON and XML

func (*APIClient) CreateSession

func (a *APIClient) CreateSession() error

CreateSession is a required step to Authenticate the developerId/signature for further API use.

func (*APIClient) GetBountyItems

func (a *APIClient) GetBountyItems() ([]models.BountyItem, error)

GetBountyItems returns daily Bounty Item history for the past 6 months.

func (*APIClient) GetChampionCards

func (a *APIClient) GetChampionCards(champID, langCode string) ([]models.ChampionCard, error)

GetChampionCards returns all Champion cards.

func (*APIClient) GetChampionLeaderboard

func (a *APIClient) GetChampionLeaderboard(champID string) ([]models.ChampionLeaderboardEntry, error)

GetChampionLeaderboard returns the current season's leaderboard for a champion/queue. [ Only queue 428]

func (*APIClient) GetChampionRanks

func (a *APIClient) GetChampionRanks(player string) ([]models.ChampionRank, error)

GetChampionRanks returns the rank and worshipper values for each Champion a player has played.

func (*APIClient) GetChampionSkins

func (a *APIClient) GetChampionSkins(champID, langCode string) ([]models.ChampionSkin, error)

GetChampionSkins returns a list of skins for a particular champion.

func (*APIClient) GetChampions

func (a *APIClient) GetChampions(langCode string) ([]models.Champion, error)

GetChampions returns all Champions and their various attributes.

func (*APIClient) GetDataUsed

func (a *APIClient) GetDataUsed() ([]models.DataUsed, error)

GetDataUsed returns API Developer daily usage limits and the current status against those limits.

func (*APIClient) GetESportsProLeagueDetails

func (a *APIClient) GetESportsProLeagueDetails() ([]models.ESportsProLeagueDetail, error)

GetESportsProLeagueDetails returns matchup info for each matchup of the current season. match_status = 1 - scheduled, 2 - in progress, 3 - complete

func (*APIClient) GetFriends

func (a *APIClient) GetFriends(player string) ([]models.Friend, error)

GetFriends returns Smite Usernames of each of the player's friends. [PC Only]

func (*APIClient) GetGodLeaderboard

func (a *APIClient) GetGodLeaderboard(godID, queueID string) ([]models.GodLeaderboardEntry, error)

GetGodLeaderboard returns the current season's leaderboard for a god/queue. [SmiteAPI: only queues 440, 450, 451]

func (*APIClient) GetGodRanks

func (a *APIClient) GetGodRanks(player string) ([]models.GodRank, error)

GetGodRanks returns the rank and worshipper values for each God a player has played.

func (*APIClient) GetGodRecommendedItems

func (a *APIClient) GetGodRecommendedItems(godID int64, langCode string) ([]models.GodRecommendedItem, error)

GetGodRecommendedItems returns the recommended items for a particular God.

func (*APIClient) GetGodSkins

func (a *APIClient) GetGodSkins(godID int64, langCode string) ([]models.GodSkin, error)

GetGodSkins returns all available skins for a particular God.

func (*APIClient) GetGods

func (a *APIClient) GetGods(langCode string) ([]models.God, error)

GetGods returns all Gods and their various attributes.

func (*APIClient) GetHiRezServerStatus

func (a *APIClient) GetHiRezServerStatus() ([]models.HiRezServerStatus, error)

GetHirezServerStatus returns UP/DOWN status for the primary game/platform environments. Data is cached once a minute.

func (*APIClient) GetItems

func (a *APIClient) GetItems(langCode string) ([]models.Item, error)

GetItems returns all items and their various attributes.

func (*APIClient) GetLeagueLeaderboard

func (a *APIClient) GetLeagueLeaderboard(queueID, tier, round string) ([]models.LeagueLeaderboardEntry, error)

GetLeagueLeaderboard returns the top players for a particular league.

func (*APIClient) GetLeagueSeasons

func (a *APIClient) GetLeagueSeasons(queueID string) ([]models.Season, error)

GetLeageSeasons returns a list of seasons for a match queue.

func (*APIClient) GetMOTD

func (a *APIClient) GetMOTD() ([]models.MOTD, error)

GetMOTD returns information about the 20 most recent Match-of-the-Days.

func (*APIClient) GetMatchDetails

func (a *APIClient) GetMatchDetails(matchID string) ([]models.MatchPlayer, error)

GetMatchDetails returns the statistics for a particular completed match.

func (*APIClient) GetMatchDetailsBatch

func (a *APIClient) GetMatchDetailsBatch(matchIDs []string) ([]models.MatchPlayer, error)

GetMatchDetailsBatch returns the statistics for a particular set of completed matches. (limit batch query to 5-10 matchIDs)

func (*APIClient) GetMatchHistory

func (a *APIClient) GetMatchHistory(player string) ([]models.Match, error)

GetMatchHistory returns a list of recent matches and high level match statistics for a particular player

func (*APIClient) GetMatchIDsByQueue

func (a *APIClient) GetMatchIDsByQueue(queueID, date, hour string) ([]models.Match, error)

GetMatchIDsByQueue lists all MatchIDs for a particular match queue.

  • queueID can be referened by constants defined in this package (eg, hirezapi.ConquestRanked).
  • date must be formatted/formattable by hirezapi.DateFormat (yyyyMMdd).
  • hour may be "0" - "23" and optionally may contain a ten minute window separated by a comma (eg, "6,30").
  • hour may also be "-1" to fetch the whole day, but may stall/fail due to the amount of data.

func (*APIClient) GetMatchPlayerDetails

func (a *APIClient) GetMatchPlayerDetails(matchID string) ([]models.LiveMatchPlayer, error)

GetMatchPlayerDetails returns player information for a live match.

func (*APIClient) GetOrganizedMatchDetailsBatch

func (a *APIClient) GetOrganizedMatchDetailsBatch(matchIDs []string) ([][]models.MatchPlayer, error)

GetOrganizedMatchDetailsBatch is the same as GetMatchDetailsBatch(), except it groups the players by match. (limit batch query to 5-10 matchIDs)

func (*APIClient) GetPatchInfo

func (a *APIClient) GetPatchInfo() (*models.VersionInfo, error)

GetPatchInfo returns information about the currently deployed patch.

func (*APIClient) GetPlayer

func (a *APIClient) GetPlayer(player string) ([]models.Player, error)

GetPlayer returns league and other high level data for a particular player.

func (*APIClient) GetPlayerAchievements

func (a *APIClient) GetPlayerAchievements(playerID string) (*models.PlayerAchievements, error)

GetPlayerAchievements returns select achievement totals.

func (*APIClient) GetPlayerBatch

func (a *APIClient) GetPlayerBatch(playerIDs []string) ([]models.Player, error)

GetPlayerBatch returns league and other high level data for a particular list of players. [20 max]

func (*APIClient) GetPlayerByPlatform

func (a *APIClient) GetPlayerByPlatform(player, portalID string) ([]models.Player, error)

GetPlayer returns league and other high level data for a particular player.

func (*APIClient) GetPlayerIDByName

func (a *APIClient) GetPlayerIDByName(player string) ([]models.PlayerIDInfo, error)

GetPlayerIDByName returns a list of Hi-Rez PlayerID values for the particular player

func (*APIClient) GetPlayerIDByPortalUserID

func (a *APIClient) GetPlayerIDByPortalUserID(portalID, portalUserID string) ([]models.PlayerIDInfo, error)

GetPlayerIDByPortalUserID returns a list of Hi-Rez PlayerID values for portalID/portalUserID combo

func (*APIClient) GetPlayerIDInfoForXBOXAndSwitch

func (a *APIClient) GetPlayerIDInfoForXBOXAndSwitch(player string) ([]models.PlayerIDInfoForXBOXAndSwitch, error)

GetPlayerIDInfoForXBOXAndSwitch returns all PlayerID data associated with the playerName

func (*APIClient) GetPlayerIDsByGamertag

func (a *APIClient) GetPlayerIDsByGamertag(portalID, gamerTag string) ([]models.PlayerIDInfo, error)

GetPlayerIDsByGamertag returns a list of Hi-Rez PlayerID values for a portalID/gamerTag combo

func (*APIClient) GetPlayerLoadouts

func (a *APIClient) GetPlayerLoadouts(player, langCode string) ([]models.PlayerLoadout, error)

GetPlayerLoadouts returns deck loadouts per Champion

func (*APIClient) GetPlayerStatus

func (a *APIClient) GetPlayerStatus(player string) ([]models.PlayerStatus, error)

GetPlayerStatus returns a player status.

func (*APIClient) GetQueueStats

func (a *APIClient) GetQueueStats(player, queueID string) ([]models.PlayerGodQueueStat, error)

GetQueueStats returns match summary stats for a player + queue, grouped by Gods played.

func (*APIClient) GetTeamDetails

func (a *APIClient) GetTeamDetails(clanID string) ([]models.TeamDetail, error)

GetTeamDetails returns the number of players and other high level details for a particular Clan.

func (*APIClient) GetTeamPlayers

func (a *APIClient) GetTeamPlayers(clanID string) ([]models.TeamPlayer, error)

GetTeamPlayers returns a list of players for a particular Clan.

func (*APIClient) GetTopMatches

func (a *APIClient) GetTopMatches() ([]models.TopMatch, error)

GetTopMatches returns the 50 most watched / recorded matches.

func (*APIClient) Ping

func (a *APIClient) Ping() error

Ping is a quick way of validating access to the Hi-Rez API.

func (*APIClient) SearchPlayers

func (a *APIClient) SearchPlayers(searchPlayer string) ([]models.PlayerIDInfo, error)

SearchPlayers returns playerID values for all names and/or gamerTags containing searchPlayer

func (*APIClient) SearchTeams

func (a *APIClient) SearchTeams(searchTeam string) ([]models.TeamDetail, error)

SearchTeams returns high level info for Clan names containing search term.

func (*APIClient) TestSession

func (a *APIClient) TestSession() (string, error)

TestSession is a means of validating that a session is established.

type HiRezAPI

type HiRezAPI interface {
	// ===== Connectivity =====
	// Ping is a quick way of validating access to the Hi-Rez API.
	Ping() error
	// CreateSession is a required step to Authenticate the developerId/signature for further API use.
	CreateSession() error
	// TestSession is a means of validating that a session is established.
	TestSession() (string, error)
	// GetHirezServerStatus returns UP/DOWN status for the primary game/platform environments. Data is cached once a minute.
	GetHiRezServerStatus() ([]models.HiRezServerStatus, error)
	// GetDataUsed returns API Developer daily usage limits and the current status against those limits.
	GetDataUsed() ([]models.DataUsed, error)
	// ChangeBasePath modifies the base path if you want to query a different platform
	ChangeBasePath(url MustBeURL)
	// ChangeResponseType modifies the response type if you want to switch between JSON and XML
	ChangeResponseType(respType MustBeResponseType)

	// ===== Player Related =====
	// GetPlayer returns league and other high level data for a particular player.
	GetPlayer(player string) ([]models.Player, error)
	// GetPlayer returns league and other high level data for a particular player.
	GetPlayerByPlatform(player, portalID string) ([]models.Player, error)
	// GetPlayerIDByName
	GetPlayerIDByName(player string) ([]models.PlayerIDInfo, error)
	// GetPlayerIDByPortalUserID
	GetPlayerIDByPortalUserID(portalID, portalUserID string) ([]models.PlayerIDInfo, error)
	// GetPlayerIDsByGamertag
	GetPlayerIDsByGamertag(portalID, gamerTag string) ([]models.PlayerIDInfo, error)
	// GetFriends returns Smite Usernames of each of the player's friends. [PC Only]
	GetFriends(player string) ([]models.Friend, error)
	// GetGodRanks returns the rank and worshipper values for each God a player has played.
	GetGodRanks(player string) ([]models.GodRank, error)
	// GetMatchHistory returns a list of recent matches and high level match statistics for a particular player
	GetMatchHistory(player string) ([]models.Match, error)
	// GetPlayerStatus returns a player status. 0 - offline, 1 - lobby, 2 - god select, 3 - in game, 4 - online, 5 - unknown
	GetPlayerStatus(player string) ([]models.PlayerStatus, error)
	// GetPlayerAchievements returns select achievement totals.
	GetPlayerAchievements(playerID string) (*models.PlayerAchievements, error)
	// GetTeamDetails returns the number of players and other high level details for a particular Clan.
	GetTeamDetails(clanID string) ([]models.TeamDetail, error)
	// GetTeamPlayers returns a list of players for a particular Clan.
	GetTeamPlayers(clanID string) ([]models.TeamPlayer, error)
	// SearchTeams returns high level info for Clan names containing search term.
	SearchTeams(searchTeam string) ([]models.TeamDetail, error)
	// SearchPlayers returns playerID values for all names and/or gamerTags containing searchPlayer
	SearchPlayers(searchPlayer string) ([]models.PlayerIDInfo, error)

	// ===== Game Entity Related =====
	// GetGods returns all Gods and their various attributes.
	GetGods(langCode string) ([]models.God, error)
	// GetGodSkins returns all available skins for a particular God.
	GetGodSkins(godID int64, langCode string) ([]models.GodSkin, error)
	// GetGodRecommendedItems returns the recommended items for a particular God.
	GetGodRecommendedItems(godID int64, langCode string) ([]models.GodRecommendedItem, error)
	// GetItems returns all items and their various attributes.
	GetItems(langCode string) ([]models.Item, error)

	// ===== Match Related =====
	// GetMatchDetails returns the statistics for a particular completed match.
	GetMatchDetails(matchID string) ([]models.MatchPlayer, error)
	/*GetMatchDetailsBatch returns the statistics for a particular set of completed matches. (limit batch query to 5-10 matchIDs)

		- The actual Hi-Rez API does not automatically group the response by matchID.
	  - If you want the results to be grouped by matchID, use GetOrganizedMatchDetailsBatch() instead.
	*/
	GetMatchDetailsBatch(matchIDs []string) ([]models.MatchPlayer, error)
	// GetOrganizedMatchDetailsBatch is the same as GetMatchDetailsBatch(), except it groups the players by match.
	GetOrganizedMatchDetailsBatch(matchIDs []string) ([][]models.MatchPlayer, error)
	// GetMatchPlayerDetails returns player information for a live match.
	GetMatchPlayerDetails(matchID string) ([]models.LiveMatchPlayer, error)
	/*GetMatchIDsByQueue lists all MatchIDs for a particular match queue.
	- queueID can be referened by constants defined in this package (eg, hirezapi.ConquestRanked).
	- date must be formatted/formattable by hirezapi.DateFormat (yyyyMMdd).
	- hour may be "0" - "23" and optionally may contain a ten minute window separated by a comma (eg, "6,30").
	- hour may also be "-1" to fetch the whole day, but may stall/fail due to the amount of data.
	*/
	GetMatchIDsByQueue(queueID, date, hour string) ([]models.Match, error)
	// GetQueueStats returns match summary stats for a player + queue, grouped by Gods played.
	GetQueueStats(player, queueID string) ([]models.PlayerGodQueueStat, error)

	// ===== Miscellaneous =====
	// GetESportsProLeagueDetails returns matchup info for each matchup of the current season. match_status = 1 - scheduled, 2 - in progress, 3 - complete
	GetESportsProLeagueDetails() ([]models.ESportsProLeagueDetail, error)
	// GetGodLeaderboard returns the current season's leaderboard for a god/queue. [SmiteAPI: only queues 440, 450, 451 apply]
	GetGodLeaderboard(godID, queueID string) ([]models.GodLeaderboardEntry, error)
	// GetLeagueLeaderboard returns the top players for a particular league.
	GetLeagueLeaderboard(queueID, tier, round string) ([]models.LeagueLeaderboardEntry, error)
	// GetLeagueSeasons returns a list of seasons for a match queue.
	GetLeagueSeasons(queueID string) ([]models.Season, error)
	// GetMOTD returns information about the 20 most recent Match-of-the-Days.
	GetMOTD() ([]models.MOTD, error)
	// GetTopMatches returns the 50 most watched / recorded matches.
	GetTopMatches() ([]models.TopMatch, error)
	// GetPatchInfo returns information about the currently deployed patch.
	GetPatchInfo() (*models.VersionInfo, error)

	// ===== Paladins =====
	// GetPlayerBatch returns league and other high level data for a particular list of players. [20 max]
	GetPlayerBatch(playerIDs []string) ([]models.Player, error)
	// GetChampionRanks returns the rank and worshipper values for each Champion a player has played.
	GetChampionRanks(player string) ([]models.ChampionRank, error)
	// GetChampions returns all Champions and their various attributes.
	GetChampions(langCode string) ([]models.Champion, error)
	// GetChampionLeaderboard returns the current season's leaderboard for a champion/queue. [ Only queue 428]
	GetChampionLeaderboard(champID string) ([]models.ChampionLeaderboardEntry, error)
	// GetChampionSkins
	GetChampionSkins(champID, langCode string) ([]models.ChampionSkin, error)
	// GetPlayerIDInfoForXBOXAndSwitch returns all PlayerID data associated with the playerName
	GetPlayerIDInfoForXBOXAndSwitch(player string) ([]models.PlayerIDInfoForXBOXAndSwitch, error)
	// GetPlayerLoadouts returns deck loadouts per Champion
	GetPlayerLoadouts(player, langCode string) ([]models.PlayerLoadout, error)
	// GetChampionCards returns all Champion cards
	GetChampionCards(champID, langCode string) ([]models.ChampionCard, error)
	// GetBountyItems returns daily Bounty Item history for the past 6 months.
	GetBountyItems() ([]models.BountyItem, error)
}

HiRezAPI is a collection of endpoint methods for interacting with the Hi-Rez API Definitions here are taken from the publicly available "Smite API Developer Guide" PDF

func New

func New(devID, key string, url MustBeURL, respType MustBeResponseType) (HiRezAPI, error)

New initializes a HiRezAPI instance with devID, auth key, url, and response type.

func NewWithSession

func NewWithSession(devID, key string, url URL, respType MustBeResponseType) (HiRezAPI, error)

NewWithSession is like New() but it also tests connectivity with Ping and initializes a session for you.

type MustBeResponseType

type MustBeResponseType interface {
	String() string
	IsResponseType() bool
}

MustBeResponseType exists to force the constructors to use our ResponseType type

type MustBeURL

type MustBeURL interface {
	String() string
	IsURL() bool
}

MustBeURL exists to force the constructors to use our URL type

type ResponseType

type ResponseType int

ResponseType determines the type of the Response body: JSON or XML

const (
	ResponseTypeJSON ResponseType = iota
	ResponseTypeXML
)

func (ResponseType) IsResponseType

func (r ResponseType) IsResponseType() bool

IsResponseType exists to satisfy the MustBeResponseType interface

func (ResponseType) String

func (r ResponseType) String() string

type URL

type URL int

URL determinmes the baseURL to use when calling Hi-Rez API endpoints

const (
	URLSmitePC URL = iota
	URLPaladinsPC
)

func (URL) IsURL

func (u URL) IsURL() bool

IsURL exists to satisfy the MustBeURL interface

func (URL) String

func (u URL) String() string

Jump to

Keyboard shortcuts

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