Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

CS2 API client. Cheap to clone; clones share one connection pool.

Implementations§

Source§

impl Client

Source

pub fn new(api_key: impl Into<String>) -> Result<Self, Error>

Creates a client with an explicit API key.

Source

pub fn from_env() -> Result<Self, Error>

Creates a client with the key from the CITO_API_KEY environment variable.

Source

pub fn builder() -> ClientBuilder

Starts a ClientBuilder to set the base URL or timeout.

Source

pub fn base_url(&self) -> &str

The base URL requests go to.

Source

pub fn timeout(&self) -> Duration

The request timeout.

Source

pub fn get_raw( &self, path: &str, query: &[(&str, &str)], ) -> Result<Value, Error>

Any endpoint. Returns the whole response envelope (success, data, meta).

Source

pub fn get(&self, path: &str, query: &[(&str, &str)]) -> Result<Value, Error>

Any endpoint. Returns data.

Source

pub fn live(&self) -> Result<Value, Error>

Every match being played now, with series score, current map and map score.

Source

pub fn live_scoreboard(&self, match_id: &str) -> Result<Value, Error>

Round-level scoreboard for one live match: sides, round, player K/D/ADR, money.

Source

pub fn upcoming(&self, limit: u32) -> Result<Value, Error>

Upcoming matches (the other clients default limit to 50).

Source

pub fn results(&self, limit: u32) -> Result<Value, Error>

Recent match results (the other clients default limit to 50).

Source

pub fn today(&self) -> Result<Value, Error>

Today’s matches.

Source

pub fn match_by_id(&self, match_id: &str) -> Result<Value, Error>

One match by id.

Source

pub fn match_(&self, match_id: &str) -> Result<Value, Error>

Source

pub fn match_maps(&self, match_id: &str) -> Result<Value, Error>

Per-map results for a match.

Source

pub fn match_player_stats(&self, match_id: &str) -> Result<Value, Error>

Player stats for a match.

Source

pub fn match_streams(&self, match_id: &str) -> Result<Value, Error>

Streams for a match.

Source

pub fn team(&self, team: &str) -> Result<Value, Error>

Team with roster and recent results. Accepts an id or a slug such as “vitality”.

Source

pub fn team_matches(&self, team: &str, limit: u32) -> Result<Value, Error>

A team’s matches (the other clients default limit to 20).

Source

pub fn team_stats(&self, team: &str) -> Result<Value, Error>

A team’s aggregate stats.

Source

pub fn team_map_stats(&self, team: &str) -> Result<Value, Error>

A team’s per-map stats.

Source

pub fn head_to_head(&self, team_a: &str, team_b: &str) -> Result<Value, Error>

Head-to-head record between two teams.

Source

pub fn player(&self, player: &str) -> Result<Value, Error>

Player profile. Accepts an id or a slug such as “donk”.

Source

pub fn search_players(&self, query: &str, limit: u32) -> Result<Value, Error>

Search players by name (the other clients default limit to 10).

Source

pub fn player_stats(&self, player: &str) -> Result<Value, Error>

A player’s stats.

Source

pub fn player_matches(&self, player: &str, limit: u32) -> Result<Value, Error>

A player’s matches (the other clients default limit to 20).

Source

pub fn events(&self, status: &str, limit: u32) -> Result<Value, Error>

status: “upcoming”, “live” or “recent” (anything else means “upcoming”).

Source

pub fn event(&self, event: &str) -> Result<Value, Error>

One event by id or slug.

Source

pub fn event_matches(&self, event: &str) -> Result<Value, Error>

An event’s matches.

Source

pub fn event_standings(&self, event: &str) -> Result<Value, Error>

An event’s standings.

Source

pub fn event_bracket(&self, event: &str) -> Result<Value, Error>

An event’s bracket.

Source

pub fn world_ranking(&self, limit: u32) -> Result<Value, Error>

World ranking (the other clients default limit to 30).

Source

pub fn vrs_ranking(&self, limit: u32) -> Result<Value, Error>

Valve Regional Standings.

Source

pub fn leaderboard(&self, metric: &str, limit: u32) -> Result<Value, Error>

metric: e.g. “rating”, “adr”, “kast”, “kd”, “kills”, “opening-kills”.

Source

pub fn transfers(&self, limit: u32) -> Result<Value, Error>

Recent roster transfers (the other clients default limit to 50).

Source

pub fn search(&self, query: &str) -> Result<Value, Error>

Teams, players, events and matches matching a name.

Source

pub fn search_skins( &self, query: Option<&str>, filters: &[(&str, &str)], ) -> Result<Value, Error>

Search one word at a time (“redline”), or pass filters such as [("weapon", "AK-47"), ("skin_name", "Redline")] for an exact skin.

Source

pub fn skin(&self, slug: &str) -> Result<Value, Error>

One skin by slug.

Source

pub fn skin_prices(&self, slug: &str) -> Result<Value, Error>

The skin’s price on every marketplace, with listing counts and buy links.

Source

pub fn skin_history( &self, slug: &str, range: Option<&str>, ) -> Result<Value, Error>

A skin’s price history, optionally limited to a range such as “30d”.

Source

pub fn trending_skins( &self, timeframe: &str, limit: u32, min_price: Option<f64>, ) -> Result<Value, Error>

Biggest movers: {"gainers": [...], "losers": [...]}. The other clients default to timeframe “7d” and limit 20.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.