equinox

package module
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: 15 Imported by: 1

README

equinox

WikiExampleTodoVersioning

Features

  • Riot APIs implemented:
    • Riot Account
    • League of Legends
    • Teamfight Tactics
    • Valorant
    • Legends of Runeterra
    • Riftbound
  • Rate limit
  • Caching with BigCache or Redis
  • Logging with zerolog
  • Retries with exponential backoff

[!NOTE] equinox currently uses the proposed jsonv2, read more about it here.

Check the Wiki for more information about the library.

Example

package main

import (
	"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
  • Add checks for duration in tests that include any WaitN/any blocking
  • Add more tests against the live Riot API
  • 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCache

func DefaultCache() (*cache.Cache, error)

Returns the default Cache.

BigCache with an eviction time of 4 minutes.

func DefaultConfig

func DefaultConfig(key string) api.EquinoxConfig

Returns the default equinox config.

Logger with zerolog.WarnLevel. Retry with a limit of 3 and jitter of 500 milliseconds.

func DefaultLogger

func DefaultLogger() api.Logger

Returns the default Logger config.

  • Level : zerolog.WarnLevel
  • Pretty : false
  • TimeFieldFormat : zerolog.TimeFormatUnix
  • EnableTimestamp : true
  • EnableConfigurationLogging : false

func DefaultRateLimit

func DefaultRateLimit() *ratelimit.RateLimit

Returns the default RateLimit.

  • StoreType : InternalRateLimit
  • LimitUsageFactor : 0.99
  • IntervalOverhead : 1 second

func DefaultRetry

func DefaultRetry() api.Retry

Returns the default Retry config.

  • MaxRetries : 3
  • Jitter : 500 milliseconds

Types

type Equinox

type Equinox struct {
	Internal  *internal.Client
	Cache     *cache.Cache
	RateLimit *ratelimit.RateLimit
	Riot      *riot.Client
	LOL       *lol.Client
	TFT       *tft.Client
	VAL       *val.Client
	LOR       *lor.Client
	Riftbound *riftbound.Client
}

func NewClient

func NewClient(key string) (*Equinox, error)

Returns an equinox client with the default configuration:

  • Key : The provided Riot API key.
  • HTTPClient : Default http.Client.
  • Cache : BigCache with a TTL of 4 minutes.
  • RateLimit : InternalRateLimit with a limit usage factor of 0.99 and interval overhead of 1 second.
  • Logger : Logger with zerolog.WarnLevel. Will log if rate limited or when retrying a request.
  • Retry : Will retry a request a maximum of 3 times with a jitter of 500 milliseconds.

func NewCustomClient

func NewCustomClient(config api.EquinoxConfig, httpClient *http.Client, cache *cache.Cache, rateLimit *ratelimit.RateLimit) (*Equinox, error)

Returns an equinox client using a custom configuration.

  • Config : The api.EquinoxConfig.
  • HTTPClient : Can be nil.
  • Cache : Can be nil.
  • RateLimit : Can be nil, only disable it if you know what you're doing.

Directories

Path Synopsis
Package used to share common constants and structs.
Package used to share common constants and structs.
Cache package to provide an interface to interact with cache stores.
Cache package to provide an interface to interact with cache stores.
clients
lol
This package is used to interact with all LOL endpoints.
This package is used to interact with all LOL endpoints.
lor
This package is used to interact with all LOR endpoints.
This package is used to interact with all LOR endpoints.
riftbound
This package is used to interact with all Riftbound endpoints.
This package is used to interact with all Riftbound endpoints.
riot
This package is used to interact with all Riot endpoints.
This package is used to interact with all Riot endpoints.
tft
This package is used to interact with all TFT endpoints.
This package is used to interact with all TFT endpoints.
val
This package is used to interact with all VAL endpoints.
This package is used to interact with all VAL endpoints.
test
integration
This package only contains integration tests and are meant to be run manually.
This package only contains integration tests and are meant to be run manually.

Jump to

Keyboard shortcuts

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