Skip to main content

A performant, typed API for the Formula 1 Fantasy game .

Project description

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 GUID and Token.
  • 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.

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

skelmis_f1_fantasy-0.2.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

skelmis_f1_fantasy-0.2.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file skelmis_f1_fantasy-0.2.0.tar.gz.

File metadata

  • Download URL: skelmis_f1_fantasy-0.2.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.16

File hashes

Hashes for skelmis_f1_fantasy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 89998d859edd129bb62c0d15194f63b552f632e004fb19a11e872e8a4bf0aa10
MD5 891b7cf14786eec206ef2babb4c34fa0
BLAKE2b-256 c25c7e43c4fed4b32bc0729624ce52a307a082e06ec7cbbc4364a4cd927d92e1

See more details on using hashes here.

File details

Details for the file skelmis_f1_fantasy-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for skelmis_f1_fantasy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7d8bb312211254babac223910734adf077dca259ac62e8fa9fbc5c71f5bf2b9
MD5 222f7e73a8db737c1b39d9e1de33d04d
BLAKE2b-256 9b1dbac55e6d88bb285d58738c4a91f508e3c4b8b133d1e494d0a4c3c29533f4

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