Expand description
§league-link
An async Rust client for the League of Legends Client (LCU) API.
league-link provides three primitives:
- Credential discovery —
authenticate/try_find_lcu/try_find_lcu_async/try_find_lcu_via_lockfilelocate a running client and extract its local API port and auth token. - HTTP requests —
build_lcu_client+lcu_get/lcu_post/lcu_deleteissue typed requests against the local HTTPS server. - WebSocket events —
ws_connectorws_connect_filteredsubscribe to LCU events and deliver them through anEventStream.
§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;