Get User Profile

Updated at:

Get the profile attributes of a specified user

Gets the profile attributes of a specified user. Profile extraction is asynchronous. After calling AddMemory, the first query may not contain attribute values, so retry according to your application's retry policy.

NoteIf all returned attribute values are empty, verify that AddMemory was called with the same profile_schema. Without that parameter, profile extraction is not triggered.

Endpoint

GEThttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemas/{profile_schema_id}/user_profile

Replace {WorkspaceId} with your actual workspace ID.

Path parameters

profile_schema_idstringRequired

Profile schema ID

Location: Path

Query parameters

user_idstringRequired

Memory entity ID

Location: Query
memory_library_idstringOptional

Memory library ID

Location: Query

Response fields

request_idstring

Request ID

profile.schema_namestring

Profile schema name

profile.schema_descriptionstring

Profile schema description

profile.attributesarray

Profile attribute list

profile.attributes[].idstring

Attribute ID

profile.attributes[].namestring

Attribute name

profile.attributes[].valuestring

Attribute value

Request examples

curl -X GET "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemas/{profile_schema_id}/user_profile?user_id=user_001" \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json"
from agentscope_runtime.tools.modelstudio_memory import (
    GetUserProfile, GetUserProfileInput,
)
import asyncio

async def main():
    get_profile = GetUserProfile()
    try:
        profile = await get_profile.arun(GetUserProfileInput(
            schema_id="YOUR_SCHEMA_ID",
            user_id="user_001"
        ))
        for attr in profile.profile.attributes:
            print(f"{attr.name}: {attr.value or 'Not extracted'}")
    finally:
        await get_profile.close()

asyncio.run(main())

Response example

{
  "profile": {
    "attributes": [
      {"id": "bb28e6cd522443fc9bf7e75b1377bf9d", "name": "Age", "value": "28"},
      {"id": "04eb06f5f04a437b82d07ceb088103f9", "name": "Hobbies", "value": "Playing football"},
      {"id": "2eff4652a6bc47b0803635033b1e08dd", "name": "Occupation", "value": "Software engineer"}
    ],
    "schema_description": "User information including age and interests",
    "schema_name": "Basic user profile"
  },
  "request_id": "78cb6090-a7a5-9897-861c-082a64b43d97"
}

ImportantFor the complete profile workflow, see Using User Profiles.