api

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 4 Imported by: 7

Documentation

Overview

Package used to share common constants and structs.

Index

Constants

View Source
const (
	RIOT_API_BASE_URL_FORMAT = ".api.riotgames.com"
)

Base Riot API URLs formats.

Variables

View Source
var (
	ErrBadRequest           = errors.New("bad request")
	ErrUnauthorized         = errors.New("unauthorized")
	ErrForbidden            = errors.New("forbidden")
	ErrNotFound             = errors.New("not found")
	ErrMethodNotAllowed     = errors.New("method not allowed")
	ErrUnsupportedMediaType = errors.New("unsupported media type")
	ErrTooManyRequests      = errors.New("too many requests")
	ErrInternalServer       = errors.New("internal server error")
	ErrBadGateway           = errors.New("bad gateway")
	ErrServiceUnavailable   = errors.New("service unavailable")
	ErrGatewayTimeout       = errors.New("gateway timeout")
)
View Source
var (
	// A slice containing all endpoints from the Riot API.
	AllEndpoints = [][]string{
		{"GET", "/riot/account/v1/region/by-game/{game}/by-puuid/{puuid}", "account-v1.getActiveRegion"},
		{"GET", "/riot/account/v1/active-shards/by-game/{game}/by-puuid/{puuid}", "account-v1.getActiveShard"},
		{"GET", "/riot/account/v1/accounts/me", "account-v1.getByAccessToken"},
		{"GET", "/riot/account/v1/accounts/by-puuid/{puuid}", "account-v1.getByPuuid"},
		{"GET", "/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}", "account-v1.getByRiotId"},
		{"GET", "/lol/champion-mastery/v4/champion-masteries/by-puuid/{encryptedPUUID}", "champion-mastery-v4.getAllChampionMasteriesByPUUID"},
		{"GET", "/lol/champion-mastery/v4/champion-masteries/by-puuid/{encryptedPUUID}/by-champion/{championId}", "champion-mastery-v4.getChampionMasteryByPUUID"},
		{"GET", "/lol/champion-mastery/v4/scores/by-puuid/{encryptedPUUID}", "champion-mastery-v4.getChampionMasteryScoreByPUUID"},
		{"GET", "/lol/champion-mastery/v4/champion-masteries/by-puuid/{encryptedPUUID}/top", "champion-mastery-v4.getTopChampionMasteriesByPUUID"},
		{"GET", "/lol/platform/v3/champion-rotations", "champion-v3.getChampionInfo"},
		{"GET", "/lol/clash/v1/players/by-puuid/{puuid}", "clash-v1.getPlayersByPUUID"},
		{"GET", "/lol/clash/v1/teams/{teamId}", "clash-v1.getTeamById"},
		{"GET", "/lol/clash/v1/tournaments/{tournamentId}", "clash-v1.getTournamentById"},
		{"GET", "/lol/clash/v1/tournaments/by-team/{teamId}", "clash-v1.getTournamentByTeam"},
		{"GET", "/lol/clash/v1/tournaments", "clash-v1.getTournaments"},
		{"GET", "/lol/league-exp/v4/entries/{queue}/{tier}/{division}", "league-exp-v4.getLeagueEntries"},
		{"GET", "/lol/league/v4/challengerleagues/by-queue/{queue}", "league-v4.getChallengerLeague"},
		{"GET", "/lol/league/v4/grandmasterleagues/by-queue/{queue}", "league-v4.getGrandmasterLeague"},
		{"GET", "/lol/league/v4/leagues/{leagueId}", "league-v4.getLeagueById"},
		{"GET", "/lol/league/v4/entries/{queue}/{tier}/{division}", "league-v4.getLeagueEntries"},
		{"GET", "/lol/league/v4/entries/by-puuid/{encryptedPUUID}", "league-v4.getLeagueEntriesByPUUID"},
		{"GET", "/lol/league/v4/masterleagues/by-queue/{queue}", "league-v4.getMasterLeague"},
		{"GET", "/lol/challenges/v1/challenges/config", "lol-challenges-v1.getAllChallengeConfigs"},
		{"GET", "/lol/challenges/v1/challenges/percentiles", "lol-challenges-v1.getAllChallengePercentiles"},
		{"GET", "/lol/challenges/v1/challenges/{challengeId}/config", "lol-challenges-v1.getChallengeConfigs"},
		{"GET", "/lol/challenges/v1/challenges/{challengeId}/leaderboards/by-level/{level}", "lol-challenges-v1.getChallengeLeaderboards"},
		{"GET", "/lol/challenges/v1/challenges/{challengeId}/percentiles", "lol-challenges-v1.getChallengePercentiles"},
		{"GET", "/lol/challenges/v1/player-data/{puuid}", "lol-challenges-v1.getPlayerData"},
		{"GET", "/lol/rso-match/v1/matches/{matchId}", "lol-rso-match-v1.getMatch"},
		{"GET", "/lol/rso-match/v1/matches/ids", "lol-rso-match-v1.getMatchIds"},
		{"GET", "/lol/rso-match/v1/matches/{matchId}/timeline", "lol-rso-match-v1.getTimeline"},
		{"GET", "/lol/status/v4/platform-data", "lol-status-v4.getPlatformData"},
		{"POST", "/lor/deck/v1/decks/me", "lor-deck-v1.createDeck"},
		{"GET", "/lor/deck/v1/decks/me", "lor-deck-v1.getDecks"},
		{"GET", "/lor/inventory/v1/cards/me", "lor-inventory-v1.getCards"},
		{"GET", "/lor/match/v1/matches/{matchId}", "lor-match-v1.getMatch"},
		{"GET", "/lor/match/v1/matches/by-puuid/{puuid}/ids", "lor-match-v1.getMatchIdsByPUUID"},
		{"GET", "/lor/ranked/v1/leaderboards", "lor-ranked-v1.getLeaderboards"},
		{"GET", "/lor/status/v1/platform-data", "lor-status-v1.getPlatformData"},
		{"GET", "/lol/match/v5/matches/{matchId}", "match-v5.getMatch"},
		{"GET", "/lol/match/v5/matches/by-puuid/{puuid}/ids", "match-v5.getMatchIdsByPUUID"},
		{"GET", "/lol/match/v5/matches/by-puuid/{puuid}/replays", "match-v5.getReplay"},
		{"GET", "/lol/match/v5/matches/{matchId}/timeline", "match-v5.getTimeline"},
		{"GET", "/riftbound/content/v1/contents", "riftbound-content-v1.getContent"},
		{"GET", "/lol/spectator/tft/v5/active-games/by-puuid/{encryptedPUUID}", "spectator-tft-v5.getCurrentGameInfoByPuuid"},
		{"GET", "/lol/spectator/v5/active-games/by-summoner/{encryptedPUUID}", "spectator-v5.getCurrentGameInfoByPuuid"},
		{"GET", "/lol/summoner/v4/summoners/me", "summoner-v4.getByAccessToken"},
		{"GET", "/lol/summoner/v4/summoners/by-puuid/{encryptedPUUID}", "summoner-v4.getByPUUID"},
		{"GET", "/tft/league/v1/challenger", "tft-league-v1.getChallengerLeague"},
		{"GET", "/tft/league/v1/grandmaster", "tft-league-v1.getGrandmasterLeague"},
		{"GET", "/tft/league/v1/leagues/{leagueId}", "tft-league-v1.getLeagueById"},
		{"GET", "/tft/league/v1/entries/{tier}/{division}", "tft-league-v1.getLeagueEntries"},
		{"GET", "/tft/league/v1/by-puuid/{puuid}", "tft-league-v1.getLeagueEntriesByPUUID"},
		{"GET", "/tft/league/v1/master", "tft-league-v1.getMasterLeague"},
		{"GET", "/tft/league/v1/rated-ladders/{queue}/top", "tft-league-v1.getTopRatedLadder"},
		{"GET", "/tft/match/v1/matches/{matchId}", "tft-match-v1.getMatch"},
		{"GET", "/tft/match/v1/matches/by-puuid/{puuid}/ids", "tft-match-v1.getMatchIdsByPUUID"},
		{"GET", "/tft/status/v1/platform-data", "tft-status-v1.getPlatformData"},
		{"GET", "/tft/summoner/v1/summoners/me", "tft-summoner-v1.getByAccessToken"},
		{"GET", "/tft/summoner/v1/summoners/by-puuid/{encryptedPUUID}", "tft-summoner-v1.getByPUUID"},
		{"POST", "/lol/tournament-stub/v5/codes", "tournament-stub-v5.createTournamentCode"},
		{"GET", "/lol/tournament-stub/v5/lobby-events/by-code/{tournamentCode}", "tournament-stub-v5.getLobbyEventsByCode"},
		{"GET", "/lol/tournament-stub/v5/codes/{tournamentCode}", "tournament-stub-v5.getTournamentCode"},
		{"POST", "/lol/tournament-stub/v5/providers", "tournament-stub-v5.registerProviderData"},
		{"POST", "/lol/tournament-stub/v5/tournaments", "tournament-stub-v5.registerTournament"},
		{"POST", "/lol/tournament/v5/codes", "tournament-v5.createTournamentCode"},
		{"GET", "/lol/tournament/v5/games/by-code/{tournamentCode}", "tournament-v5.getGames"},
		{"GET", "/lol/tournament/v5/lobby-events/by-code/{tournamentCode}", "tournament-v5.getLobbyEventsByCode"},
		{"GET", "/lol/tournament/v5/codes/{tournamentCode}", "tournament-v5.getTournamentCode"},
		{"POST", "/lol/tournament/v5/providers", "tournament-v5.registerProviderData"},
		{"POST", "/lol/tournament/v5/tournaments", "tournament-v5.registerTournament"},
		{"PUT", "/lol/tournament/v5/codes/{tournamentCode}", "tournament-v5.updateCode"},
		{"GET", "/val/match/console/v1/matches/{matchId}", "val-console-match-v1.getMatch"},
		{"GET", "/val/match/console/v1/matchlists/by-puuid/{puuid}", "val-console-match-v1.getMatchlist"},
		{"GET", "/val/match/console/v1/recent-matches/by-queue/{queue}", "val-console-match-v1.getRecent"},
		{"GET", "/val/console/ranked/v1/leaderboards/by-act/{actId}", "val-console-ranked-v1.getLeaderboard"},
		{"GET", "/val/content/v1/contents", "val-content-v1.getContent"},
		{"GET", "/val/match/v1/matches/{matchId}", "val-match-v1.getMatch"},
		{"GET", "/val/match/v1/matchlists/by-puuid/{puuid}", "val-match-v1.getMatchlist"},
		{"GET", "/val/match/v1/recent-matches/by-queue/{queue}", "val-match-v1.getRecent"},
		{"GET", "/val/ranked/v1/leaderboards/by-act/{actId}", "val-ranked-v1.getLeaderboard"},
		{"GET", "/val/status/v1/platform-data", "val-status-v1.getPlatformData"},
	}
)

Functions

func StatusCodeToError

func StatusCodeToError(statusCode int) error

Types

type EquinoxConfig

type EquinoxConfig struct {
	// Riot API Key.
	Key string
	// Log Level, Pretty print, Timestamp logging, etc.
	Logger Logger
	// Maximum number of retries, Jitter.
	Retry Retry
}

Configuration for the equinox client.

type EquinoxRequest

type EquinoxRequest struct {
	Logger   zerolog.Logger
	Request  *http.Request
	URL      string
	Route    string
	MethodID string
}

Contains the *http.Request to the Riot API and all necessary information about it.

type ExecuteOptions

type ExecuteOptions bool

Options to be used when executing requests.

const (
	// Skips checking the cache then updates the cache with new data.
	Revalidate ExecuteOptions = true
)

type Logger

type Logger struct {
	TimeFieldFormat string
	Level           zerolog.Level
	// Enables prettified logging.
	Pretty bool
	// Prints the timestamp.
	EnableTimestamp bool
	// Will log cache, rate limit and retry configuration, might be useful for debugging.
	EnableConfigurationLogging bool
}

Logger configuration object.

type RegionalRoute

type RegionalRoute string

Regional routes, used in tournament services, Legends of Runeterra, and some other endpoints.

const (
	// North and South America.
	AMERICAS RegionalRoute = "americas"
	// # Deprecated
	//
	// Asia-Pacific, deprecated, for some old matches in `lor-match-v1`.
	APAC RegionalRoute = "apac"
	// Asia, used for LoL matches (`match-v5`) and TFT matches (`tft-match-v1`).
	ASIA RegionalRoute = "asia"
	// Special esports platform for `account-v1`. Do not confuse with the `esports` Valorant platform route.
	ESPORTS RegionalRoute = "esports"
	// Special Europe esports platform for `account-v1`. Do not confuse with the `esports` Valorant platform route.
	ESPORTSEU RegionalRoute = "esportseu"
	// Europe.
	EUROPE RegionalRoute = "europe"
	// South East Asia, used for LoR, LoL matches (`match-v5`), and TFT matches (`tft-match-v1`).
	SEA RegionalRoute = "sea"
)

func (RegionalRoute) String

func (route RegionalRoute) String() string

type Retry

type Retry struct {
	// Maximum number of retries, 0 disables retries.
	MaxRetries int
	// Jitter, in milliseconds, added to the retry interval.
	Jitter time.Duration
}

Retry configuration object.

Retries have a exponential backoff mechanism.

Jump to

Keyboard shortcuts

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