Package: ergast-py
Ergast-PyA comprehensive Python wrapper for the Ergast API. Built for easy use and functionality, Ergast-py aims to bring the Ergast API into the Python network as seemlessly as possible.NOTE: Ergast-py is still in active development, so all features are experimental and subject to change. Differences may occur between what is documented in this README.md and what is actually available in Ergast-pyWhat is Ergast?Ergastis a free, experimental API for accessing motor-racing data, dating back to the beginning of World Championships in 1950. The website provides plenty of detail into how effective the API can be, and the many options that are available for data gathering using it.Why should I use Ergast-Py?Ergast-Py provides a clean, Python orientated wrapper for this API. It has been designed to remove the heavy lifting of handling the API formatting behind the scenes, allowing developers to easily access the data that is relevant to them. All the data is conformed into clean class code, allowing for users to keep a Python-centric mindset whilst developing.How to installErgast-py is apip package, so can be installed with the pip command:pip install ergast-pyUsageOnce ergast-py is installed on your system you can then begin using the library in querying the ergast API. To begin, initialise an instance of theErgast()class.Note: Whilst the package is calledergast-py, you need to importergast_pyimportergast_pye=ergast_py.Ergast()Queries can then be built up with function calls in a sequential manner. Once you've built up a query, finally define what data you wish to get using aget_xyz()function.# http://ergast.com/api/f1/2008/5/resultsrace_results=e.season(2008).round(5).get_results()# http://ergast.com/api/f1/drivers/massafelipe_massa=e.driver("massa").get_driver()# http://ergast.com/api/f1/current/constructorStandings/3constructor_standings=e.season().standing(3).get_constructor_standings()Structure and TypesErgast-py has many models which allow the user to more effectively use and manipulate the data available to them through Ergast. All models of data are available through.models.xyz.Available models in ergast-pyNameDescriptionAverageSpeedThe average speed achieved during a fastest lapCircuitDetails about a Formula One circuitConstructorStandingA single constructor's representation in the standingsConstructorA Formula One constructorDriverStandingA single driver's representation in the standingsDriverA Formula One driverFastestLapA fastest lap achieved by a driverLapDetails about a drivers lapLocationThe position of a circuitPitStopDetails about a driver's pit stopRaceFull representation of a Formula One raceResultDetails about a driver's resultSeasonDetails about a Formula One seasonStandingsListA list of standings; constructors or driversStatusDetails about the final status of a driver in a raceTimingDetails about the timings of a driver during a lapQuery buildingThere are 3 types of query available in theErgast()class.FILTERfunctions build up the query, by filtering down the data that you will receive.PAGINGfunctions control the flow of data if there is excessive amounts, limiting it to not overflow the API.RETURNfunctions detail what type of data you're expecting back from the query.The order of the builder functions is inconsequential, however the final function called should be areturnfunction.Ergast().{paging/filter}.{return}More detail on the available functions within theErgast()class is available below.FILTERfunctionsNameArgumentsNotesseasonyear: intIf you call season with no arguments it will default to the current seasonroundround_no: intIf you call round with no arguments it will default to the last rounddriverdriver: Driverconstructorconstructor: Constructorqualifyingposition: intPosition at theendof qualifyingsprintposition: intgridposition: intPosition lined up on the gridresultposition: intfastestposition: intRanking in list of each drivers fastest lapcircuitcircuit: Circuitstatusstatus: intMust use statusId or string representationstandingposition: intPosition of Driver or Constructor in standinglaplap_number: intpit_stopstop_number: intPAGINGfunctionsNameArgumentslimitamount: intoffsetamount: intRETURNfunctionsNOTE: All the functions that return a single object will raise an Exception if your query is returning more than one item.NameReturn Typeget_circuitslist[Circuit]get_circuitCircuitget_constructorslist[Constructor]get_constructorConstructorget_driverslist[Driver]get_driverDriverget_qualifyingslist[Race]get_qualifyingRaceget_sprintslist[Race]get_sprintRaceget_resultslist[Race]get_resultRaceget_raceslist[Race]get_raceRaceget_seasonslist[Season]get_seasonSeasonget_statuseslist[Status]get_statusStatusget_driver_standingslist[StandingsList]get_driver_standingStandingsListget_constructor_standingslist[StandingsList]get_constructor_standingStandingsListget_lapslist[Race]get_lapRaceget_pit_stopslist[Race]get_pit_stopRaceCreditsThis library would not be possible without the freely availableErgastAPI. For full information about the API and it's responsible use, please refer to their website.Poetrywas used for package building and releasing.