Client
pyopenf1.client.AsyncOpenF1Client
Asynchronous client for interacting with the OpenF1 API.
This is the main facade that should be used by consumers of the library. It manages the lifecycle of the underlying HTTP connection pool and exposes domain-specific API namespaces as properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Override the default OpenF1 API base URL. |
'https://api.openf1.org/v1'
|
timeout
|
float
|
HTTP request timeout in seconds. |
30.0
|
headers
|
dict[str, str] | None
|
Extra HTTP headers merged into every request. |
None
|
max_retries
|
int
|
Maximum retry attempts for transient errors. |
3
|
cache_ttl
|
float
|
TTL in seconds for response cache. |
0.0
|
max_per_second
|
float
|
Rate limit: max requests per second. |
3.0
|
max_per_minute
|
float
|
Rate limit: max requests per minute. |
30.0
|
Example::
async with AsyncOpenF1Client() as client:
drivers = await client.drivers.get_drivers(session_key=9158)
for d in drivers:
print(f"{d.name_acronym} - {d.team_name}")
Source code in pyopenf1/client.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
championship
property
Access championship standings endpoints.
drivers
property
Access driver information endpoints.
race
property
Access race control, pit, stint, and overtake endpoints.
results
property
Access session result and starting grid endpoints.
sessions
property
Access session and meeting endpoints.
team_radio
property
Access team radio endpoints.
telemetry
property
Access telemetry / car-data / location endpoints.
timing
property
Access lap, interval, and position endpoints.
weather
property
Access weather endpoints.
__aenter__()
async
__aexit__(exc_type, exc_val, exc_tb)
async
Exit the async context manager, closing the HTTP pool.
pyopenf1.sync_client.OpenF1Client
Synchronous client for the OpenF1 API.
Wraps :class:AsyncOpenF1Client and runs all coroutines in an
event loop. Supports standard with context manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Override the default OpenF1 API base URL. |
'https://api.openf1.org/v1'
|
timeout
|
float
|
HTTP request timeout in seconds. |
30.0
|
headers
|
dict[str, str] | None
|
Extra HTTP headers. |
None
|
max_retries
|
int
|
Maximum retry attempts for transient errors. |
3
|
cache_ttl
|
float
|
TTL in seconds for response cache. |
0.0
|
max_per_second
|
float
|
Rate limit: max requests per second. |
3.0
|
max_per_minute
|
float
|
Rate limit: max requests per minute. |
30.0
|
Example::
with OpenF1Client() as client:
drivers = client.drivers.get_drivers(session_key=9158)
for d in drivers:
print(d.full_name)
Source code in pyopenf1/sync_client.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
championship
property
Access championship endpoints synchronously.
drivers
property
Access driver endpoints synchronously.
race
property
Access race endpoints synchronously.
results
property
Access results endpoints synchronously.
sessions
property
Access session endpoints synchronously.
team_radio
property
Access team radio endpoints synchronously.
telemetry
property
Access telemetry endpoints synchronously.
timing
property
Access timing endpoints synchronously.
weather
property
Access weather endpoints synchronously.