Skip to main content

Unofficial Ergast API wrapper

Project description

yukinator

actionsDocumentation StatusDownloads

Unofficial API wrapper for Ergast API.

Created mainly for learning purposes. There are already at least two other wrappers worth checking: fastF1 - a swiss army knife for F1-related analyses, pyErgast - a neat pandas wrapper.

The name of the wrapper is Yukinator, in honor of the Japanese Formula 1 driver - Yuki Tsunoda.

Features

  • Extensive: covers all Ergast API endpoints
  • Responsible: minimize the load on the API server
    • implemented caching
  • Simple: easy to use and customize:
    • object-oriented design
    • use of data transfer objects
    • convert adequate fields from strings to the more suitable types
  • Lightweight: minimal usage of the third-party packages

Installation

pip install yukinator

Getting started

Obtaining data for an Ergast API endpoint is very simple. For example, you can get a list of race objects from the 2020 season like this:

import yukinator

y = yukinator.Yuki()
races_2020 = y.get_races(year=2020)

Check the docs to get acquainted with the methods for the rest of the endpoints.

The wrapper is initiated with the caching enabled by default. You can manually set the caching-related attributes like a directory for cache file, time after cached items expire, or clear the whole cache before the first request as follows:

y = yukinator.Yuki(cache_dir='f1project/races', expires_after=9000, force_clear=True)

The caching can be also disabled (strongly not recommended):

y = yukinator.Yuki(cache_enabled=False)

Chosen fields of the object can be accessed easily:

race_1 = races_2020[0]

# print name of the race
print(race_1.raceName)

# print name from every nested Circuit object
for race in races_2020:
    print(race.Circuit.circuitName)

Every object from the obtained list can be converted to the simpler structures:

# convert object to the dictionary
race_1_dict = race_1.to_dict()

# convert object to the tuple
race_1_tuple = race_1.to_tuple()

# convert object to the flat dict - useful for creating pandas dataframes
race_1_flat_dict = race_1.to_flat_dict() 

# convert object to a json string
race_1_json = race_1.to_json()

WARNING

The Ergast API has a limit of four calls per second and 200 per hour. Please take care while calling the methods within a loop.

Documentation

The documentation is hosted on ReadTheDocs.io

Help, questions, and contributing

All contributors are very welcome. If you have any questions or a bug to report feel free to open an issue.

External packages

Yukinator depends on these third-party packages:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yukinator-0.1.3.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yukinator-0.1.3-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file yukinator-0.1.3.tar.gz.

File metadata

  • Download URL: yukinator-0.1.3.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-200.fc41.x86_64

File hashes

Hashes for yukinator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6b3294a6eda441b73fb8aa6e0e8104592d23577c7bdd2b127f208eeee983c589
MD5 be73c36dcc79d08e6e86e9d9be2a8500
BLAKE2b-256 9370167b15019c0b1e108eb27b748e86b01772850950a8dfff6ef17fee70009f

See more details on using hashes here.

File details

Details for the file yukinator-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: yukinator-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-200.fc41.x86_64

File hashes

Hashes for yukinator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cef65c5684ddb73f5125b050c0f575047312d01a8ca34ae8383876d6c3dab9de
MD5 85e3b293626695c5c62c424584d1fede
BLAKE2b-256 302da7e01fc77bc188f978f0793ec75843437f373bebabbbbd7b16cc982e5018

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page