openwec 0.2.4__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openwec-0.3.1/LICENSE +47 -0
- {openwec-0.2.4 → openwec-0.3.1}/PKG-INFO +78 -15
- openwec-0.3.1/README.md +183 -0
- {openwec-0.2.4 → openwec-0.3.1}/openwec/__init__.py +58 -44
- openwec-0.3.1/openwec/client.py +193 -0
- {openwec-0.2.4 → openwec-0.3.1}/openwec.egg-info/PKG-INFO +78 -15
- {openwec-0.2.4 → openwec-0.3.1}/pyproject.toml +2 -2
- openwec-0.2.4/LICENSE +0 -21
- openwec-0.2.4/README.md +0 -120
- openwec-0.2.4/openwec/client.py +0 -62
- {openwec-0.2.4 → openwec-0.3.1}/openwec/plotting.py +0 -0
- {openwec-0.2.4 → openwec-0.3.1}/openwec/session.py +0 -0
- {openwec-0.2.4 → openwec-0.3.1}/openwec.egg-info/SOURCES.txt +0 -0
- {openwec-0.2.4 → openwec-0.3.1}/openwec.egg-info/dependency_links.txt +0 -0
- {openwec-0.2.4 → openwec-0.3.1}/openwec.egg-info/requires.txt +0 -0
- {openwec-0.2.4 → openwec-0.3.1}/openwec.egg-info/top_level.txt +0 -0
- {openwec-0.2.4 → openwec-0.3.1}/setup.cfg +0 -0
openwec-0.3.1/LICENSE
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
OpenWEC — Proprietary Software License
|
|
2
|
+
Copyright (c) 2026 Paloma Cordeiro. All rights reserved.
|
|
3
|
+
|
|
4
|
+
This software and its source code, documentation, configuration and data
|
|
5
|
+
schemas (the "Software") are proprietary and confidential.
|
|
6
|
+
|
|
7
|
+
NO LICENSE IS GRANTED. No permission is given to any person to use, copy,
|
|
8
|
+
modify, merge, publish, distribute, sublicense, sell, reverse engineer or
|
|
9
|
+
create derivative works of the Software, in whole or in part, by any means,
|
|
10
|
+
except under a separate written agreement signed by the copyright holder.
|
|
11
|
+
|
|
12
|
+
Access to the Software — including access granted through a source code
|
|
13
|
+
repository, a deployment, an installer or any other channel — does not grant
|
|
14
|
+
any right beyond what that separate written agreement states. Possession of a
|
|
15
|
+
copy is not permission to use it.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
21
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
22
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
THIRD-PARTY COMPONENTS
|
|
26
|
+
|
|
27
|
+
The Software depends on, and its builds bundle, third-party components that
|
|
28
|
+
remain under their own licenses. Nothing in this file changes, restricts or
|
|
29
|
+
supersedes those licenses, and their notices must be kept intact — including
|
|
30
|
+
the notices embedded in the compiled dashboard assets.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
PREVIOUSLY PUBLISHED VERSIONS
|
|
34
|
+
|
|
35
|
+
Versions of the `openwec` Python package published to PyPI before 2026-11-17
|
|
36
|
+
(0.1.0 through 0.3.0) were released under the MIT License. That grant is
|
|
37
|
+
irrevocable for the copies already distributed: whoever received those
|
|
38
|
+
versions keeps the MIT rights to them. This license governs this repository
|
|
39
|
+
and every version released from 2026-11-17 onward.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
RACING DATA
|
|
43
|
+
|
|
44
|
+
The racing data this Software reads and serves comes from Al Kamel Systems
|
|
45
|
+
public timing exports and is not owned by the copyright holder. See
|
|
46
|
+
DATA_POLICY.md. OpenWEC is not affiliated with the ACO, the FIA, IMSA or
|
|
47
|
+
Al Kamel Systems.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openwec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Python SDK for endurance racing data — WEC, ELMS, ALMS, Le Mans Cup, IMSA
|
|
5
5
|
Author: Paloma C.
|
|
6
|
-
License-Expression:
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
7
|
Project-URL: Homepage, https://openwec.com
|
|
8
8
|
Project-URL: Documentation, https://api.openwec.com/docs
|
|
9
9
|
Project-URL: Repository, https://github.com/palomacdev/openwec
|
|
@@ -74,7 +74,7 @@ print(session)
|
|
|
74
74
|
results = session.results()
|
|
75
75
|
print(results[["position", "car_number", "car_class", "team", "drivers"]].head(10))
|
|
76
76
|
|
|
77
|
-
# Lap-by-lap data (key
|
|
77
|
+
# Lap-by-lap data for one car (no key needed)
|
|
78
78
|
laps = session.laps(car="7")
|
|
79
79
|
print(laps[["lap_number", "lap_time_s", "s1_s", "s2_s", "s3_s"]].head())
|
|
80
80
|
|
|
@@ -108,7 +108,7 @@ session.plot_gap_to_leader(car_class="HYPERCAR")
|
|
|
108
108
|
| Le Mans Cup | 2017–2026 |
|
|
109
109
|
| IMSA | 2014–2026 |
|
|
110
110
|
|
|
111
|
-
**
|
|
111
|
+
**2M+ laps** across all series.
|
|
112
112
|
|
|
113
113
|
---
|
|
114
114
|
|
|
@@ -121,20 +121,68 @@ Lap-by-lap data and analytics endpoints require a free API key.
|
|
|
121
121
|
|
|
122
122
|
---
|
|
123
123
|
|
|
124
|
+
## Errors and rate limits
|
|
125
|
+
|
|
126
|
+
Reads made without a key share a per-minute budget. A sweep over many sessions
|
|
127
|
+
will reach it, and the API answers `429` with a `Retry-After`. Every failure
|
|
128
|
+
mode has its own exception, so you can tell them apart:
|
|
129
|
+
|
|
130
|
+
| Status | Exception | What it means |
|
|
131
|
+
|--------|-----------|---------------|
|
|
132
|
+
| 401 | `OpenWECAuthError` | no key, and this endpoint needs one |
|
|
133
|
+
| 403 | `OpenWECPermissionError` | the key is valid but not allowed here |
|
|
134
|
+
| 404 | `OpenWECNotFoundError` | no such session, driver or team |
|
|
135
|
+
| 429 | `OpenWECRateLimitError` | budget spent — carries `.retry_after` |
|
|
136
|
+
| 5xx | `OpenWECServerError` | the API failed; the request was fine |
|
|
137
|
+
|
|
138
|
+
All of them derive from `OpenWECError`.
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from openwec import OpenWECRateLimitError
|
|
142
|
+
import time
|
|
143
|
+
|
|
144
|
+
try:
|
|
145
|
+
laps = session.laps()
|
|
146
|
+
except OpenWECRateLimitError as e:
|
|
147
|
+
time.sleep(e.retry_after or 60) # None means the API did not say
|
|
148
|
+
laps = session.laps()
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Or let the SDK wait for you. It is **off by default** — a library should not
|
|
152
|
+
block your notebook without being asked:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
openwec.configure(max_retries=3) # wait out up to three 429s
|
|
156
|
+
openwec.configure(retry_max_wait=30) # but never sleep more than 30s at once
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
A `Retry-After` longer than `retry_max_wait` raises instead of sleeping, and a
|
|
160
|
+
`429` without a `Retry-After` always raises — there is nothing to wait for.
|
|
161
|
+
|
|
162
|
+
Configuring a key raises your budget and removes the shared one.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
124
166
|
## Session methods
|
|
125
167
|
|
|
126
168
|
| Method | Description | Key required |
|
|
127
169
|
|--------|-------------|-------------|
|
|
128
170
|
| `.results()` | Race classification as DataFrame | No |
|
|
129
|
-
| `.laps(car=
|
|
130
|
-
| `.
|
|
131
|
-
| `.
|
|
132
|
-
| `.
|
|
133
|
-
| `.
|
|
134
|
-
| `.
|
|
135
|
-
| `.
|
|
136
|
-
| `.
|
|
137
|
-
| `.
|
|
171
|
+
| `.laps(car="7")` | Lap-by-lap data for one car | No |
|
|
172
|
+
| `.laps()` | Lap-by-lap data, whole session | **Yes** |
|
|
173
|
+
| `.driver_laps(name, car="7")` | Laps filtered by driver name ⚑ | No |
|
|
174
|
+
| `.driver_laps(name)` | Same, across the whole session | **Yes** |
|
|
175
|
+
| `.stints(car_class=None)` | Stint breakdown per car | No |
|
|
176
|
+
| `.gaps(car_class=None)` | Gap to leader evolution | No |
|
|
177
|
+
| `.pace(car_class=None)` | Average green-flag pace | **Yes** |
|
|
178
|
+
| `.pit_window(car=None)` | Optimal pit window estimate | **Yes** |
|
|
179
|
+
| `.plot_lap_evolution(car)` | Lap time chart | No |
|
|
180
|
+
| `.plot_stint_chart()` | Strategy/stint chart | No |
|
|
181
|
+
| `.plot_gap_to_leader()` | Gap to leader chart | No |
|
|
182
|
+
|
|
183
|
+
The line is what a page shows versus what a consumer extracts: one car's laps
|
|
184
|
+
draw a chart, a whole session's laps are a dataset. A key you *do* send is
|
|
185
|
+
always validated — an invalid one is refused with 401 even on a public method.
|
|
138
186
|
|
|
139
187
|
⚑ **Unique to endurance racing** — multiple drivers share a car. `driver_laps()` has no equivalent in FastF1.
|
|
140
188
|
|
|
@@ -151,5 +199,20 @@ Lap-by-lap data and analytics endpoints require a free API key.
|
|
|
151
199
|
|
|
152
200
|
## License
|
|
153
201
|
|
|
154
|
-
|
|
155
|
-
|
|
202
|
+
Three different things, with three different answers. This page used to show
|
|
203
|
+
one word, and one word cannot tell them apart.
|
|
204
|
+
|
|
205
|
+
**The SDK code.** Versions 0.1.0 through 0.3.0 were published here under the
|
|
206
|
+
MIT License. That grant is irrevocable for the copies already distributed: if
|
|
207
|
+
you installed one of those versions, you keep the MIT rights to that code.
|
|
208
|
+
From 0.3.1 onward the SDK, like the rest of the project, is **proprietary —
|
|
209
|
+
all rights reserved**. The full text ships with the package, in `LICENSE`.
|
|
210
|
+
|
|
211
|
+
**The API service.** A key is permission to use the service. It is not a
|
|
212
|
+
licence to the project's source and grants no rights to anything behind the
|
|
213
|
+
endpoint. What the key allows comes with the key.
|
|
214
|
+
|
|
215
|
+
**The racing data.** It is not ours to license. It comes from Al Kamel Systems
|
|
216
|
+
public timing exports, and OpenWEC is not affiliated with Al Kamel, the ACO,
|
|
217
|
+
the FIA or IMSA. Results you compute from the data are yours; the dataset
|
|
218
|
+
itself is someone else's. See `DATA_POLICY.md`.
|
openwec-0.3.1/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# openwec
|
|
2
|
+
|
|
3
|
+
**Python SDK for endurance racing data — WEC, ELMS, ALMS, Le Mans Cup, IMSA.**
|
|
4
|
+
|
|
5
|
+
Inspired by [FastF1](https://github.com/theOehrly/Fast-F1), OpenWEC gives you lap-by-lap timing data, stint analytics, and race results from endurance racing as pandas DataFrames — in one line.
|
|
6
|
+
|
|
7
|
+
→ **[openwec.com](https://openwec.com)** — Live dashboard
|
|
8
|
+
→ **[api.openwec.com/docs](https://api.openwec.com/docs)** — API reference
|
|
9
|
+
→ **[github.com/palomacdev/openwec](https://github.com/palomacdev/openwec)** — Source
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install openwec
|
|
17
|
+
|
|
18
|
+
# With plotting support
|
|
19
|
+
pip install openwec[plotting]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import openwec
|
|
28
|
+
|
|
29
|
+
# Public endpoints work without a key.
|
|
30
|
+
# Request a free key at https://openwec.com/api-keys
|
|
31
|
+
openwec.configure(api_key="your-key-here") # required for laps and analytics
|
|
32
|
+
|
|
33
|
+
# Load any session — WEC, ELMS, ALMS, Le Mans Cup, or IMSA
|
|
34
|
+
session = openwec.Session("WEC", 2026, "Le Mans", "Race")
|
|
35
|
+
print(session)
|
|
36
|
+
# Session(WEC 2026 LE MANS — Race, id=6556)
|
|
37
|
+
|
|
38
|
+
# Results as a DataFrame (no key needed)
|
|
39
|
+
results = session.results()
|
|
40
|
+
print(results[["position", "car_number", "car_class", "team", "drivers"]].head(10))
|
|
41
|
+
|
|
42
|
+
# Lap-by-lap data for one car (no key needed)
|
|
43
|
+
laps = session.laps(car="7")
|
|
44
|
+
print(laps[["lap_number", "lap_time_s", "s1_s", "s2_s", "s3_s"]].head())
|
|
45
|
+
|
|
46
|
+
# Endurance-specific: filter laps by driver within a shared-drive car
|
|
47
|
+
# (unique to endurance racing — not possible in FastF1)
|
|
48
|
+
conway_laps = session.driver_laps("Conway", car="7")
|
|
49
|
+
kobayashi_laps = session.driver_laps("Kobayashi", car="7")
|
|
50
|
+
print(f"Conway pace: {conway_laps['lap_time_s'].median():.3f}s")
|
|
51
|
+
print(f"Kobayashi pace: {kobayashi_laps['lap_time_s'].median():.3f}s")
|
|
52
|
+
|
|
53
|
+
# Stints and pace
|
|
54
|
+
stints = session.stints(car_class="HYPERCAR")
|
|
55
|
+
pace = session.pace(car_class="HYPERCAR")
|
|
56
|
+
pit_window = session.pit_window(car="7")
|
|
57
|
+
|
|
58
|
+
# Plots (requires matplotlib)
|
|
59
|
+
session.plot_lap_evolution(car="7")
|
|
60
|
+
session.plot_stint_chart(car_class="HYPERCAR")
|
|
61
|
+
session.plot_gap_to_leader(car_class="HYPERCAR")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Coverage
|
|
67
|
+
|
|
68
|
+
| Series | Seasons |
|
|
69
|
+
|--------|---------|
|
|
70
|
+
| FIA WEC | 2012–2026 |
|
|
71
|
+
| ELMS | 2012–2026 |
|
|
72
|
+
| ALMS (Asian) | 2022–2026 |
|
|
73
|
+
| Le Mans Cup | 2017–2026 |
|
|
74
|
+
| IMSA | 2014–2026 |
|
|
75
|
+
|
|
76
|
+
**2M+ laps** across all series.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## API key
|
|
81
|
+
|
|
82
|
+
Public endpoints (results, driver profiles, team profiles, driver search) require no key.
|
|
83
|
+
Lap-by-lap data and analytics endpoints require a free API key.
|
|
84
|
+
|
|
85
|
+
→ **[Request a key at openwec.com/api-keys](https://openwec.com/api-keys)**
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Errors and rate limits
|
|
90
|
+
|
|
91
|
+
Reads made without a key share a per-minute budget. A sweep over many sessions
|
|
92
|
+
will reach it, and the API answers `429` with a `Retry-After`. Every failure
|
|
93
|
+
mode has its own exception, so you can tell them apart:
|
|
94
|
+
|
|
95
|
+
| Status | Exception | What it means |
|
|
96
|
+
|--------|-----------|---------------|
|
|
97
|
+
| 401 | `OpenWECAuthError` | no key, and this endpoint needs one |
|
|
98
|
+
| 403 | `OpenWECPermissionError` | the key is valid but not allowed here |
|
|
99
|
+
| 404 | `OpenWECNotFoundError` | no such session, driver or team |
|
|
100
|
+
| 429 | `OpenWECRateLimitError` | budget spent — carries `.retry_after` |
|
|
101
|
+
| 5xx | `OpenWECServerError` | the API failed; the request was fine |
|
|
102
|
+
|
|
103
|
+
All of them derive from `OpenWECError`.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from openwec import OpenWECRateLimitError
|
|
107
|
+
import time
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
laps = session.laps()
|
|
111
|
+
except OpenWECRateLimitError as e:
|
|
112
|
+
time.sleep(e.retry_after or 60) # None means the API did not say
|
|
113
|
+
laps = session.laps()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Or let the SDK wait for you. It is **off by default** — a library should not
|
|
117
|
+
block your notebook without being asked:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
openwec.configure(max_retries=3) # wait out up to three 429s
|
|
121
|
+
openwec.configure(retry_max_wait=30) # but never sleep more than 30s at once
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
A `Retry-After` longer than `retry_max_wait` raises instead of sleeping, and a
|
|
125
|
+
`429` without a `Retry-After` always raises — there is nothing to wait for.
|
|
126
|
+
|
|
127
|
+
Configuring a key raises your budget and removes the shared one.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Session methods
|
|
132
|
+
|
|
133
|
+
| Method | Description | Key required |
|
|
134
|
+
|--------|-------------|-------------|
|
|
135
|
+
| `.results()` | Race classification as DataFrame | No |
|
|
136
|
+
| `.laps(car="7")` | Lap-by-lap data for one car | No |
|
|
137
|
+
| `.laps()` | Lap-by-lap data, whole session | **Yes** |
|
|
138
|
+
| `.driver_laps(name, car="7")` | Laps filtered by driver name ⚑ | No |
|
|
139
|
+
| `.driver_laps(name)` | Same, across the whole session | **Yes** |
|
|
140
|
+
| `.stints(car_class=None)` | Stint breakdown per car | No |
|
|
141
|
+
| `.gaps(car_class=None)` | Gap to leader evolution | No |
|
|
142
|
+
| `.pace(car_class=None)` | Average green-flag pace | **Yes** |
|
|
143
|
+
| `.pit_window(car=None)` | Optimal pit window estimate | **Yes** |
|
|
144
|
+
| `.plot_lap_evolution(car)` | Lap time chart | No |
|
|
145
|
+
| `.plot_stint_chart()` | Strategy/stint chart | No |
|
|
146
|
+
| `.plot_gap_to_leader()` | Gap to leader chart | No |
|
|
147
|
+
|
|
148
|
+
The line is what a page shows versus what a consumer extracts: one car's laps
|
|
149
|
+
draw a chart, a whole session's laps are a dataset. A key you *do* send is
|
|
150
|
+
always validated — an invalid one is refused with 401 even on a public method.
|
|
151
|
+
|
|
152
|
+
⚑ **Unique to endurance racing** — multiple drivers share a car. `driver_laps()` has no equivalent in FastF1.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Example notebooks
|
|
157
|
+
|
|
158
|
+
| Notebook | Description |
|
|
159
|
+
|----------|-------------|
|
|
160
|
+
| [le_mans_2026.ipynb](examples/le_mans_2026.ipynb) | Full race analysis — results, pace, stints, plots |
|
|
161
|
+
| [driver_career.ipynb](examples/driver_career.ipynb) | Cross-series career analysis for a driver |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
Three different things, with three different answers. This page used to show
|
|
168
|
+
one word, and one word cannot tell them apart.
|
|
169
|
+
|
|
170
|
+
**The SDK code.** Versions 0.1.0 through 0.3.0 were published here under the
|
|
171
|
+
MIT License. That grant is irrevocable for the copies already distributed: if
|
|
172
|
+
you installed one of those versions, you keep the MIT rights to that code.
|
|
173
|
+
From 0.3.1 onward the SDK, like the rest of the project, is **proprietary —
|
|
174
|
+
all rights reserved**. The full text ships with the package, in `LICENSE`.
|
|
175
|
+
|
|
176
|
+
**The API service.** A key is permission to use the service. It is not a
|
|
177
|
+
licence to the project's source and grants no rights to anything behind the
|
|
178
|
+
endpoint. What the key allows comes with the key.
|
|
179
|
+
|
|
180
|
+
**The racing data.** It is not ours to license. It comes from Al Kamel Systems
|
|
181
|
+
public timing exports, and OpenWEC is not affiliated with Al Kamel, the ACO,
|
|
182
|
+
the FIA or IMSA. Results you compute from the data are yours; the dataset
|
|
183
|
+
itself is someone else's. See `DATA_POLICY.md`.
|
|
@@ -1,45 +1,59 @@
|
|
|
1
|
-
"""
|
|
2
|
-
OpenWEC SDK — Alpha
|
|
3
|
-
|
|
4
|
-
A FastF1-style Python interface for endurance racing data
|
|
5
|
-
(WEC, ELMS, ALMS, Le Mans Cup, IMSA).
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
import openwec
|
|
9
|
-
|
|
10
|
-
# Optional: configure API URL and key
|
|
11
|
-
openwec.configure(base_url="http://localhost:8000/api/v1", api_key="your-key")
|
|
12
|
-
|
|
13
|
-
# Load a session
|
|
14
|
-
session = openwec.Session("WEC", 2024, "Le Mans", "Race")
|
|
15
|
-
|
|
16
|
-
# Results (public, no API key needed)
|
|
17
|
-
results = session.results()
|
|
18
|
-
print(results.head())
|
|
19
|
-
|
|
20
|
-
# Laps
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
pace
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
session.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
"""
|
|
2
|
+
OpenWEC SDK — Alpha
|
|
3
|
+
|
|
4
|
+
A FastF1-style Python interface for endurance racing data
|
|
5
|
+
(WEC, ELMS, ALMS, Le Mans Cup, IMSA).
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
import openwec
|
|
9
|
+
|
|
10
|
+
# Optional: configure API URL and key
|
|
11
|
+
openwec.configure(base_url="http://localhost:8000/api/v1", api_key="your-key")
|
|
12
|
+
|
|
13
|
+
# Load a session
|
|
14
|
+
session = openwec.Session("WEC", 2024, "Le Mans", "Race")
|
|
15
|
+
|
|
16
|
+
# Results (public, no API key needed)
|
|
17
|
+
results = session.results()
|
|
18
|
+
print(results.head())
|
|
19
|
+
|
|
20
|
+
# Laps of one car — public
|
|
21
|
+
laps_50 = session.laps(car="50")
|
|
22
|
+
|
|
23
|
+
# Laps of the whole session at once — needs a key
|
|
24
|
+
laps = session.laps()
|
|
25
|
+
|
|
26
|
+
# Analytics: stints and gaps are public, pace needs a key
|
|
27
|
+
stints = session.stints()
|
|
28
|
+
gaps = session.gaps()
|
|
29
|
+
pace = session.pace()
|
|
30
|
+
|
|
31
|
+
# Plots (need matplotlib; the data behind these three is public)
|
|
32
|
+
session.plot_lap_evolution(car="50")
|
|
33
|
+
session.plot_stint_chart()
|
|
34
|
+
session.plot_gap_to_leader()
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
from .client import (
|
|
38
|
+
configure,
|
|
39
|
+
OpenWECError,
|
|
40
|
+
OpenWECNotFoundError,
|
|
41
|
+
OpenWECAuthError,
|
|
42
|
+
OpenWECPermissionError,
|
|
43
|
+
OpenWECRateLimitError,
|
|
44
|
+
OpenWECServerError,
|
|
45
|
+
)
|
|
46
|
+
from .session import Session
|
|
47
|
+
|
|
48
|
+
__version__ = "0.3.1"
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
"Session",
|
|
52
|
+
"configure",
|
|
53
|
+
"OpenWECError",
|
|
54
|
+
"OpenWECNotFoundError",
|
|
55
|
+
"OpenWECAuthError",
|
|
56
|
+
"OpenWECPermissionError",
|
|
57
|
+
"OpenWECRateLimitError",
|
|
58
|
+
"OpenWECServerError",
|
|
45
59
|
]
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"""
|
|
2
|
+
OpenWEC SDK — Client configuration and HTTP wrapper.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import email.utils
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# A 429 carries Retry-After. Waiting longer than this is not a retry, it is a
|
|
12
|
+
# hang, so the SDK refuses to sleep past it and raises instead.
|
|
13
|
+
_RETRY_MAX_WAIT_SECONDS = 60.0
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class _Config:
|
|
17
|
+
base_url: str = "https://api.openwec.com/api/v1"
|
|
18
|
+
api_key: str | None = None
|
|
19
|
+
max_retries: int = 0
|
|
20
|
+
retry_max_wait: float = _RETRY_MAX_WAIT_SECONDS
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_config = _Config()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def configure(
|
|
27
|
+
base_url: str | None = None,
|
|
28
|
+
api_key: str | None = None,
|
|
29
|
+
max_retries: int | None = None,
|
|
30
|
+
retry_max_wait: float | None = None,
|
|
31
|
+
):
|
|
32
|
+
"""
|
|
33
|
+
Configure the SDK.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
base_url: API base URL (default: https://api.openwec.com/api/v1)
|
|
37
|
+
api_key: API key for protected endpoints (laps, pace, pit-window)
|
|
38
|
+
max_retries: how many times to wait out a 429 before raising.
|
|
39
|
+
Default 0 — a rate-limited call raises OpenWECRateLimitError
|
|
40
|
+
immediately, and you decide what to do. Set it to 2 or 3 in a
|
|
41
|
+
notebook that sweeps many sessions.
|
|
42
|
+
retry_max_wait: never sleep longer than this for one retry, in
|
|
43
|
+
seconds (default 60). A Retry-After above it raises instead.
|
|
44
|
+
"""
|
|
45
|
+
if base_url:
|
|
46
|
+
_config.base_url = base_url.rstrip("/")
|
|
47
|
+
if api_key:
|
|
48
|
+
_config.api_key = api_key
|
|
49
|
+
if max_retries is not None:
|
|
50
|
+
if max_retries < 0:
|
|
51
|
+
raise ValueError("max_retries must be zero or more")
|
|
52
|
+
_config.max_retries = max_retries
|
|
53
|
+
if retry_max_wait is not None:
|
|
54
|
+
if retry_max_wait <= 0:
|
|
55
|
+
raise ValueError("retry_max_wait must be positive")
|
|
56
|
+
_config.retry_max_wait = retry_max_wait
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _headers() -> dict:
|
|
60
|
+
headers = {}
|
|
61
|
+
if _config.api_key:
|
|
62
|
+
headers["X-API-Key"] = _config.api_key
|
|
63
|
+
return headers
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _retry_after(resp: httpx.Response) -> float | None:
|
|
67
|
+
"""
|
|
68
|
+
Seconds to wait, from the Retry-After header.
|
|
69
|
+
|
|
70
|
+
The header is either a number of seconds or an HTTP date; both are legal
|
|
71
|
+
and the API has used both over time. Anything else, or a date already in
|
|
72
|
+
the past, reads as None — the caller then has no guidance, which is
|
|
73
|
+
different from being told to wait zero.
|
|
74
|
+
"""
|
|
75
|
+
bruto = resp.headers.get("Retry-After")
|
|
76
|
+
if not bruto:
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
bruto = bruto.strip()
|
|
80
|
+
try:
|
|
81
|
+
return max(0.0, float(bruto))
|
|
82
|
+
except ValueError:
|
|
83
|
+
pass
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
quando = email.utils.parsedate_to_datetime(bruto)
|
|
87
|
+
except (TypeError, ValueError):
|
|
88
|
+
return None
|
|
89
|
+
if quando is None:
|
|
90
|
+
return None
|
|
91
|
+
espera = quando.timestamp() - time.time()
|
|
92
|
+
return espera if espera > 0 else None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _get(path: str, params: dict | None = None) -> dict | list:
|
|
96
|
+
"""Performs a GET request to the OpenWEC API. Raises on error."""
|
|
97
|
+
url = f"{_config.base_url}{path}"
|
|
98
|
+
tentativas = 0
|
|
99
|
+
|
|
100
|
+
while True:
|
|
101
|
+
resp = httpx.get(url, params=params, headers=_headers(), timeout=30)
|
|
102
|
+
|
|
103
|
+
if resp.status_code == 404:
|
|
104
|
+
raise OpenWECNotFoundError(f"Not found: {path} ({resp.text})")
|
|
105
|
+
|
|
106
|
+
if resp.status_code == 401:
|
|
107
|
+
raise OpenWECAuthError(
|
|
108
|
+
"Unauthorized — this endpoint requires an API key. "
|
|
109
|
+
"Call openwec.configure(api_key='...') first."
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
if resp.status_code == 403:
|
|
113
|
+
raise OpenWECPermissionError(
|
|
114
|
+
f"Forbidden — the key is valid but not allowed here: {path}"
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
if resp.status_code == 429:
|
|
118
|
+
espera = _retry_after(resp)
|
|
119
|
+
podemos = (
|
|
120
|
+
tentativas < _config.max_retries
|
|
121
|
+
and espera is not None
|
|
122
|
+
and espera <= _config.retry_max_wait
|
|
123
|
+
)
|
|
124
|
+
if not podemos:
|
|
125
|
+
raise OpenWECRateLimitError(
|
|
126
|
+
_mensagem_de_limite(path, espera), retry_after=espera
|
|
127
|
+
)
|
|
128
|
+
time.sleep(espera)
|
|
129
|
+
tentativas += 1
|
|
130
|
+
continue
|
|
131
|
+
|
|
132
|
+
if resp.status_code >= 500:
|
|
133
|
+
raise OpenWECServerError(
|
|
134
|
+
f"Server error {resp.status_code} from {path}. "
|
|
135
|
+
"This is the API's problem, not the request's — retry later."
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
resp.raise_for_status()
|
|
139
|
+
return resp.json()
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _mensagem_de_limite(path: str, espera: float | None) -> str:
|
|
143
|
+
quando = (
|
|
144
|
+
f"Retry after {espera:.0f}s." if espera is not None
|
|
145
|
+
else "The response gave no Retry-After."
|
|
146
|
+
)
|
|
147
|
+
chave = (
|
|
148
|
+
"Reads without a key share a per-minute budget; configure(api_key=...) "
|
|
149
|
+
"raises it." if not _config.api_key else
|
|
150
|
+
"This key's own per-minute budget is spent."
|
|
151
|
+
)
|
|
152
|
+
return (
|
|
153
|
+
f"Rate limited on {path}. {quando} {chave} "
|
|
154
|
+
"Pass max_retries= to configure() to wait automatically."
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class OpenWECError(Exception):
|
|
159
|
+
"""Base exception for OpenWEC SDK errors."""
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class OpenWECNotFoundError(OpenWECError):
|
|
163
|
+
"""Raised when a resource is not found (404)."""
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class OpenWECAuthError(OpenWECError):
|
|
167
|
+
"""Raised when an API key is required but missing/invalid (401)."""
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class OpenWECPermissionError(OpenWECError):
|
|
171
|
+
"""Raised when the key is accepted but not allowed here (403)."""
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class OpenWECRateLimitError(OpenWECError):
|
|
175
|
+
"""
|
|
176
|
+
Raised when the API returns 429.
|
|
177
|
+
|
|
178
|
+
`retry_after` is the seconds the API asked for, or None when it did not
|
|
179
|
+
say. Catch this rather than sleeping blind:
|
|
180
|
+
|
|
181
|
+
try:
|
|
182
|
+
laps = session.laps()
|
|
183
|
+
except OpenWECRateLimitError as e:
|
|
184
|
+
time.sleep(e.retry_after or 60)
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
def __init__(self, message: str, retry_after: float | None = None):
|
|
188
|
+
super().__init__(message)
|
|
189
|
+
self.retry_after = retry_after
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class OpenWECServerError(OpenWECError):
|
|
193
|
+
"""Raised on 5xx — the API failed, the request was fine."""
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openwec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Python SDK for endurance racing data — WEC, ELMS, ALMS, Le Mans Cup, IMSA
|
|
5
5
|
Author: Paloma C.
|
|
6
|
-
License-Expression:
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
7
|
Project-URL: Homepage, https://openwec.com
|
|
8
8
|
Project-URL: Documentation, https://api.openwec.com/docs
|
|
9
9
|
Project-URL: Repository, https://github.com/palomacdev/openwec
|
|
@@ -74,7 +74,7 @@ print(session)
|
|
|
74
74
|
results = session.results()
|
|
75
75
|
print(results[["position", "car_number", "car_class", "team", "drivers"]].head(10))
|
|
76
76
|
|
|
77
|
-
# Lap-by-lap data (key
|
|
77
|
+
# Lap-by-lap data for one car (no key needed)
|
|
78
78
|
laps = session.laps(car="7")
|
|
79
79
|
print(laps[["lap_number", "lap_time_s", "s1_s", "s2_s", "s3_s"]].head())
|
|
80
80
|
|
|
@@ -108,7 +108,7 @@ session.plot_gap_to_leader(car_class="HYPERCAR")
|
|
|
108
108
|
| Le Mans Cup | 2017–2026 |
|
|
109
109
|
| IMSA | 2014–2026 |
|
|
110
110
|
|
|
111
|
-
**
|
|
111
|
+
**2M+ laps** across all series.
|
|
112
112
|
|
|
113
113
|
---
|
|
114
114
|
|
|
@@ -121,20 +121,68 @@ Lap-by-lap data and analytics endpoints require a free API key.
|
|
|
121
121
|
|
|
122
122
|
---
|
|
123
123
|
|
|
124
|
+
## Errors and rate limits
|
|
125
|
+
|
|
126
|
+
Reads made without a key share a per-minute budget. A sweep over many sessions
|
|
127
|
+
will reach it, and the API answers `429` with a `Retry-After`. Every failure
|
|
128
|
+
mode has its own exception, so you can tell them apart:
|
|
129
|
+
|
|
130
|
+
| Status | Exception | What it means |
|
|
131
|
+
|--------|-----------|---------------|
|
|
132
|
+
| 401 | `OpenWECAuthError` | no key, and this endpoint needs one |
|
|
133
|
+
| 403 | `OpenWECPermissionError` | the key is valid but not allowed here |
|
|
134
|
+
| 404 | `OpenWECNotFoundError` | no such session, driver or team |
|
|
135
|
+
| 429 | `OpenWECRateLimitError` | budget spent — carries `.retry_after` |
|
|
136
|
+
| 5xx | `OpenWECServerError` | the API failed; the request was fine |
|
|
137
|
+
|
|
138
|
+
All of them derive from `OpenWECError`.
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from openwec import OpenWECRateLimitError
|
|
142
|
+
import time
|
|
143
|
+
|
|
144
|
+
try:
|
|
145
|
+
laps = session.laps()
|
|
146
|
+
except OpenWECRateLimitError as e:
|
|
147
|
+
time.sleep(e.retry_after or 60) # None means the API did not say
|
|
148
|
+
laps = session.laps()
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Or let the SDK wait for you. It is **off by default** — a library should not
|
|
152
|
+
block your notebook without being asked:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
openwec.configure(max_retries=3) # wait out up to three 429s
|
|
156
|
+
openwec.configure(retry_max_wait=30) # but never sleep more than 30s at once
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
A `Retry-After` longer than `retry_max_wait` raises instead of sleeping, and a
|
|
160
|
+
`429` without a `Retry-After` always raises — there is nothing to wait for.
|
|
161
|
+
|
|
162
|
+
Configuring a key raises your budget and removes the shared one.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
124
166
|
## Session methods
|
|
125
167
|
|
|
126
168
|
| Method | Description | Key required |
|
|
127
169
|
|--------|-------------|-------------|
|
|
128
170
|
| `.results()` | Race classification as DataFrame | No |
|
|
129
|
-
| `.laps(car=
|
|
130
|
-
| `.
|
|
131
|
-
| `.
|
|
132
|
-
| `.
|
|
133
|
-
| `.
|
|
134
|
-
| `.
|
|
135
|
-
| `.
|
|
136
|
-
| `.
|
|
137
|
-
| `.
|
|
171
|
+
| `.laps(car="7")` | Lap-by-lap data for one car | No |
|
|
172
|
+
| `.laps()` | Lap-by-lap data, whole session | **Yes** |
|
|
173
|
+
| `.driver_laps(name, car="7")` | Laps filtered by driver name ⚑ | No |
|
|
174
|
+
| `.driver_laps(name)` | Same, across the whole session | **Yes** |
|
|
175
|
+
| `.stints(car_class=None)` | Stint breakdown per car | No |
|
|
176
|
+
| `.gaps(car_class=None)` | Gap to leader evolution | No |
|
|
177
|
+
| `.pace(car_class=None)` | Average green-flag pace | **Yes** |
|
|
178
|
+
| `.pit_window(car=None)` | Optimal pit window estimate | **Yes** |
|
|
179
|
+
| `.plot_lap_evolution(car)` | Lap time chart | No |
|
|
180
|
+
| `.plot_stint_chart()` | Strategy/stint chart | No |
|
|
181
|
+
| `.plot_gap_to_leader()` | Gap to leader chart | No |
|
|
182
|
+
|
|
183
|
+
The line is what a page shows versus what a consumer extracts: one car's laps
|
|
184
|
+
draw a chart, a whole session's laps are a dataset. A key you *do* send is
|
|
185
|
+
always validated — an invalid one is refused with 401 even on a public method.
|
|
138
186
|
|
|
139
187
|
⚑ **Unique to endurance racing** — multiple drivers share a car. `driver_laps()` has no equivalent in FastF1.
|
|
140
188
|
|
|
@@ -151,5 +199,20 @@ Lap-by-lap data and analytics endpoints require a free API key.
|
|
|
151
199
|
|
|
152
200
|
## License
|
|
153
201
|
|
|
154
|
-
|
|
155
|
-
|
|
202
|
+
Three different things, with three different answers. This page used to show
|
|
203
|
+
one word, and one word cannot tell them apart.
|
|
204
|
+
|
|
205
|
+
**The SDK code.** Versions 0.1.0 through 0.3.0 were published here under the
|
|
206
|
+
MIT License. That grant is irrevocable for the copies already distributed: if
|
|
207
|
+
you installed one of those versions, you keep the MIT rights to that code.
|
|
208
|
+
From 0.3.1 onward the SDK, like the rest of the project, is **proprietary —
|
|
209
|
+
all rights reserved**. The full text ships with the package, in `LICENSE`.
|
|
210
|
+
|
|
211
|
+
**The API service.** A key is permission to use the service. It is not a
|
|
212
|
+
licence to the project's source and grants no rights to anything behind the
|
|
213
|
+
endpoint. What the key allows comes with the key.
|
|
214
|
+
|
|
215
|
+
**The racing data.** It is not ours to license. It comes from Al Kamel Systems
|
|
216
|
+
public timing exports, and OpenWEC is not affiliated with Al Kamel, the ACO,
|
|
217
|
+
the FIA or IMSA. Results you compute from the data are yours; the dataset
|
|
218
|
+
itself is someone else's. See `DATA_POLICY.md`.
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "openwec"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.1"
|
|
8
8
|
description = "Python SDK for endurance racing data — WEC, ELMS, ALMS, Le Mans Cup, IMSA"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
license = "
|
|
10
|
+
license = "LicenseRef-Proprietary"
|
|
11
11
|
license-files = ["LICENSE"]
|
|
12
12
|
requires-python = ">=3.10"
|
|
13
13
|
|
openwec-0.2.4/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Paloma Cordeiro
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
openwec-0.2.4/README.md
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
# openwec
|
|
2
|
-
|
|
3
|
-
**Python SDK for endurance racing data — WEC, ELMS, ALMS, Le Mans Cup, IMSA.**
|
|
4
|
-
|
|
5
|
-
Inspired by [FastF1](https://github.com/theOehrly/Fast-F1), OpenWEC gives you lap-by-lap timing data, stint analytics, and race results from endurance racing as pandas DataFrames — in one line.
|
|
6
|
-
|
|
7
|
-
→ **[openwec.com](https://openwec.com)** — Live dashboard
|
|
8
|
-
→ **[api.openwec.com/docs](https://api.openwec.com/docs)** — API reference
|
|
9
|
-
→ **[github.com/palomacdev/openwec](https://github.com/palomacdev/openwec)** — Source
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pip install openwec
|
|
17
|
-
|
|
18
|
-
# With plotting support
|
|
19
|
-
pip install openwec[plotting]
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Quick start
|
|
25
|
-
|
|
26
|
-
```python
|
|
27
|
-
import openwec
|
|
28
|
-
|
|
29
|
-
# Public endpoints work without a key.
|
|
30
|
-
# Request a free key at https://openwec.com/api-keys
|
|
31
|
-
openwec.configure(api_key="your-key-here") # required for laps and analytics
|
|
32
|
-
|
|
33
|
-
# Load any session — WEC, ELMS, ALMS, Le Mans Cup, or IMSA
|
|
34
|
-
session = openwec.Session("WEC", 2026, "Le Mans", "Race")
|
|
35
|
-
print(session)
|
|
36
|
-
# Session(WEC 2026 LE MANS — Race, id=6556)
|
|
37
|
-
|
|
38
|
-
# Results as a DataFrame (no key needed)
|
|
39
|
-
results = session.results()
|
|
40
|
-
print(results[["position", "car_number", "car_class", "team", "drivers"]].head(10))
|
|
41
|
-
|
|
42
|
-
# Lap-by-lap data (key required)
|
|
43
|
-
laps = session.laps(car="7")
|
|
44
|
-
print(laps[["lap_number", "lap_time_s", "s1_s", "s2_s", "s3_s"]].head())
|
|
45
|
-
|
|
46
|
-
# Endurance-specific: filter laps by driver within a shared-drive car
|
|
47
|
-
# (unique to endurance racing — not possible in FastF1)
|
|
48
|
-
conway_laps = session.driver_laps("Conway", car="7")
|
|
49
|
-
kobayashi_laps = session.driver_laps("Kobayashi", car="7")
|
|
50
|
-
print(f"Conway pace: {conway_laps['lap_time_s'].median():.3f}s")
|
|
51
|
-
print(f"Kobayashi pace: {kobayashi_laps['lap_time_s'].median():.3f}s")
|
|
52
|
-
|
|
53
|
-
# Stints and pace
|
|
54
|
-
stints = session.stints(car_class="HYPERCAR")
|
|
55
|
-
pace = session.pace(car_class="HYPERCAR")
|
|
56
|
-
pit_window = session.pit_window(car="7")
|
|
57
|
-
|
|
58
|
-
# Plots (requires matplotlib)
|
|
59
|
-
session.plot_lap_evolution(car="7")
|
|
60
|
-
session.plot_stint_chart(car_class="HYPERCAR")
|
|
61
|
-
session.plot_gap_to_leader(car_class="HYPERCAR")
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Coverage
|
|
67
|
-
|
|
68
|
-
| Series | Seasons |
|
|
69
|
-
|--------|---------|
|
|
70
|
-
| FIA WEC | 2012–2026 |
|
|
71
|
-
| ELMS | 2012–2026 |
|
|
72
|
-
| ALMS (Asian) | 2022–2026 |
|
|
73
|
-
| Le Mans Cup | 2017–2026 |
|
|
74
|
-
| IMSA | 2014–2026 |
|
|
75
|
-
|
|
76
|
-
**1.96M+ laps** across all series.
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## API key
|
|
81
|
-
|
|
82
|
-
Public endpoints (results, driver profiles, team profiles, driver search) require no key.
|
|
83
|
-
Lap-by-lap data and analytics endpoints require a free API key.
|
|
84
|
-
|
|
85
|
-
→ **[Request a key at openwec.com/api-keys](https://openwec.com/api-keys)**
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Session methods
|
|
90
|
-
|
|
91
|
-
| Method | Description | Key required |
|
|
92
|
-
|--------|-------------|-------------|
|
|
93
|
-
| `.results()` | Race classification as DataFrame | No |
|
|
94
|
-
| `.laps(car=None)` | Lap-by-lap data | Yes |
|
|
95
|
-
| `.driver_laps(name, car=None)` | Laps filtered by driver name ⚑ | Yes |
|
|
96
|
-
| `.stints(car_class=None)` | Stint breakdown per car | Yes |
|
|
97
|
-
| `.pace(car_class=None)` | Average green-flag pace | Yes |
|
|
98
|
-
| `.gaps(car_class=None)` | Gap to leader evolution | Yes |
|
|
99
|
-
| `.pit_window(car=None)` | Optimal pit window estimate | Yes |
|
|
100
|
-
| `.plot_lap_evolution(car)` | Lap time chart | Yes |
|
|
101
|
-
| `.plot_stint_chart()` | Strategy/stint chart | Yes |
|
|
102
|
-
| `.plot_gap_to_leader()` | Gap to leader chart | Yes |
|
|
103
|
-
|
|
104
|
-
⚑ **Unique to endurance racing** — multiple drivers share a car. `driver_laps()` has no equivalent in FastF1.
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## Example notebooks
|
|
109
|
-
|
|
110
|
-
| Notebook | Description |
|
|
111
|
-
|----------|-------------|
|
|
112
|
-
| [le_mans_2026.ipynb](examples/le_mans_2026.ipynb) | Full race analysis — results, pace, stints, plots |
|
|
113
|
-
| [driver_career.ipynb](examples/driver_career.ipynb) | Cross-series career analysis for a driver |
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## License
|
|
118
|
-
|
|
119
|
-
MIT — data sourced from Al Kamel Systems public timing exports.
|
|
120
|
-
Not affiliated with ACO, FIA, or any racing organization.
|
openwec-0.2.4/openwec/client.py
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
OpenWEC SDK — Client configuration and HTTP wrapper.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import httpx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class _Config:
|
|
9
|
-
base_url: str = "https://api.openwec.com/api/v1"
|
|
10
|
-
api_key: str | None = None
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_config = _Config()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def configure(base_url: str | None = None, api_key: str | None = None):
|
|
17
|
-
"""
|
|
18
|
-
Configure the SDK.
|
|
19
|
-
|
|
20
|
-
Args:
|
|
21
|
-
base_url: API base URL (default: https://api.openwec.com/api/v1)
|
|
22
|
-
api_key: API key for protected endpoints (laps, analytics)
|
|
23
|
-
"""
|
|
24
|
-
if base_url:
|
|
25
|
-
_config.base_url = base_url.rstrip("/")
|
|
26
|
-
if api_key:
|
|
27
|
-
_config.api_key = api_key
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def _headers() -> dict:
|
|
31
|
-
headers = {}
|
|
32
|
-
if _config.api_key:
|
|
33
|
-
headers["X-API-Key"] = _config.api_key
|
|
34
|
-
return headers
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _get(path: str, params: dict | None = None) -> dict | list:
|
|
38
|
-
"""Performs a GET request to the OpenWEC API. Raises on error."""
|
|
39
|
-
url = f"{_config.base_url}{path}"
|
|
40
|
-
resp = httpx.get(url, params=params, headers=_headers(), timeout=30)
|
|
41
|
-
|
|
42
|
-
if resp.status_code == 404:
|
|
43
|
-
raise OpenWECNotFoundError(f"Not found: {path} ({resp.text})")
|
|
44
|
-
if resp.status_code == 401:
|
|
45
|
-
raise OpenWECAuthError(
|
|
46
|
-
"Unauthorized — this endpoint requires an API key. "
|
|
47
|
-
"Call openwec.configure(api_key='...') first."
|
|
48
|
-
)
|
|
49
|
-
resp.raise_for_status()
|
|
50
|
-
return resp.json()
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class OpenWECError(Exception):
|
|
54
|
-
"""Base exception for OpenWEC SDK errors."""
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class OpenWECNotFoundError(OpenWECError):
|
|
58
|
-
"""Raised when a resource is not found (404)."""
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
class OpenWECAuthError(OpenWECError):
|
|
62
|
-
"""Raised when an API key is required but missing/invalid (401)."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|