#f1 #racing #async-client #api-client #query-api #formula1 #ergast

ergast-rs

An async client for getting Formula 1 schedules, qualifying, and race results powered by the Ergast API

5 unstable releases

0.3.2 Dec 15, 2022
0.3.1 Dec 15, 2022
0.2.1 Jun 26, 2022
0.1.0 Jun 26, 2022

#1048 in Web programming

33 downloads per month

MIT license

41KB
896 lines

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?;

Dependencies

~5–18MB
~262K SLoC