openf1

package
v0.0.0-...-44fb2c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2025 License: 0BSD Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValuesBetween

func ValuesBetween[T any](filter T, fieldName, min, max string, extrmeIncluded bool) (string, error)

valuesBetween takes a generic filter struct and returns a query string representing a range condition for a specific field.

Parameters:

  • filter: A struct of any type T representing the filter (e.g., CarDataFilter{}, DriverFilter{}).
  • fieldName: The name (case sensitive) of the struct field to filter on (e.g., "DriverNumber").
  • min: The lower bound of the range.
  • max: The upper bound of the range.
  • extrmeIncluded: A boolean indicating whether the range endpoints are inclusive.

Returns:

  • A string representing the range condition (e.g., "DriverNumber>=1&DriverNumber<=3").
  • An error if the field does not exist or cannot be accessed.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Driver

func (c *Client) Driver(filter types.DriverFilter) ([]types.Driver, error)

Driver retrieves driver informations based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) DriverFastestLap

func (c *Client) DriverFastestLap(sessionKey string, driverNumber int) (types.Lap, error)

DriverFastestLap retrieves the fastest lap of the given driver in the specified session.

func (*Client) DriverFastestLapTelemetry

func (c *Client) DriverFastestLapTelemetry(sessionKey string, driverNumber int) ([]types.CarData, error)

func (*Client) DriverNumbersBySession

func (c *Client) DriverNumbersBySession(sessionKey string) ([]int, error)

DriverNumbersBySession returns a slice of driver numbers who participated in the specified session. Only the numeric driver identifiers are returned, not full driver details.

func (*Client) DriverStints

func (c *Client) DriverStints(sessionKey string, driverNumber int) ([]types.Stint, error)

DriverStints returns a list of stints for the specified driver in the given session.

func (*Client) FiaComunications

func (c *Client) FiaComunications(sessionKey string) ([]types.RaceControl, error)

FIACommunications retrieves all race control events related to FIA communications for the specified session key, such as investigations, track conditions, lap time deletions during qualifying, etc.

func (*Client) Flag

func (c *Client) Flag(flagColor, sessionKey string) ([]types.RaceControl, error)

Flag retrieves race control flag events for a specified flag color and session key.

func (*Client) GetSessionKey

func (c *Client) GetSessionKey(cityName, sessionName, year string) (int, error)

The sessionName combinations vary depending on the Grand Prix format. Note: The query is case-sensitive.

Classic GP | Sprint GP -----------|------------------- Practice 1 | Practice 1 Practice 2 | Sprint Qualifying Practice 3 | Sprint Qualifying | Qualifying Race | Race

func (*Client) Intervals

func (c *Client) Intervals(filter types.IntervalFilter) ([]types.Interval, error)

Intervals retrieves the gap to leader and driver ahead data based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) LappedDrivers

func (c *Client) LappedDrivers(sessionKey string) ([]types.Driver, error)

LappedDrivers returns information about lapped drivers for the given session key.

func (*Client) Laps

func (c *Client) Laps(filter types.LapFilter) ([]types.Lap, error)

Laps retrieves laps data based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) Location

func (c *Client) Location(filter types.LocationFilter) ([]types.Location, error)

Location retrieves The approximate location of the cars on the circuit data based on the given user filter, at a sample rate of about 3.7 Hz. Useful for gauging their progress along the track, but lacks details about lateral placement — i.e. whether the car is on the left or right side of the track. The origin point (0, 0, 0) appears to be arbitrary and not tied to any specific location on the track. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) LocationByLap

func (c *Client) LocationByLap(sessionKey, lap string, driverNumber int) ([]types.Location, error)

func (*Client) Meetings

func (c *Client) Meetings(filter types.MeetingFilter) ([]types.Meeting, error)

Meetings retrieves meetings data based on the given user filter. A meeting refers to a Grand Prix or testing weekend and usually includes multiple sessions (practice, qualifying, race, ...). An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) Overtakes

func (c *Client) Overtakes(filter types.OvertakeFilter) ([]types.Overtake, error)

As reported in the openf1 api, this is a BETA endpoint. This data is only available during races and may be incomplete. Overtakes retrieves overtakes data based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) Pit

func (c *Client) Pit(filter types.PitFilter) ([]types.Pit, error)

Pits retrieves pits data based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) Position

func (c *Client) Position(filter types.PositionFilter) ([]types.Position, error)

Position retrieves driver positions throughout a session, including initial placement and subsequent changes based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) QualifyingResult

func (c *Client) QualifyingResult(cityName, year string, isSprintRace bool) ([]types.SessionResult, error)

func (*Client) RaceControl

func (c *Client) RaceControl(filter types.RaceControlFilter) ([]types.RaceControl, error)

RaceControl retrieves race control data based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) RaceResult

func (c *Client) RaceResult(cityName, year string, isSprintRace bool) ([]types.SessionResult, error)

func (*Client) RainySessionsForYear

func (c *Client) RainySessionsForYear(year int) ([]types.Session, error)

RainySessionsForYear retrieves all the sessions that experienced rain during the specified year.

func (*Client) SafetyCar

func (c *Client) SafetyCar(sessionKey string) ([]types.RaceControl, error)

SafetyCar retrieves all race control events related to the safety car for the specified session key. The message field specifies whether it is a virtual safety car or not.

func (*Client) SessionFastestLap

func (c *Client) SessionFastestLap(sessionKey string) (types.Lap, error)

SessionFastestLap retrieves the fastest lap in the specified session.

func (*Client) SessionResult

func (c *Client) SessionResult(filter types.SessionResultFilter) ([]types.SessionResult, error)

As reported in the openf1 api, this is a BETA endpoint SessionResult retrieves standings after a session based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) Sessions

func (c *Client) Sessions(filter types.SessionFilter) ([]types.Session, error)

Sessions retrieves sessions data based on the given user filter. A session refers to a distinct period of track activity during a Grand Prix or testing weekend (practice, qualifying, sprint, race, ...) An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) SetAPIVersion

func (c *Client) SetAPIVersion(version string)

SetAPIVersion sets the version of the OpenF1 API to use (e.g. "v1")

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(hc *http.Client)

SetHTTPClient allows user to provide their own http.Client

func (*Client) SetPath

func (c *Client) SetPath(path string)

SetPath sets the specific API path (e.g. "/car_data") to be appended to the base URL

func (*Client) StartingCompound

func (c *Client) StartingCompound(sessionKey string) ([]types.Stint, error)

StartingCompound returns the starting tyre compound for each driver in the grid for the specified session. By checking TyreAgeAtStart, you can identify drivers who started with fresh tyres.

func (*Client) StartingGrid

func (c *Client) StartingGrid(filter types.StartingGridFilter) ([]types.StartingGrid, error)

As reported in the openf1 api, this is a BETA endpoint StartingGrid retrieves the starting grid for the upcoming race based on user filter. Need to pass the qualifying session_key to get the race starting grid! An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) StartingGridGP

func (c *Client) StartingGridGP(cityName, year string, isSprintRace bool) ([]types.StartingGrid, error)

StartingGridGP returns the starting grid for a specific Grand Prix, including both sprint and classic races.

func (*Client) Stints

func (c *Client) Stints(filter types.StintFilter) ([]types.Stint, error)

Stints retrieves stints data based on the given user filter. A stint refers to a period of continuous driving by a driver during a session. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) TeamRadio

func (c *Client) TeamRadio(filter types.TeamRadioFilter) ([]types.TeamRadio, error)

TeamRadio retrieves team radio data based on the given user filter. Only a limited selection of communications are included, not the complete record of radio interactions. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) Telemetry

func (c *Client) Telemetry(filter types.CarDataFilter) ([]types.CarData, error)

Telemetry retrieves telemetry data based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

func (*Client) TelemetryByLap

func (c *Client) TelemetryByLap(sessionKey, lap string, driverNumber int) ([]types.CarData, error)

func (*Client) Weather

func (c *Client) Weather(filter types.WeatherFilter) ([]types.Weather, error)

Weather retrieves weather data based on the given user filter. An incorrect filter parameters resulting in no results will raise an error. Excessive data requests may result in an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL