Skip to main content

Crate league_link

Crate league_link 

Source
Expand description

An async Rust client for the League of Legends Client (LCU) API.

league-link provides three primitives:

  1. Credential discoveryauthenticate / try_find_lcu / try_find_lcu_async / try_find_lcu_via_lockfile locate a running client and extract its local API port and auth token.
  2. HTTP requestsbuild_lcu_client + lcu_get / lcu_post / lcu_delete issue typed requests against the local HTTPS server.
  3. WebSocket eventsws_connect or ws_connect_filtered subscribe to LCU events and deliver them through an EventStream.

§Example

use league_link::{authenticate, build_lcu_client, lcu_get, ws_connect};
use serde_json::Value;

// 1. Find the running client
let creds = authenticate(1000, 30).await?;

// 2. Make an HTTP call
let client = build_lcu_client()?;
let me: Value = lcu_get(&client, &creds, "/lol-summoner/v1/current-summoner").await?;
println!("summoner: {me}");

// 3. Watch live events
let mut stream = ws_connect(&creds, 128).await?;
while let Some(event) = stream.recv().await {
    println!("[{:?}] {}", event.event_type, event.uri);
}

Re-exports§

pub use auth::authenticate;
pub use auth::try_find_lcu;
pub use auth::try_find_lcu_async;
pub use auth::try_find_lcu_via_lockfile;
pub use auth::Credentials;
pub use error::LcuError;
pub use http::build_lcu_client;
pub use http::lcu_delete;
pub use http::lcu_get;
pub use http::lcu_post;
pub use http::lcu_request;
pub use http::lcu_request_with_body;
pub use http::parse_marketing_version;
pub use http::DEFAULT_TIMEOUT;
pub use websocket::connect as ws_connect;
pub use websocket::connect_filtered as ws_connect_filtered;
pub use websocket::EventStream;
pub use websocket::EventType;
pub use websocket::LcuEvent;

Modules§

auth
Discover LCU credentials from a running League Client.
error
Unified error type returned by every fallible operation in this crate.
http
HTTPS requests to the LCU REST API.
websocket
WebSocket client for the LCU event stream.