Skip to main content
A portrait is the head of a player’s OG as a transparent PNG. A game can show it next to a name or load it as a texture. Authentication covers each credential, and errors covers the JSON error body.

Draw a player’s portrait

GET https://opengame.io/api/avatars/{look}/portrait Authentication: None. The head of an OG as a transparent PNG, as OpenGame shows it next to a name. The address is made only from the look recipe (og.player.avatar.look, or portraitUrl in @opengamehq/sdk/avatar), so it identifies no player and the image at one address stays the same. Each response includes Access-Control-Allow-Origin: * and Cross-Origin-Resource-Policy: cross-origin, so a game on another origin can show it or upload it as a WebGL texture.

Parameters

Path

string
required
The look recipe: shape.eyes.color, then the optional accessory, identity, facial hair and hair colors. At most 125 characters. Matches ^[a-z]{1,16}(\.[a-z]{1,16}){2,7}$. Example: panda.dots.tangerine.crown.

Query

integer
default:256
One of 64, 128, 256 or 512. Width and height in pixels. Any other number is redirected to the next listed size up, or to the largest when it is larger. A missing or malformed size is redirected to 256.
string
default:"light"
One of light or dark. dark picks the inks OpenGame shows on a dark page, which turns the Auto color (mono) white. Any other value, or none, is redirected to light.
integer
default:2
Only 2. The drawing version. An old or missing one is redirected to the current one, 2.

Request

cURL

Response 200

The portrait, sent as image/png with Cache-Control: public, max-age=31536000, s-maxage=31536000, immutable. Only an address with all 3 query parameters, in the order size, theme, v, as portraitUrl writes it, gets the image.

Response 307

Redirects to the canonical address with size, theme and v; follow it. Sent when the request spells the look another way, names an unlisted size, or omits a parameter. A browser and a texture loader follow it on their own; curl needs --location.

Headers

string
The canonical address, relative to https://opengame.io. Example: /api/avatars/circle.classic.black/portrait?size=256&theme=light&v=2.

Errors