Skip to content

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, not cycling.road).

Returns:

  • list[Sport] –

    list[Sport]: The sports. A sport newer than the installed taxonomy is still

  • list[Sport] –

    returned (Sport.parse), with is_standard set to False.

Raises:

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:

Raises:

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:

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:

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:

Examples:

from sweatstack import Client

client = Client(api_key="app-user-token")
client.profile.app_metadata.set(data={"onboarded": True})