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 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:

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})