Skip to main content

Get the complete profile

package main

import (
"context"
"encoding/json"
"fmt"

analogwakatime "github.com/Analog-Code-Monitor/Analog-WakaTime-GO-SDK"
)

const apiToken = "PASTE_API_TOKEN_HERE"

func main() {
ctx := context.WithValue(
context.Background(),
analogwakatime.ContextAccessToken,
apiToken,
)
client := analogwakatime.NewAPIClient(analogwakatime.NewConfiguration())

profile, response, err := client.ProfileAPI.
MainApiV1GetMyProfileInfoGet(ctx).
Execute()
if err != nil {
if response != nil {
fmt.Printf("API error %s: %v\n", response.Status, err)
} else {
fmt.Printf("request failed: %v\n", err)
}
return
}

payload, err := json.MarshalIndent(profile, "", " ")
if err != nil {
fmt.Printf("cannot encode profile: %v\n", err)
return
}

fmt.Println(string(payload))
}

json.MarshalIndent prints the complete MyProfile response, including roles, team roles, subscriptions, and team dashboard memberships.

fmt.Println(profile.Uuid)
fmt.Println(profile.Name)
fmt.Println(profile.HasActiveSubscription)
fmt.Println(profile.Roles)
fmt.Println(profile.Subscriptions)

More profile operations (2FA, avatar, account deletion) are in Profile API.