Skip to content

API Endpoints

Complete reference for Gravatar API v3 endpoints and usage patterns.

https://api.gravatar.com/v3

Use Bearer token authentication for richer profile data and higher profile API limits:

Authorization: Bearer YOUR_API_KEY

Retrieve a user’s profile using their email hash or profile URL slug.

Endpoint: GET /profiles/{profileIdentifier}

Authentication:

  • Public: Limited profile data
  • Bearer Token: Full profile data (recommended)

Parameters:

  • profileIdentifier (required): SHA256 hash of email or profile URL slug

Response Codes:

  • 200 OK: Successfully retrieved profile
  • 404 Not Found: Profile not found
  • 429 Too Many Requests: Rate limit exceeded
Terminal window
# With authentication
curl -X GET "https://api.gravatar.com/v3/profiles/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"hash": "99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1",
"profile_url": "https://gravatar.com/examplefork",
"avatar_url": "https://0.gravatar.com/avatar/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1",
"avatar_alt_text": "User's avatar",
"display_name": "Example",
"pronouns": "He/Him",
"location": "E.G.",
"job_title": "Chief",
"company": "EG Inc",
"description": "Sorry, this is not my name. Just an example, you know."
}

Generate a QR code for a user’s profile.

URL Pattern: GET /{sha256_hash}.qr

Authentication: Public (no authentication required)

Parameters:

  • sha256_hash (required): SHA256 hash of email or profile URL slug

Query Parameters:

  • size (optional): Size of QR code in pixels (default: 80)
  • s (optional): Alias for size
  • version (optional): QR code style (1: standard, 3: modern dots)
  • utm_medium (optional): UTM medium parameter
  • utm_campaign (optional): UTM campaign parameter
  • type (optional): Center icon type (user, gravatar, none)

Response Codes:

  • 200 OK: QR code image (PNG format)
  • 429 Too Many Requests: Rate limit exceeded
  • 500 Internal Server Error: Server error
Terminal window
curl -X GET "https://gravatar.com/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1.qr?size=300&type=user&version=3"

While not API endpoints, avatar URLs follow a predictable pattern:

https://0.gravatar.com/avatar/{hash}?parameters
Parameter Description Default
s or size Avatar size in pixels 80
d or default Default avatar type mp
r or rating Maximum rating level g
f or forcedefault Force default image y
  • 404 - Return a 404 error
  • mp - Mystery person silhouette
  • identicon - Geometric pattern based on hash
  • monsterid - Generated monster
  • wavatar - Generated faces
  • retro - 8-bit arcade-style
  • robohash - Generated robot
  • blank - Transparent PNG
Terminal window
# Basic avatar
https://0.gravatar.com/avatar/27205e5c51cb03f862138b22bcb5dc20f94a342e744ff6df1b8dc8af3c865109
# With parameters
https://0.gravatar.com/avatar/27205e5c51cb03f862138b22bcb5dc20f94a342e744ff6df1b8dc8af3c865109?s=200&r=pg&d=identicon
# Force default
https://0.gravatar.com/avatar/27205e5c51cb03f862138b22bcb5dc20f94a342e744ff6df1b8dc8af3c865109?f=y

Embed a Gravatar profile card through the oEmbed endpoint.

Endpoint: GET /oembed

Parameters:

  • url (required): Gravatar profile URL, such as https://gravatar.com/{username}
Terminal window
curl "https://api.gravatar.com/v3/oembed?url=https%3A%2F%2Fgravatar.com%2Fmatt"

Gravatar profiles can be requested in multiple formats:

Append .json to profile URLs:

https://gravatar.com/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1.json

JSONP Support: Add a callback parameter:

https://gravatar.com/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1.json?callback=processProfile

Append .xml to profile URLs:

https://gravatar.com/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1.xml

Append .php to profile URLs:

https://gravatar.com/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1.php

Append .vcf to profile URLs:

https://gravatar.com/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1.vcf

Append .md to profile URLs:

https://gravatar.com/99511d6010af8c574c31f94e1b327bba5e25086dd7b92a4b6f3e132b579cc8d1.md
Authentication Profile Requests per Hour
API Key 1,000
Unauthenticated 100

Avatar image requests do not count toward these profile endpoint limits.

All API responses include rate limit information:

  • X-RateLimit-Limit: Total requests allowed in current period
  • X-RateLimit-Remaining: Remaining requests in current period
  • X-RateLimit-Reset: Unix timestamp when the limit resets
// Check rate limits from response headers
const response = await fetch('https://api.gravatar.com/v3/profiles/hash', {
headers: {
Authorization: `Bearer ${apiKey}`,
},
});
const rateLimit = {
limit: response.headers.get('X-RateLimit-Limit'),
remaining: response.headers.get('X-RateLimit-Remaining'),
reset: response.headers.get('X-RateLimit-Reset'),
};
if (rateLimit.remaining === '0') {
const resetTime = parseInt(rateLimit.reset!) * 1000;
const waitTime = resetTime - Date.now();
if (waitTime > 0) {
console.log(`Rate limit reached. Waiting ${waitTime}ms...`);
await new Promise((resolve) => setTimeout(resolve, waitTime));
}
}

All API errors follow a consistent format:

{
"error": "Error message description",
"code": "error_code"
}
HTTP Status Error Code Description Solution
400 uncropped_image Image is not square Crop image to 1:1 ratio
400 unsupported_image File format not supported Use JPG, PNG, or GIF
401 - Authentication failed Check API key
403 insufficient_scope Token lacks permissions Request proper scopes
404 disabled Profile is disabled No solution
429 rate_limit_exceeded Too many requests Implement backoff
500 - Server error Retry with backoff
import { GravatarError } from 'astro-gravatar';
try {
const profile = await getProfile('user@example.com', { apiKey });
return profile;
} catch (error) {
if (error instanceof GravatarError) {
switch (error.code) {
case 'rate_limit_exceeded':
// Implement exponential backoff
await new Promise((resolve) => setTimeout(resolve, 5000));
return getProfile('user@example.com', { apiKey });
case 'disabled':
// Profile is disabled, use fallback
return createFallbackProfile();
default:
console.error('Gravatar API Error:', error.message);
throw error;
}
}
throw error;
}
import { getProfile, buildAvatarUrl } from 'astro-gravatar';
// Get profile with API key
const profile = await getProfile('user@example.com', {
apiKey: import.meta.env.GRAVATAR_API_KEY,
});
// Build avatar URL
const avatarUrl = buildAvatarUrl('user@example.com', {
size: 200,
rating: 'pg',
default: 'identicon',
});

The complete API specification is available at:

https://api.gravatar.com/v3/openapi
  1. Never expose API keys in client-side code
  2. Store API keys in environment variables
  3. Use HTTPS for all API requests
  4. Implement rate limiting on your side
  5. Validate email addresses before hashing
  6. Cache responses to reduce API calls
  7. Use exponential backoff for retries
  8. Monitor rate limit headers in responses