Skip to content

Create a holdsport instance

Create a Holdsport instance with your username and password, and use it as a context manager via with. Learn more about http clients here.

1
2
3
4
5
6
7
from pyholdsport import Holdsport

with Holdsport(
    holdsport_username="username",
    holdsport_password="password",
) as holdsport:
    holdsport.get_teams()

Using environment variables

Instead of passing credentials directly, set the HOLDSPORT_USERNAME and HOLDSPORT_PASSWORD environment variables:

export HOLDSPORT_USERNAME="username"
export HOLDSPORT_PASSWORD="password"
1
2
3
4
from pyholdsport import Holdsport

with Holdsport() as holdsport:
    holdsport.get_teams()

It is also possible to provide one value as an input argument and the other as an environment variable.

Using a custom client

For advanced use cases, pass an existing httpx2.Client:

import httpx2
from pyholdsport import Holdsport

with httpx2.Client(timeout=60.0) as client:
    holdsport = Holdsport(
        holdsport_username="username",
        holdsport_password="password",
        client=client,
    )
    holdsport.get_teams()

In this case, it is the caller's responsibility to manage the client's properties and lifecycle.