Documentation
¶
Overview ¶
Package valorant is the library behind the valorant command line: the HTTP client, request shaping, and the typed data models for the valorant-api.com static game data API.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.
Index ¶
- Constants
- type Agent
- type Client
- func (c *Client) Agents(ctx context.Context, all bool) ([]*Agent, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) Maps(ctx context.Context) ([]*Map, error)
- func (c *Client) Ranks(ctx context.Context) ([]*Rank, error)
- func (c *Client) Weapons(ctx context.Context, category string) ([]*Weapon, error)
- type Domain
- type Map
- type Rank
- type Weapon
Constants ¶
const BaseURL = "https://valorant-api.com/v1"
BaseURL is the root every request is built from.
const DefaultLanguage = "en-US"
DefaultLanguage is the language tag sent to the API.
const DefaultUserAgent = "valorant-cli/0.1 (tamnd87@gmail.com)"
DefaultUserAgent identifies the client to valorant-api.com.
const Host = "valorant-api.com"
Host is the API hostname this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
UUID string `kit:"id" json:"uuid" table:"uuid"`
Name string `json:"name" table:"name"`
Role string `json:"role" table:"role"`
Description string `json:"description" table:"-"`
Abilities string `json:"abilities" table:"abilities"`
}
Agent is a playable agent (character) in VALORANT.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
Language string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to valorant-api.com over HTTP.
func (*Client) Agents ¶
Agents fetches playable agents. If all is true, include non-playable ones too.
func (*Client) Get ¶
Get fetches rawURL and returns the response body. It paces and retries according to the client's settings.
type Domain ¶
type Domain struct{}
Domain is the valorant driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify is required by the kit.Domain interface. Since valorant-api.com URIs are not addressable like web pages (there are no stable resource paths users copy-paste), we return a minimal implementation that at least handles the scheme itself.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Map ¶
type Map struct {
UUID string `kit:"id" json:"uuid" table:"uuid"`
Name string `json:"name" table:"name"`
TacticalDescription string `json:"tactical_description" table:"tactical_description"`
Coordinates string `json:"coordinates" table:"coordinates"`
}
Map is a playable map in VALORANT.
type Rank ¶
type Rank struct {
Tier int `kit:"id" json:"tier" table:"tier"`
Name string `json:"name" table:"name"`
Division string `json:"division" table:"division"`
}
Rank is a competitive rank tier in VALORANT.
type Weapon ¶
type Weapon struct {
UUID string `kit:"id" json:"uuid" table:"uuid"`
Name string `json:"name" table:"name"`
Category string `json:"category" table:"category"`
Cost int `json:"cost" table:"cost"`
FireRate float64 `json:"fire_rate" table:"fire_rate"`
MagSize int `json:"mag_size" table:"mag_size"`
ReloadTime float64 `json:"reload_time" table:"reload_time"`
}
Weapon is a weapon available in VALORANT.