Skip to main content

Social

For player identity and registration state, see Player. For profile data formatted for UI, use the social module documented below. It handles avatar size selection and requests a Godot-decodable image format for you.

Player avatar

Each registered user on Jest can set up a profile with a customizable avatar. JestSDK.social.get_profile(avatar_size) returns the current player's username and a resized avatar URL, matching the HTML5 social profile API while accounting for Godot image loading. The avatar URL routes through Cloudflare Image Resizing so the response comes back as resized WebP, which Godot can decode reliably without browser-dependent AVIF negotiation.

The avatar is delivered at one of these sizes: 64x64, 128x128, 256x256, 512x512, or 1000x1000 pixels. Request the smallest size that fits your UI for the best performance.

const AVATAR_REQUEST_HEADERS: PackedStringArray = [
"Accept: image/webp,image/png,image/jpeg,*/*",
]

func load_player_avatar(target: TextureRect) -> void:
var profile: JestPlayerProfile = JestSDK.social.get_profile(128)
if profile == null or profile.avatar_url.is_empty():
return # guest or no avatar set
var url: String = profile.avatar_url

var http := HTTPRequest.new()
add_child(http)
http.request_completed.connect(
func(_r, code, _h, body):
http.queue_free()
if code < 200 or code >= 300: return
var image := Image.new()
if image.load_webp_from_buffer(body) != OK \
and image.load_png_from_buffer(body) != OK \
and image.load_jpg_from_buffer(body) != OK:
return
target.texture = ImageTexture.create_from_image(image)
)
http.request(url, AVATAR_REQUEST_HEADERS)

When loading the URL with HTTPRequest in a web export, send an image Accept header as shown above. This keeps the CDN response on the WebP variant with CORS headers.

get_profile() returns null for guest players and registered players who haven't set up a profile. avatar_url may be an empty string for registered players with no avatar set. Always provide fallbacks in your UI.

JestSDK.social.get_profile()

JestSDK.social.get_profile(avatar_size: int = 1000) -> JestPlayerProfile

Parameters:

NameTypeDescription
avatar_sizeintOptional. One of 64, 128, 256, 512, or 1000. Defaults to 1000. Other values bucket down to the next supported size.

Returns a JestPlayerProfile instance, or null when the player has no profile:

PropertyTypeDescription
usernameStringThe current player's username, or an empty string when the player has no username.
avatar_urlStringA Cloudflare-proxied WebP avatar URL, or an empty string when the player has no avatar.

Bots

When games need to fill in player slots with bots, we recommend using the bot avatars for this purpose. There are 1000 unique bot avatars, and you can request them using the JestSDK.social.get_bot_avatar method. They are generated deterministically, so the same username will always return the same avatar.

The avatar is delivered at one of these sizes: 64x64, 128x128, 256x256, 512x512, or 1000x1000 pixels. It is recommended to request the smallest size that fits your UI for best performance, as this will minimize network traffic and improve loading times.

func get_bots(usernames: Array) -> Array:
var bots: Array = []
for username in usernames:
bots.append({
"username": username,
"avatar_url": JestSDK.social.get_bot_avatar(username, 128),
})
return bots

get_bots(["Hello", "Jest", "Bots"])
512x512256x256128x12864x64

JestSDK.social.get_bot_avatar()

JestSDK.social.get_bot_avatar(username: String, size: int = 1000) -> String

Parameters:

NameTypeDescription
usernameStringRequired. Used as a seed for the avatar — the same username always returns the same avatar.
sizeintOptional. One of 64, 128, 256, 512, or 1000. Defaults to 1000. Other values bucket down to the next supported size.

Returns:

TypeDescription
StringThe URL of the bot avatar.

The mapping from username to avatar is deterministic and identical across game engines, so the same username yields the same avatar whether your game uses the Godot, Unity, or HTML5 SDK.