F1 Fantasy API Client
A mildy janky implementation letting you browser the F1 fantasy data set. Certain values are guaranteed to be wrong and methods missing due to a lack of public methods. This is a best guess implementation, and I'd love any feedback.
Basic Usage
- Navigate to https://fantasy.formula1.com
- Open dev tools for your browser (typically F12)
- Click
Network - Login
- Look for a request to
/services/session/login - Click
Response - Copy the value of
GUIDandToken. - See below example.
import os
import asyncio
from fantasy import Client, APIClient
async def main():
"""Shows your highest place in all your private leagues."""
client = Client(
APIClient(
user_guid=os.environ["USER_GUID"],
token=os.environ["TOKEN"],
)
)
user_leagues = await client.get_user_leagues()
for league in user_leagues.leagues:
leaderboard = await client.get_private_league_leaderboard(league.league_id)
ranks = [i.rank_in_league for i in league.teams_in_league]
print(f"League: {leaderboard.league_name}\n\tBest rank: {max(ranks)}")
if __name__ == "__main__":
asyncio.run(main())
Further Usage
The class fantasy.Client exposes all the nice data models, however many are missing.
If you want full access, use fantasy.APIClient which implements significantly more but provides the data as the API does which is hard to work with.
Metadata
Release files for skelmis-f1-fantasy 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| skelmis_f1_fantasy-0.2.0.tar.gz | 11.8 kB | Without provenance | Details for skelmis_f1_fantasy-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| skelmis_f1_fantasy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for skelmis_f1_fantasy-0.2.0-py3-none-any.whl |
Total release size: 30.8 kB
Release files / skelmis_f1_fantasy-0.2.0.tar.gz
| Download URL | skelmis_f1_fantasy-0.2.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89998d859edd129bb62c0d15194f63b552f632e004fb19a11e872e8a4bf0aa10
|
|
BLAKE2b-256 checksum How to use checksums |
c25c7e43c4fed4b32bc0729624ce52a307a082e06ec7cbbc4364a4cd927d92e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.16
|
Release files / skelmis_f1_fantasy-0.2.0-py3-none-any.whl
| Download URL | skelmis_f1_fantasy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7d8bb312211254babac223910734adf077dca259ac62e8fa9fbc5c71f5bf2b9
|
|
BLAKE2b-256 checksum How to use checksums |
9b1dbac55e6d88bb285d58738c4a91f508e3c4b8b133d1e494d0a4c3c29533f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.16
|
Security for skelmis-f1-fantasy 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.