Skip to content
v2.7

Get user photo

Returns the best available profile photo for a user.

GET/avatars/photoScope avatars.read

Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: a custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, Gravatar, Libravatar, Owbase Initials, built-in static fallback.

Passing userId — current() for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit emailHash or name then overrides just that value, and the user’s remaining sources stay in the chain. Without userId, passing emailHash and/or name resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL.

width number

Output image width in pixels. Pass an integer between 0 and 2000. Defaults to 256.

height number

Output image height in pixels. Pass an integer between 0 and 2000. Defaults to 256.

quality number

Output image quality between 0 and 100. Defaults to 100.

output string

Output image format. Defaults to ‘png’.

rating string

Maximum image rating to fetch from Gravatar/Libravatar. Defaults to ‘g’.

userId string

User ID to resolve the photo for. Pass ‘current()’ for the currently authenticated user. When omitted, the session user is used only if no emailHash and no name is passed.

emailHash string

SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user’s own email. Pass the hash, never the address itself.

name string

Name to render initials from instead of the user’s own name. Max length: 128 chars.

Access: API key with the avatars.read scope or no key or session: the project ID is enough.

200Success
400Invalid or missing parameter
401No session, no permission on the resource or key without the scope
429Rate limit

Every error comes as JSON with code, type and message: see Errors.

import { Client, Avatars } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const avatars = new Avatars(client);
const result = avatars.getPhoto({
width: 0, // optional
height: 0, // optional
quality: 0, // optional
output: 'png', // optional
rating: 'g', // optional
userId: 'current()', // optional
emailHash: '<EMAIL_HASH>', // optional
name: '<NAME>', // optional
});
console.log(result);
Response200 OK

No response body.


The descriptions on this page come from the server API specification (BSD-3-Clause license), and the examples come from the SDK generator (MIT license). The full notices are in the NOTICE file of the @owbase/web and @owbase/node packages.

Was this page helpful?