1
+ ---
2
+ description:
3
+ globs:
4
+ alwaysApply: true
5
+ ---
6
+ # First Cycling API
7
+ [](https://firstcyclingapi.readthedocs.io/en/latest/?badge=latest)
8
+ [](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE)
9
+ [](https://github.com/baronet2/FirstCyclingAPI/stargazers)
10
+ @
11
+ An unofficial Python API wrapper for https://firstcycling.com/.
12
+
13
+ ## Usage
14
+
15
+ The API wrapper currently supports the following endpoints:
16
+
17
+ - Race pages
18
+ - Rider pages
19
+ - Rankings pages
20
+
21
+ A few examples are shown below.
22
+
23
+ For full documentation, see https://firstcyclingapi.readthedocs.io/en/latest/.
24
+
25
+ **Race Results:**
26
+ ```python
27
+ >>> from first_cycling_api import RaceEdition
28
+ >>> amstel_2019 = RaceEdition(race_id=9, year=2019) # The race_id comes from the race page URL
29
+ >>> amstel_2019.results().results_table.head() # A pandas DataFrame of the race results
30
+ ```
31
+
32
+ | | Pos | Rider | Team | Time | UCI | Rider_ID | Rider_Country | Team_ID |
33
+ |---:|------:|:----------------------|:------------------------|:--------|------:|-----------:|:----------------|----------:|
34
+ | 0 | 01 | van der Poel Mathieu | Corendon - Circus | 6:28:18 | 500 | 16672 | NED | 13279 |
35
+ | 1 | 02 | Clarke Simon | EF Education First | + 00 | 400 | 568 | AUS | 13208 |
36
+ | 2 | 03 | Fuglsang Jakob | Astana Pro Team | + 00 | 325 | 264 | DEN | 13198 |
37
+ | 3 | 04 | Alaphilippe Julian | Deceuninck - Quick Step | + 00 | 275 | 12474 | FRA | 13206 |
38
+ | 4 | 05 | Schachmann Maximilian | Bora - Hansgrohe | + 00 | 225 | 16643 | GER | 13200 |
39
+
40
+ **Rider Results:**
41
+ ```python
42
+ >>> from first_cycling_api import Rider
43
+ >>> roglic = Rider(18655) # The rider ID comes from the rider page URL
44
+ >>> roglic.year_results(2020).results_df.head() # A pandas DataFrame of Roglic's 2020 results
45
+ ```
46
+
47
+ | | Date | Pos | GC | Race_Country | Race | CAT | UCI | Unnamed: 8 | Race_ID |
48
+ |---:|-------:|------:|-----:|:---------------|:----------------------|:------|------:|:-------------|----------:|
49
+ | 0 | 8.11 | 1 | nan | ESP | Vuelta a España | 2.UWT | 850 | Show more | 23 |
50
+ | 1 | 4.1 | 1 | nan | BEL | Liège-Bastogne-Liège | 1.UWT | 500 | Show more | 11 |
51
+ | 2 | 20.09 | 2 | nan | FRA | Tour de France | 2.UWT | 800 | Show more | 17 |
52
+ | 3 | 27.09 | 6 | nan | UCI | World Championship RR | WCRR | 225 | Show more | 26 |
53
+ | 4 | 9.08 | 1 | nan | FRA | Tour de l'Ain | 2.1 | 125 | Show more | 63 |
54
+
55
+ **Rankings Pages:**
56
+ ```python
57
+ >>> from first_cycling_api import Ranking
58
+ >>> ranking = Ranking(h=1, rank=1, y=2020, page=2) # Parameters from corresponding URL
59
+ >>> ranking.table.head() # A pandas DataFrame of the rankings table
60
+ ```
61
+
62
+ | | Pos | Rider | Nation | Team | Points | Rider_ID | Team_ID | Team_Country |
63
+ |---:|------:|:--------------|:------------|:----------------------|---------:|-----------:|----------:|:---------------|
64
+ | 0 | 101 | Egan Bernal | Colombia | INEOS Grenadiers | 425 | 58275 | 17536 | GBR |
65
+ | 1 | 102 | Bauke Mollema | Netherlands | Trek-Segafredo | 420 | 581 | 17540 | USA |
66
+ | 2 | 103 | Tim Declercq | Belgium | Deceuninck-Quick Step | 415 | 1970 | 17529 | BEL |
67
+ | 3 | 104 | Oliver Naesen | Belgium | AG2R La Mondiale | 411 | 22682 | 17524 | FRA |
68
+ | 4 | 105 | Alex Aranburu | Spain | Astana Pro Team | 410 | 27307 | 17525 | KAZ |
69
+
70
+ ## Contributing
71
+ Contributions are welcome! Please feel free to open issues, pull requests, and/or discussions.
72
+
73
+ Especially, there is room to help with:
74
+ - Mapping additional endpoints (e.g. pages starting with https://firstcycling.com/team.php?)
75
+ - Parsing results from additional pages (e.g. race startlists, race statistics)
76
+
77
+ To run tests, first `pip install pytest` and `pip install vcrpy`. Then run `py.test` in a shell from the root directory.
78
+
79
+ ## License
80
+ See the file called LICENSE. This project is not affiliated in any way with firstcycling.com.
0 commit comments