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 nothing is wrong with the data your app uses, otherwise
{code, status, message, destination}. An issue is always temporary: issue.status
is action_required (the user can fix it) or syncing (the data is arriving), never
a third value. 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. Issues are reported only for the capabilities your app
declared it uses (its settings; the default is activities and activity history).
capabilities maps each :class:Capability (activities, activity_history,
dailies, workouts) to a :class:CapabilityStatus (ready, syncing,
action_required, unavailable): facts about the user's connected sources, the
same for every app. unavailable means no connected source provides it, which
changes when the user connects one that does. Codes and capability keys are open sets:
a value the client doesn't know parses as a pseudo-member; ignore it.
Accepts any valid token, whatever its scopes. Delegated tokens are allowed and
always get destination=None.
Returns:
-
AccountStatusResponse(AccountStatusResponse) –issueandcapabilities.
Raises:
-
SweatStackAuthError–If the token is invalid.
-
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})