First Cycling API

June 15, 2022 · View on GitHub

Documentation Status GitHub license GitHub Repo stars

An unofficial Python API wrapper for https://firstcycling.com/.

Usage

The API wrapper currently supports the following endpoints:

  • Race pages
  • Rider pages
  • Rankings pages

A few examples are shown below.

For full documentation, see https://firstcyclingapi.readthedocs.io/en/latest/.

Race Results:

>>> from first_cycling_api import RaceEdition
>>> amstel_2019 = RaceEdition(race_id=9, year=2019) # The race_id comes from the race page URL
>>> amstel_2019.results().results_table.head() # A pandas DataFrame of the race results
PosRiderTeamTimeUCIRider_IDRider_CountryTeam_ID
001van der Poel MathieuCorendon - Circus6:28:1850016672NED13279
102Clarke SimonEF Education First+ 00400568AUS13208
203Fuglsang JakobAstana Pro Team+ 00325264DEN13198
304Alaphilippe JulianDeceuninck - Quick Step+ 0027512474FRA13206
405Schachmann MaximilianBora - Hansgrohe+ 0022516643GER13200

Rider Results:

>>> from first_cycling_api import Rider
>>> roglic = Rider(18655) # The rider ID comes from the rider page URL
>>> roglic.year_results(2020).results_df.head() # A pandas DataFrame of Roglic's 2020 results
DatePosGCRace_CountryRaceCATUCIUnnamed: 8Race_ID
08.111nanESPVuelta a España2.UWT850Show more23
14.11nanBELLiège-Bastogne-Liège1.UWT500Show more11
220.092nanFRATour de France2.UWT800Show more17
327.096nanUCIWorld Championship RRWCRR225Show more26
49.081nanFRATour de l'Ain2.1125Show more63

Rankings Pages:

>>> from first_cycling_api import Ranking
>>> ranking = Ranking(h=1, rank=1, y=2020, page=2) # Parameters from corresponding URL
>>> ranking.table.head() # A pandas DataFrame of the rankings table
PosRiderNationTeamPointsRider_IDTeam_IDTeam_Country
0101Egan BernalColombiaINEOS Grenadiers4255827517536GBR
1102Bauke MollemaNetherlandsTrek-Segafredo42058117540USA
2103Tim DeclercqBelgiumDeceuninck-Quick Step415197017529BEL
3104Oliver NaesenBelgiumAG2R La Mondiale4112268217524FRA
4105Alex AranburuSpainAstana Pro Team4102730717525KAZ

Contributing

Contributions are welcome! Please feel free to open issues, pull requests, and/or discussions.

Especially, there is room to help with:

  • Mapping additional endpoints (e.g. pages starting with https://firstcycling.com/team.php?)
  • Parsing results from additional pages (e.g. race startlists, race statistics)

To run tests, first pip install pytest and pip install vcrpy. Then run py.test in a shell from the root directory.

License

See the file called LICENSE. This project is not affiliated in any way with firstcycling.com.