Users

Stream allows you to store user information and embed them inside activities or use them for personalization. When stored in activities, users are automatically enriched by Stream.

final client = StreamFeedClient.connect('{{ api_key }}', token: '{{ feed_token }}',appId: '{{ app_id }}');

// ensure the user data is stored on Stream
await client.setUserData({
 'name': 'John Doe',
 'occupation': 'Software Engineer',
 'gender': 'male'
});

Adding Users

This endpoint allows you to insert a new user.

NameTypeDescription
idstringThe unique identifier for the new user (eg. username, user id, etc.). The value is restricted to alphanumeric characters, dashes and underscore symbols.
dataobjectThe data related to the user.
// create a new user, if the user already exist an error is returned
await client.user('john-doe').create({
 'name': 'John Doe',
 'occupation': 'Software Engineer',
 'gender': 'male'
});

// get or create a new user, if the user already exist the user is returned
await client.user('john-doe').getOrCreate({
 'name': 'John Doe',
 'occupation': 'Software Engineer',
 'gender': 'male'
});

The size of a user object can not exceed 10kB

Retrieving Users

The retrieving users endpoint allows you to retrieve a user by their ID.

//retrieving users
await client.user('john-doe').get();

Removing Users

The delete endpoint removes a user by their ID.

await client.user('john-doe').delete();

When you delete a user it will be converted to a missing reference and throw an error when enriching.

Updating Users

This endpoint allows you to update a user by their ID.

Parameters

nametypedescriptiondefaultoptional
idstringThe ID of the user to update-
dataobjectThe data related to the user-
await client.user('john-doe').update({
 'name': 'Jane Doe',
 'occupation': 'Software Engineer',
 'gender': 'female'
});
© Getstream.io, Inc. All Rights Reserved.