Athlon Flex API client.

T = TypeVar('T') module-attribute

AthlonFlexClient

Bases: BaseModel

Athlon Flex API client.

Exposes functions to load the profile, vehicle clusters, vehicles & vehicle details. Uses the aiohttp library to interact with the API. All _async methods can also be accessed synchronously by removing the '_async' suffix.

Attributes:
  • email (str | None) –

    str The email of the user.

  • password (str | None) –

    str The password of the user.

  • gross_yearly_income (float | None) –

    float | None = None The optional (approximate) gross yearly income of the user. If provided, the tax rate group will be calculated, and added as cookie to the session. The Client will then include calculated net prices for the user

  • apply_loonheffingskorting (bool) –

    bool = True Whether to apply the loonheffingskorting. Required to find the tax rate belonging to the gross yearly income.

  • TAX_RATES_PAGE_ID (str) –

    ClassVar[str] = "4ecf5f24-8985-450a-915d-919aa7ffa9df" A static page ID, retrieved by manually interacting with the web app. The TaxRates endpoint requires a valid page ID to return the tax rates. Could not figure out how to get a valid page ID from the API.

  • logged_in (bool) –

    bool Whether the user is logged in.

BASE_URL: str = 'https://flex.athlon.com/api/v1' class-attribute

TAX_RATES_PAGE_ID: str = '4ecf5f24-8985-450a-915d-919aa7ffa9df' class-attribute

apply_loonheffingskorting: bool = True class-attribute instance-attribute

email: str | None = None class-attribute instance-attribute

gross_yearly_income: float | None = None class-attribute instance-attribute

logged_in: bool = Field(init=False, default=False) class-attribute instance-attribute

model_config = ConfigDict(ignored_types=(AsyncCachedPropertyDescriptor), arbitrary_types_allowed=True) class-attribute instance-attribute

password: str | None = None class-attribute instance-attribute

profile: Profile cached property

Synchronously get the profile of the user.

session: ClientSession = Field(init=False, optional=True, default=None) class-attribute instance-attribute

__del__()

Automatically close the session when the object is garbage collected.

__getattr__(name)

Allow synchronous access to async methods.

Any method that ends with '_async' can also be accessed synchronously by removing the '_async' suffix.

model_post_init(_)

Initialize the API client.

Create a new session and login to the API.

profile_async() async

Get the profile of the user.

tax_rates_async() async

Load the tax rates registered in Athlon Flex.

vehicle_clusters_async(filter_=None, detail_level=DetailLevel.INCLUDE_VEHICLE_DETAILS) async

Load all clusters that have at least one vehicle available.

Parameters:
  • filter_ (VehicleClusterFilter | None, default: None ) –

    How to filter the clusters. If not provided: Use filter based on profile if logged in else do not filter.

  • detail_level (DetailLevel, default: INCLUDE_VEHICLE_DETAILS ) –

    The level of detail to include in the clusters.

Returns:

vehicle_details_async(vehicle) async

Load all details of a vehicle.

Parameters:
  • vehicle (Vehicle) –

    Vehicle The vehicle for which to load the details.

Returns:
  • Vehicle( Vehicle ) –

    The vehicle with the loaded details.

vehicles_async(make, model, *, filter_vehicles_by_profile=True) async

Load all available vehicles a certain make and model (of a cluster).

If logged in, only load the vehicles that are available to the user.

Parameters:
  • make (str) –

    str The make of the cluster.

  • model (str) –

    str The model of the cluster.

  • filter_vehicles_by_profile (bool, default: True ) –

    If true, vehilces are filtered by being leasable by the current profile.

Returns:
  • list[Vehicle]

    list[Vehicle]: A collection of vehicles of the given make and model.