A sleek, easy-to-use wrapper for making API calls to Riot and DataDragon with built-in rate limiting
The Riot-API-Golang provides a simplified interface to access Riot Games and DataDragon APIs in Golang. It smoothly handles Riot's rate limiting, making your development experience hassle-free.
- 🚀 Simple to use
- 🧠 Intelligent rate limiting
- 🎮 Access to Riot Games and DataDragon APIs
go get github.com/junioryono/Riot-API-Golangcontinent continent.Continent, gameName, tagLine string
func main() {
apiKey := "RGAPI-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
client := apiclient.New(apiKey)
riotAccount, err := client.GetAccountByRiotID(continent.AMERICAS, "Mighty Junior", "NA1")
if err != nil {
panic(err)
}
matchlist, err := client.GetMatchlist(region.NA1.Continent(), riotAccount.Puuid, nil)
if err != nil {
panic(err)
}
matchID := (*matchlist)[0]
match, err := client.GetMatch(region.NA1.Continent(), matchID)
if err != nil {
panic(err)
}
fmt.Println(match.Info.GameCreation)
}func main() {
apiKey := "RGAPI-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
client := apiclient.New(apiKey)
riotAccount, err := client.GetAccountByRiotID(continent.AMERICAS, "Mighty Junior", "NA1")
if err != nil {
panic(err)
}
matchlist, err := client.WithContext(context.TODO()).GetMatchlist(region.NA1.Continent(), riotAccount.Puuid, nil)
if err != nil {
panic(err)
}
matchID := (*matchlist)[0]
match, err := client.WithContext(context.TODO()).GetMatch(region.NA1.Continent(), matchID)
if err != nil {
panic(err)
}
fmt.Println(match.Info.GameCreation)
}func main() {
patches, err := staticdata.GetPatches()
if err != nil {
panic(err)
}
currentPatch := patches.CurrentPatch()
champions, err := staticdata.GetChampions(currentPatch, language.EnglishUnitedStates)
if err != nil {
panic(err)
}
champ, err := champions.Champion("MonkeyKing")
if err != nil {
panic(err)
}
fmt.Println(champ.Blurb)
}Throttle the number of requests made to Riot's APIs. This is beneficial if a frontend portion of the application exists.
conservation := ratelimiter.ConserveUsage{
RegionPercent: 30,
MethodPercent: 30,
}
client.SetUsageConservation(conservation)Ignore limits for specific methods. The region's conservation percentage will still be followed.
conservation := ratelimiter.ConserveUsage{
RegionPercent: 30,
MethodPercent: 30,
IgnoreLimits: []ratelimiter.MethodID{
ratelimiter.GetLeagueEntriesChallenger,
ratelimiter.GetLeagueEntriesGrandmaster,
ratelimiter.GetLeagueEntriesMaster,
ratelimiter.GetLeagueEntries,
},
}
client.SetUsageConservation(conservation)How many times Riot API requests will be retried when unsuccessful. By default, requests will be retried indefinitely (-1).
client.SetMaxRetries(3)Interested in contributing to Riot-API-Golang? Check out the contributing guide to see how you can make an impact.
Riot-API-Golang is licensed under the MIT license. See the LICENSE file for more info.
If you encounter any issues or have questions, please file an issue on the GitHub issues page.