Take a sneak peak of our new documentation Read More
Last Updated: 4/3/2023, 1:06:06 AM

# Profile

# Overview

AccelByte Cloud’s Profile services allow players to display information about themselves, such as their name, location, date of birth, and photos. Beyond these basic attributes, you can also create your own attributes to customize the player profiles for your game. For example, you can add attributes that include a player’s level or rank. When you add these custom attributes to the Profile service, that information will be displayed on each player’s profile.

# Custom Attributes

Custom Attributes are added using the SDK. In the sample code below, four custom attributes have been added: level, rank, equipped sword, and equipped shield. When this code is implemented, these attributes will appear in each player’s profile.

{
	"userId": "string",
	"namespace": "string",
	"firstName": "string",
	"lastName": "string",
	"avatarSmallUrl": "string",
	"avatarUrl": "string",
	"avatarLargeUrl": "string",
	"status": "ACTIVE",
	"language": "string",
	"timeZone": "string",
	"dateOfBirth": "2019-12-22",
	"customAttributes": {
		"level": "1",
		"rank": "Grand Master",
		"activeWeapon": "Copper Sword",
		"activeShield": "Pot Lid"
	}
} 

# Prerequisites

# Implement Profiles Using the Client SDKs

# Create a Player Profile

Use the following function to create a player profile:

# Retrieve a Player Profile

You can retrieve a player profile using the following function. This function will retrieve the player’s personal information, such as First Name, Last Name, Language, etc.

# Retrieve a Player’s Public Profile

If you need to get a player's public profile, you can use the following function. The public profile is the profile that other players see when interacting in the game. When retrieving a player’s public profile, you will receive the player’s User ID, Namespace, Timezone, and Avatar URL.

# Update a Player Profile

Use the following function to update a player profile:

# Update Custom Attributes

The following function can be used to update a specific custom attribute field.

# Retrieve Custom Attributes

You can retrieve a player profile with its custom attributes using the following function:

# Retrieve Public Custom Attributes

You can retrieve a public player profile with custom attributes using the following function and specifying the user ID.

# Connect Custom Services to Profiles Using the Server SDKs

# SDK Initialization

Before you can use the Cloud Basic service (which includes the Profile service) , you will need to initialize the server-side SDKs to ensure you can create, read, update, and delete profiles.

# Golang SDK Initialization

Before you can use the Basic service from the Golang SDK, you will need to initialize it by following the steps below:

  1. Create your OAuth Clientand assign the necessary permissions to access the Basic service.
  2. Log in as a Client using the SDK.
  3. Initialize the Basic service using the following function:

Once you have completed these steps, you can use the Golang SDK to manage the Basic service from your serverless app.

# Python SDK Initialization

Before you can use the Basic service from the Python SDK, you will need to initialize the itby following the steps below:

  1. Create your OAuth Client and assign the necessary permissions to access the Basic service.
  2. Log in as a Client using the SDK.

Once you have completed these steps, you can use the Python SDK to manage the Basic service from your serverless app.

# .NET (C#) SDK Initialization

Before you can use the Basic service, you will need to set some permissions. Use the following .NET namespaces to do this:

using AccelByte.Sdk.Api.Basic.Model;
using AccelByte.Sdk.Api.Basic.Operation;
using AccelByte.Sdk.Api.Basic.Wrapper;

# Java SDK Initialization

Before you can use the Basic service, you will need to set some permissions.

Initialize the UserProfile wrapper from the Basic service using the following code:

UserProfile wProfile = new UserProfile(sdk);

Once you have completed this step, you can use the SDK to manage player profiles.

# Create a Player Profile

Use the following function to create a player profile (opens new window):

# Delete a Player Profile

Use the following function to delete a player profile (opens new window):

# Retrieve a Player Profile

Use the following function to retrieve a public profile (opens new window):

# Update a Player Profile

Use the following function to update a player profile (opens new window):