Teams¶
client.teams: /api/v1/teams/...
Bases: Resource
Teams: the ones you belong to, and the ones you authorised to access your data.
authorize(team_id, *, scopes=None)
¶
Authorises a team to access your data (or, on a delegated client, that user's data).
Endpoint: POST /api/v1/teams/{team_id}/authorize
Parameters:
-
team_id(str) –The team's ID.
-
scopes(list[Scope | str] | None, default:None) –The scopes to grant. Defaults to
[Scope.data_read].
Returns:
-
dict(dict[str, Any]) –team_id,user_idand the grantedscopes.
Raises:
-
SweatStackNotFoundError–If the team does not exist.
-
SweatStackAPIError–If the API request fails for any other reason.
Examples:
from sweatstack import Client
client = Client()
client.teams.authorize("team_123", scopes=["data:read"])
authorized()
¶
Lists the teams you authorised to access your data.
Endpoint: GET /api/v1/teams/authorized
Returns:
-
list[AuthorizedTeamResponse]–list[AuthorizedTeamResponse]: The teams, with the scopes you granted.
Raises:
-
SweatStackAPIError–If the API request fails.
Examples:
from sweatstack import Client
client = Client()
print([team.name for team in client.teams.authorized()])
list()
¶
Lists the teams you own or are a member of.
Endpoint: GET /api/v1/teams/
Returns:
-
list[TeamResponse]–list[TeamResponse]: The teams, each with your role.
Raises:
-
SweatStackAPIError–If the API request fails.
Examples:
from sweatstack import Client
client = Client()
for team in client.teams.list():
print(team.name)
users(team_id, *, name=None)
¶
Lists the users who authorised a team to access their data. Team members only.
Endpoint: GET /api/v1/teams/{team_id}/users
Parameters:
-
team_id(str) –The team's ID.
-
name(str | None, default:None) –Only users whose display name contains this, ignoring case. Returns every match, so check the length before picking one.
Returns:
-
list[UserSummary]–list[UserSummary]: The users, with the scopes they granted.
Raises:
-
SweatStackNotFoundError–If the team does not exist.
-
SweatStackAPIError–If the API request fails for any other reason.
Examples:
from sweatstack import Client
client = Client()
team = client.teams.list()[0]
for athlete in client.teams.users(team.id):
athlete_client = client.delegated_client(athlete, team_id=team.id)