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
from pyholdsport import Holdsport

with Holdsport("username", "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:

1
2
3
4
5
6
import httpx2
from pyholdsport import Holdsport

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

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