Obtener foto del usuario
Returns the best available profile photo for a user.
/avatars/photoAlcance avatars.readReturns 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.
Parámetros
Sección titulada «Parámetros»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.
Respuestas
Sección titulada «Respuestas»200Éxito400Parámetro inválido o faltante401Sin sesión, sin permiso en el recurso o clave sin el alcance429Límite de peticionesTodo 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);import { Client, Avatars } from '@owbase/node';
const client = new Client() .setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>') // Your project ID .setSession(''); // The user session to authenticate with
const avatars = new Avatars(client);
const result = await 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});curl "https://cloud.owbase.dev/v1/avatars/photo" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Key: $OWBASE_API_KEY"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.