Profile¶
client.profile: /api/v1/profile/...
Bases: Resource
The user the client acts as: account status, sports, tags and app metadata.
app_metadata
cached
property
¶
This app's metadata on the user: set(data=...) and delete().
sports(*, only_root=False)
¶
Lists the sports the user has activities in.
Endpoint: GET /api/v1/profile/sports/
Parameters:
-
only_root(bool, default:False) –Only top-level sports (
cycling, notcycling.road).
Returns:
-
list[Sport]–list[Sport]: The sports. A sport newer than the installed taxonomy is still
-
list[Sport]–returned (
Sport.parse), withis_standardset toFalse.
Raises:
-
SweatStackAPIError–If the API request fails.
Examples:
from sweatstack import Client
client = Client()
print([sport.label for sport in client.profile.sports(only_root=True)])
status()
¶
Retrieves why the user may have little or no data, and what the account can supply.
Endpoint: GET /api/v1/profile/status
Beta: the server documents this endpoint as beta.
issue is None when there is nothing to tell the user, otherwise
{code, status, message, destination}. Branch on issue.status
(:class:CapabilityStatus: ready, syncing, action_required,
unavailable), show issue.message, and show a button only when
issue.destination is set: on click, pass it to client.portal.sessions.create().
Don't parse message or branch on code.
capabilities maps each :class:Capability (activities, activity_history,
dailies, workouts) to a :class:CapabilityStatus. Codes and capability keys are
open sets: a value the client doesn't know parses as a pseudo-member; ignore it.
Accepts a token with data:read or profile. Delegated tokens are allowed and
always get destination=None.
Returns:
-
AccountStatusResponse(AccountStatusResponse) –issueandcapabilities.
Raises:
-
SweatStackAuthError–If the token has neither
data:readnorprofile. -
SweatStackAPIError–If the API request fails for any other reason.
Examples:
from sweatstack import Client
client = Client()
status = client.profile.status()
if status.issue:
print(status.issue.message, status.issue.destination)
tags()
¶
Lists the tags the user has used on activities, traces and tests.
Endpoint: GET /api/v1/profile/tags/
Returns:
-
list[str]–list[str]: The tags.
Raises:
-
SweatStackAPIError–If the API request fails.
Examples:
from sweatstack import Client
client = Client()
print(client.profile.tags())
Bases: Resource
This app's metadata on the signed-in user. Requires an app token.
delete()
¶
Deletes this app's metadata from the user the client acts as.
Endpoint: DELETE /api/v1/profile/app-metadata
Raises:
-
SweatStackAuthError–If the client does not hold an app token (403).
-
SweatStackAPIError–If the API request fails for any other reason.
Examples:
from sweatstack import Client
client = Client(api_key="app-user-token")
client.profile.app_metadata.delete()
set(*, data)
¶
Replaces this app's metadata on the user the client acts as.
Endpoint: PUT /api/v1/profile/app-metadata
Parameters:
-
data(dict[str, Any]) –Any JSON-serialisable dict, at most 4 KB and 32 levels deep.
Raises:
-
SweatStackAuthError–If the client does not hold an app token (403).
-
SweatStackBadRequestError–If
datais too large (413) or too deep (422). -
SweatStackAPIError–If the API request fails for any other reason.
Examples:
from sweatstack import Client
client = Client(api_key="app-user-token")
client.profile.app_metadata.set(data={"onboarded": True})