Crate hltv

source · []
Expand description

Documentation | Crates.io | Repository

A crate for fetching and parsing esports data from HLTV.org.

This crate allows you to fetch and parse upcoming matches, results, event information, player performance. This crate uses async calls via reqwest and parses the HTML document with tl. This API mimics the way you discover information on HLTV. Summary pages (like HLTV Matches) contains less information in the HTML document than the detailed match-specific page.

Currently, the following API calls are supported:

Examples

The builders in hltv allow you to build a generic Request object with a fetch method.

#[tokio::test]
async fn results() -> Result<(), hltv::Error> {
    let req = hltv::results()
        .map(Map::Inferno)
        .team(4608) // Team Na'Vi
        .year(2016) 
        .event_type(EventTypeFilter::Lan)
        .build();

    let matches = req.fetch().await?; // <-- this has type Vec<MatchResult>
    Ok(())
}

More examples

Find out if specific match is live

    let req = hltv::get_match(2346065);
    let m = req.fetch().await?;
    if m.status == hltv::data::MatchStatus::Live {
        println!("match with id:[{}] is live!", m.id);
    }

Get all upcoming matches for a team

Re-exports

pub use request::upcoming::upcoming;
pub use request::results::results;
pub use request::match_page::get_match;

Modules

Methods to convert HTML to HLTV data types.

Types for esports data from HLTV.

Structs

A reusable request object, that fetches, parses and converts HLTV data to the correct type.

Enums

Errors that happen during request, parse or conversion of data.

Traits

Implements a conversion from a DOM object to a collection of its own type.

Implements a conversion from a DOM object to a single instance of its own type.