https://github.com/kyagara/equinox
Library for all Riot Games APIs written in Golang.
https://github.com/kyagara/equinox
bigcache cache code-generation golang league-of-legends legends-of-runeterra logging rate-limit redis riot-games-api rso teamfight-tactics valorant
Last synced: 5 months ago
JSON representation
Library for all Riot Games APIs written in Golang.
- Host: GitHub
- URL: https://github.com/kyagara/equinox
- Owner: Kyagara
- License: mit
- Created: 2022-04-23T22:33:21.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-26T20:00:12.000Z (8 months ago)
- Last Synced: 2024-11-16T09:33:54.588Z (5 months ago)
- Topics: bigcache, cache, code-generation, golang, league-of-legends, legends-of-runeterra, logging, rate-limit, redis, riot-games-api, rso, teamfight-tactics, valorant
- Language: Go
- Homepage: https://pkg.go.dev/github.com/Kyagara/equinox/v2
- Size: 4.62 MB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## Features
- Riot APIs implemented:
- Riot Account
- League of Legends
- Teamfight Tactics
- Valorant
- Legends of Runeterra
- Rate limit (Internal)
- Caching with [BigCache](https://github.com/allegro/bigcache) or [Redis](https://github.com/go-redis/redis)
- Logging with [zerolog](https://github.com/rs/zerolog)
- Exponential backoff> [!NOTE]
> equinox currently uses the proposed [jsonv2](https://github.com/go-json-experiment/json), read more about it [here](https://github.com/golang/go/discussions/63397).Check the [Wiki](https://github.com/Kyagara/equinox/wiki) for more information about the library.
## Example
> For a slightly more advanced example, check out [lol-match-crawler](https://github.com/Kyagara/lol-match-crawler).
```go
package mainimport (
"fmt""github.com/Kyagara/equinox/v2/"
"github.com/Kyagara/equinox/v2/clients/lol"
)func main() {
client, err := equinox.NewClient("RIOT_API_KEY")
if err != nil {
fmt.Println("error creating client: ", err)
return
}
// Get this week's champion rotation.
ctx := context.Background()
rotation, err := client.LOL.ChampionV3.Rotation(ctx, lol.BR1)
if err != nil {
fmt.Println("error retrieving champion rotation: ", err)
return
}
fmt.Printf("%+v\n", rotation)
// &{FreeChampionIDs:[17 43 56 62 67 79 85 90 133 145 147 157 201 203 245 518]
// FreeChampionIDsForNewPlayers:[222 254 427 82 131 147 54 17 18 37]
// MaxNewPlayerLevel:10}
}
```## Todo
- Maybe the context usage throughout the project could be improved
- Maybe add and move `Logger` to the `Cache` and `RateLimit` interfaces
- Maybe endpoint methods `int32`/`int64` parameters should be changed to just `int`
- Add checks for duration of tests that include any WaitN/any blocking
- Add more integration tests
- RateLimit
- Add Redis store, using a lua script
- Maybe add more options (presets?) to customize the rate limiter
- Try to reduce amount of method arguments## Versioning
Breaking changes in the library itself (removal/rename of methods from `InternalClient`/`Cache`/`RateLimit`) will require a major version (n.x.x) bump, fixes will occur in a patch (x.x.n).
The Riot API does not follow semver and changes often, breaking changes such as removal of endpoints methods or even entire endpoints will require a **minor** version (x.n.x) bump.
In `go`, new major versions of a library are an annoyance, requiring adding/changing **every** import path to the new version, so I want to keep them to a minimum. For example, `github.com/Kyagara/equinox/internal/client` will be `github.com/Kyagara/equinox/v2/internal/client`, then `github.com/Kyagara/equinox/v3/internal/client`...
Older versions are not supported (versions before v1 are outright broken and shouldn't be used), always keep the library up-to-date with the latest version.
## Disclaimer
equinox isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc.