Ir al contenido
v2.7

Obtener foto del usuario

Returns the best available profile photo for a user.

GET/avatars/photoAlcance 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.

Acceso: clave de API con el alcance avatars.read o sin clave ni sesión: basta el ID del proyecto.

200Éxito
400Parámetro inválido o faltante
401Sin sesión, sin permiso en el recurso o clave sin el alcance
429Límite de peticiones

Todo error llega como JSON con code, type y message: consulta Errores.

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);
Respuesta200 OK

Sin cuerpo en la respuesta.


Las descripciones de esta página vienen de la especificación de la API del servidor (licencia BSD-3-Clause), en inglés, y los ejemplos vienen del generador de SDKs (licencia MIT). Los avisos completos están en el archivo NOTICE de los paquetes @owbase/web y @owbase/node.

¿Te ayudó esta página?