ergast-rs

Crates.ioergast-rs
lib.rsergast-rs
version0.3.2
sourcesrc
created_at2022-06-26 12:30:38.189685
updated_at2022-12-15 19:45:01.934255
descriptionAn async client for getting Formula 1 schedules, qualifying, and race results powered by the Ergast API
homepage
repository
max_upload_size
id613522
size89,602
Pato Lankenau (pato)

documentation

README

Ergast-rs: your one stop shop for Formula 1 (F1) results and schedules

This project introduces an Ergast trait and the main implementation in ErgastClient which can be used to query the Ergast API.

To query the API you can either use the RequestBuilder or directly provide the URL as a string to the client. If you are providing your own request string, do not forget to append .json to the query string, otherwise the lib is unable to parse the response.

The client provide some pre-built methods to query

  • race schedule
  • qualifying results
  • sprint qualifying results
  • race results

Example usage

Get the last race's results

let client = ErgastClient::new()?;
let race_results = client
    .race_results(None, None)
    .await?;

Get the race schedule for 2020

let client = ErgastClient::new()?;
let races = client
    .schedule(Some(2020))
    .await?;

Get the qualifying results of the season opener in 2019 via the RequestBuilder

let request = RequestBuilder::new()
    .query(RequestType::QualifyingResult)
    .add_parameter(RequestParameter::Season(2019))
    .add_parameter(RequestParameter::Round(1))
    .build();

let client = ErgastClient::new()?;
let qualifying = client
    .query(request)
    .await?;
Commit count: 0

cargo fmt