valorant

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
const BaseURL = "https://valorant-api.com/v1"

BaseURL is the root every request is built from.

View Source
const DefaultLanguage = "en-US"

DefaultLanguage is the language tag sent to the API.

View Source
const DefaultUserAgent = "valorant-cli/0.1 (tamnd87@gmail.com)"

DefaultUserAgent identifies the client to valorant-api.com.

View Source
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 NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) Agents

func (c *Client) Agents(ctx context.Context, all bool) ([]*Agent, error)

Agents fetches playable agents. If all is true, include non-playable ones too.

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)

Get fetches rawURL and returns the response body. It paces and retries according to the client's settings.

func (*Client) Maps

func (c *Client) Maps(ctx context.Context) ([]*Map, error)

Maps fetches all maps.

func (*Client) Ranks

func (c *Client) Ranks(ctx context.Context) ([]*Rank, error)

Ranks fetches competitive rank tiers from the most recent episode.

func (*Client) Weapons

func (c *Client) Weapons(ctx context.Context, category string) ([]*Weapon, error)

Weapons fetches all weapons. Pass category="" to get all.

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

func (Domain) Classify(input string) (uriType, id string, err error)

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

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.

Jump to

Keyboard shortcuts

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