how to set use the user metadata feature
# bot-training
r
how to set / use the user metadata feature in python?
for asyncio python:
Copy code
from supertokens_python.recipe.usermetadata.asyncio import update_user_metadata


async def some_func():
    user_id = "..."

    await update_user_metadata(user_id, {
        "newKey": "data"
    })
for syncio:
Copy code
from supertokens_python.recipe.usermetadata.syncio import update_user_metadata

user_id = "..."

update_user_metadata(user_id, {
    "newKey": "data"
})
And then you can get the metadata like this:
Copy code
from supertokens_python.recipe.usermetadata.asyncio import get_user_metadata


async def some_func():
    user_id = "..."

    metadataResult = await get_user_metadata(user_id)
    exampleValue = metadataResult.metadata["exampleKey"]
    print(exampleValue)
Or for syncio, like this:
Copy code
from supertokens_python.recipe.usermetadata.syncio import get_user_metadata

user_id = "..."

metadataResult = get_user_metadata(user_id)
exampleValue = metadataResult.metadata["exampleKey"]
print(exampleValue)
2 Views