The favicon endpoint retrieves favicons from remote websites. This is useful for displaying website icons in link previews, bookmarks, and social sharing interfaces.
Get favicon
Retrieve a favicon from a remote website URL.
import { Client, Avatars } from "appwrite";
const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
const avatars = new Avatars(client);
const result = avatars.getFavicon({
url: 'https://example.com',
width: 100,
height: 100
});
console.log(result); // Resource URL
Parameters
The getFavicon method accepts the following parameters:
| Parameter | Type | Description |
url | string | The URL of the website to fetch the favicon from. Must be a valid HTTP or HTTPS URL. |
width | integer | The width of the output image in pixels. Accepts values between 0-2000. |
height | integer | The height of the output image in pixels. Accepts values between 0-2000. |
Favicon retrieval
The service automatically attempts to retrieve favicons from common locations on the target website, including standard favicon paths and HTML meta tags.
// Standard website
const exampleFavicon = avatars.getFavicon({
url: 'https://example.com',
width: 64,
height: 64
});
// Website with subdomain
const subdomainFavicon = avatars.getFavicon({
url: 'https://blog.example.com',
width: 64,
height: 64
});
// Website with path
const pathFavicon = avatars.getFavicon({
url: 'https://example.com/page',
width: 64,
height: 64
});
Use cases
Favicons are commonly used for:
- Link previews: Display website icons in link preview cards and social sharing
- Bookmarks: Show website icons in bookmark lists and collections
- Referral tracking: Display source website icons in analytics and referral reports
- Content aggregation: Show website icons in RSS feed readers and content aggregators
- Social media: Display website icons in social media link previews and embeds