Struct riven::RiotApi

source ·
pub struct RiotApi { /* private fields */ }
Expand description

For retrieving data from the Riot Games API.

§Usage

Construct an instance using RiotApi::new(api_key or config). The parameter may be a Riot API key string or a RiotApiConfig. Riot API keys are obtained from the Riot Developer Portal and look like "RGAPI-01234567-89ab-cdef-0123-456789abcdef".

An instance provides access to “endpoint handles” which in turn provide access to individual API method calls. For example, to get a summoner by name we first access the summoner_v4() endpoints then call the get_by_summoner_name() method:

riot_api.summoner_v4().get_by_summoner_name(Region::NA, "LugnutsK")

§Rate Limiting

The Riot Game API enforces dynamic rate limiting, meaning that rate limits are specified in response headers and can change at any time. Riven keeps track of changing rate limits seamlessly, preventing you from getting blacklisted.

Riven’s rate limiting is highly efficient; it can use the full throughput of your rate limit without triggering 429 errors.

To adjust rate limiting, see RiotApiConfig and use RiotApi::new(config) to construct an instance.

Implementations§

source§

impl RiotApi

source

pub fn account_v1(&self) -> AccountV1<'_>

Returns a handle for accessing AccountV1 endpoints.

§Riot Developer API Reference

account-v1

Note: this method is automatically generated.

source

pub fn champion_mastery_v4(&self) -> ChampionMasteryV4<'_>

Returns a handle for accessing ChampionMasteryV4 endpoints.

§Riot Developer API Reference

champion-mastery-v4

Note: this method is automatically generated.

source

pub fn champion_v3(&self) -> ChampionV3<'_>

Returns a handle for accessing ChampionV3 endpoints.

§Riot Developer API Reference

champion-v3

Note: this method is automatically generated.

source

pub fn clash_v1(&self) -> ClashV1<'_>

Returns a handle for accessing ClashV1 endpoints.

§Riot Developer API Reference

clash-v1

Note: this method is automatically generated.

source

pub fn league_exp_v4(&self) -> LeagueExpV4<'_>

Returns a handle for accessing LeagueExpV4 endpoints.

§Riot Developer API Reference

league-exp-v4

Note: this method is automatically generated.

source

pub fn league_v4(&self) -> LeagueV4<'_>

Returns a handle for accessing LeagueV4 endpoints.

§Riot Developer API Reference

league-v4

Note: this method is automatically generated.

source

pub fn lol_challenges_v1(&self) -> LolChallengesV1<'_>

Returns a handle for accessing LolChallengesV1 endpoints.

§Riot Developer API Reference

lol-challenges-v1

Note: this method is automatically generated.

source

pub fn lol_status_v4(&self) -> LolStatusV4<'_>

Returns a handle for accessing LolStatusV4 endpoints.

§Riot Developer API Reference

lol-status-v4

Note: this method is automatically generated.

source

pub fn lor_deck_v1(&self) -> LorDeckV1<'_>

Returns a handle for accessing LorDeckV1 endpoints.

§Riot Developer API Reference

lor-deck-v1

Note: this method is automatically generated.

source

pub fn lor_inventory_v1(&self) -> LorInventoryV1<'_>

Returns a handle for accessing LorInventoryV1 endpoints.

§Riot Developer API Reference

lor-inventory-v1

Note: this method is automatically generated.

source

pub fn lor_match_v1(&self) -> LorMatchV1<'_>

Returns a handle for accessing LorMatchV1 endpoints.

§Riot Developer API Reference

lor-match-v1

Note: this method is automatically generated.

source

pub fn lor_ranked_v1(&self) -> LorRankedV1<'_>

Returns a handle for accessing LorRankedV1 endpoints.

§Riot Developer API Reference

lor-ranked-v1

Note: this method is automatically generated.

source

pub fn lor_status_v1(&self) -> LorStatusV1<'_>

Returns a handle for accessing LorStatusV1 endpoints.

§Riot Developer API Reference

lor-status-v1

Note: this method is automatically generated.

source

pub fn match_v5(&self) -> MatchV5<'_>

Returns a handle for accessing MatchV5 endpoints.

§Riot Developer API Reference

match-v5

Note: this method is automatically generated.

source

pub fn spectator_tft_v5(&self) -> SpectatorTftV5<'_>

Returns a handle for accessing SpectatorTftV5 endpoints.

§Riot Developer API Reference

spectator-tft-v5

Note: this method is automatically generated.

source

pub fn spectator_v5(&self) -> SpectatorV5<'_>

Returns a handle for accessing SpectatorV5 endpoints.

§Riot Developer API Reference

spectator-v5

Note: this method is automatically generated.

source

pub fn summoner_v4(&self) -> SummonerV4<'_>

Returns a handle for accessing SummonerV4 endpoints.

§Riot Developer API Reference

summoner-v4

Note: this method is automatically generated.

source

pub fn tft_league_v1(&self) -> TftLeagueV1<'_>

Returns a handle for accessing TftLeagueV1 endpoints.

§Riot Developer API Reference

tft-league-v1

Note: this method is automatically generated.

source

pub fn tft_match_v1(&self) -> TftMatchV1<'_>

Returns a handle for accessing TftMatchV1 endpoints.

§Riot Developer API Reference

tft-match-v1

Note: this method is automatically generated.

source

pub fn tft_status_v1(&self) -> TftStatusV1<'_>

Returns a handle for accessing TftStatusV1 endpoints.

§Riot Developer API Reference

tft-status-v1

Note: this method is automatically generated.

source

pub fn tft_summoner_v1(&self) -> TftSummonerV1<'_>

Returns a handle for accessing TftSummonerV1 endpoints.

§Riot Developer API Reference

tft-summoner-v1

Note: this method is automatically generated.

source

pub fn tournament_stub_v5(&self) -> TournamentStubV5<'_>

Returns a handle for accessing TournamentStubV5 endpoints.

§Riot Developer API Reference

tournament-stub-v5

Note: this method is automatically generated.

source

pub fn tournament_v5(&self) -> TournamentV5<'_>

Returns a handle for accessing TournamentV5 endpoints.

§Riot Developer API Reference

tournament-v5

Note: this method is automatically generated.

source

pub fn val_content_v1(&self) -> ValContentV1<'_>

Returns a handle for accessing ValContentV1 endpoints.

§Riot Developer API Reference

val-content-v1

Note: this method is automatically generated.

source

pub fn val_match_v1(&self) -> ValMatchV1<'_>

Returns a handle for accessing ValMatchV1 endpoints.

§Riot Developer API Reference

val-match-v1

Note: this method is automatically generated.

source

pub fn val_ranked_v1(&self) -> ValRankedV1<'_>

Returns a handle for accessing ValRankedV1 endpoints.

§Riot Developer API Reference

val-ranked-v1

Note: this method is automatically generated.

source

pub fn val_status_v1(&self) -> ValStatusV1<'_>

Returns a handle for accessing ValStatusV1 endpoints.

§Riot Developer API Reference

val-status-v1

Note: this method is automatically generated.

source§

impl RiotApi

source

pub fn new(config: impl Into<RiotApiConfig>) -> Self

Constructs a new instance from an API key (e.g. "RGAPI-01234567-89ab-cdef-0123-456789abcdef") or a RiotApiConfig.

source

pub fn request( &self, method: Method, region_platform: &str, path: &str, ) -> RequestBuilder

This method should generally not be used directly. Consider using endpoint wrappers instead.

Creates a RequestBuilder instance with the given parameters, for use with the execute*() methods.

§Parameters
  • method - The HTTP method for this request.
  • region_platform - The stringified platform, used to create the base URL.
  • path - The URL path, appended to the base URL.
source

pub async fn execute_val<'a, T: DeserializeOwned + 'a>( &'a self, method_id: &'static str, region_platform: &'static str, request: RequestBuilder, ) -> Result<T>

This method should generally not be used directly. Consider using endpoint wrappers instead.

This sends a request based on the given parameters and returns a parsed result.

§Parameters
  • method_id - A unique string id representing the endpoint method for per-method rate limiting.
  • region_platform - The stringified platform, used in rate limiting.
  • request - The request information. Use request() to obtain a RequestBuilder instance.
§Returns

A future resolving to a Result containg either a T (success) or a RiotApiError (failure).

source

pub async fn execute_opt<'a, T: DeserializeOwned + 'a>( &'a self, method_id: &'static str, region_platform: &'static str, request: RequestBuilder, ) -> Result<Option<T>>

This method should generally not be used directly. Consider using endpoint wrappers instead.

This sends a request based on the given parameters and returns an optional parsed result.

§Parameters
  • method_id - A unique string id representing the endpoint method for per-method rate limiting.
  • region_platform - The stringified platform, used in rate limiting.
  • request - The request information. Use request() to obtain a RequestBuilder instance.
§Returns

A future resolving to a Result containg either an Option<T> (success) or a RiotApiError (failure).

source

pub async fn execute( &self, method_id: &'static str, region_platform: &'static str, request: RequestBuilder, ) -> Result<()>

This method should generally not be used directly. Consider using endpoint wrappers instead.

This sends a request based on the given parameters but does not deserialize any response body.

§Parameters
  • method_id - A unique string id representing the endpoint method for per-method rate limiting.
  • region_platform - The stringified platform, used in rate limiting.
  • request - The request information. Use request() to obtain a RequestBuilder instance.
§Returns

A future resolving to a Result containg either () (success) or a RiotApiError (failure).

source

pub fn execute_raw( &self, method_id: &'static str, region_platform: &'static str, request: RequestBuilder, ) -> impl Future<Output = Result<ResponseInfo>> + '_

This method should generally not be used directly. Consider using endpoint wrappers instead.

This sends a request based on the given parameters and returns a raw ResponseInfo.

This can be used to implement a Riot API proxy without needing to deserialize and reserialize JSON responses.

§Parameters
  • method_id - A unique string id representing the endpoint method for per-method rate limiting.
  • region_platform - The stringified platform, used in rate limiting.
  • request - The request information. Use request() to obtain a RequestBuilder instance.
§Returns

A future resolving to a Result containg either a ResponseInfo (success) or a RiotApiError (failure).

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more