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.
Method and endpoint
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemas/{profile_schema_id}/user_profile
Replace {WorkspaceId} with your actual workspace ID.
Request parameters
| Parameter | Type | Required | Location | Description |
|---|---|---|---|---|
profile_schema_id | string | Yes | Path | Profile schema ID |
user_id | string | Yes | Query | Memory entity ID |
memory_library_id | string | No | Query | Memory library ID |
Response
| Field | Type | Description |
|---|---|---|
request_id | string | Request ID |
profile.schema_name | string | Profile schema name |
profile.schema_description | string | Profile schema description |
profile.attributes | array | Profile attribute list |
profile.attributes[].id | string | Attribute ID |
profile.attributes[].name | string | Attribute name |
profile.attributes[].value | string | Attribute value |
Code 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.
Is this page helpful?