class RLS::Client

Overview

The client is the main utility for interacting with the RLS API. It abstracts your API key and caches certain hot API routes. See the REST module for a full description of the API.

client = RLS::Client.new("API_KEY")
puts client.player("76561198034606292") # => RLS::Player

By default, caching is enabled and is handled in memory with a collection of hashes. Cached objects have set expiry rules, and once objects expire the client will perform an HTTP request to update the cache.

If you want to disable caching:

client.player_cache = nil
client.leaderboard_cache = nil

Included Modules

Defined in:

rls/client.cr

Constructors

Instance Method Summary

Instance methods inherited from module RLS::REST

leaderboard(playlist : RankedPlaylist)
leaderboard(type : StatType)
leaderboard
, platforms platforms, player(id : String, platform : Platform = Platform::Steam) player, players(query : Array(BatchPlayersPayload))
players(*query)
players
, playlists playlists, request(method : String, path : String, headers : HTTP::Headers = HTTP::Headers.new, body : String | Nil = nil) request, search(display_name : String, page : UInt32 = 0_u32) search, seasons seasons, tiers tiers

Constructor Detail

def self.new(key : String) #

[View source]

Instance Method Detail

def leaderboard(playlist : REST::RankedPlaylist) #

Retrieves an array of 100 players sorted by their current season rating

If the #leaderboard_cache is present, it will be used to immediately return a leaderboard, or perform an API request on a cache miss


[View source]
def leaderboard(type : REST::StatType) #

Retrieves an array of 100 players sorted by their specified stat amount

If the #leaderboard_cache is present, it will be used to immediately return a leaderboard, or perform an API request on a cache miss


[View source]
def leaderboard_cache : Memory::Leaderboard | Nil #

Cache for leaderboards, which are arrays of Player objects


[View source]
def leaderboard_cache=(leaderboard_cache : Memory::Leaderboard | Nil) #

Cache for leaderboards, which are arrays of Player objects


[View source]
def player(id : String, platform : Platform = Platform::Steam) #

Retrieves a single player by ID and Platform. ID is a Steam ID, PSN username, Xbox Gamertag, or Xbox XUID.

If the #player_cache is present, it will be used to return cached players immediately, or perform an API request on a cache miss.


[View source]
def player_cache : Memory::Player | Nil #

Cache for Player objects


[View source]
def player_cache=(player_cache : Memory::Player | Nil) #

Cache for Player objects


[View source]
def players(query : Array(REST::BatchPlayersPayload)) #

Fetch up to 10 players with one request. See BatchPlayersPayload

If the #player_cache is present, it will be used to return cached players immediately, or perform an API request on a cache miss.


[View source]