FAVICON API Endpoint

Version 2.197 (Release Notes ↗)

Description

Generate a website favicon with three icon sizes (128x128, 64x64, 32x32 px) from a single image input using the FAVICON REST API endpoint. Generate a website icon a.k.a favicon containing three small icons of size 128x128, 64x64 & 32x32px respectively from a given image input.

HTTP Methods

GET, POST

HTTP Parameters

Required

Fields Type Description
img URL Input media URL. If uploading directly from your app, submit a multipart/form-data POST request.
key String Your PixLab API Key ↗. Alternatively, embed your key in the WWW-Authenticate: HTTP header to omit this parameter.

Optional

Fields Type Description
blob Boolean Returns JSON with output image link by default. Set to true to receive raw image binary instead.

POST Request Body

This section details the requirements for using a POST request instead of a simple GET request.

Allowed Content-Types:

  • multipart/form-data
  • application/json

Use multipart/form-data for direct file uploads (see examples). For JSON, media must be pre-uploaded - call store first if needed.

HTTP Response

Fields Type Description
status Integer Status code 200 indicates success, any other code indicates failure.
link URL Link to the media output stored on pixlab.xyz storage server unless custom S3 keys are configured (see console for setup).
id String Unique media identifier.
error String Error message when status != 200.

The API returns application/json when the optional blob parameter is omitted. When blob is enabled, the response contains raw binary data instead of JSON. The JSON response structure contains these fields:

Required

All requests must include the mandatory API key and target URL parameters.

Optional

The blob parameter switches response format between JSON and binary output.

Code Samples


import requests

API_URL = 'https://api.pixlab.io/favicon'
API_KEY = 'My_Key'

def get_favicon(image_url: str) -> str:
    params = {
        'img': image_url,
        'key': API_KEY
    }
    
    try:
        response = requests.get(API_URL, params=params, timeout=10)
        response.raise_for_status()
        data = response.json()
        
        if data.get('status') == 200:
            return data.get('link', '')
        else:
            raise ValueError(data.get('error', 'Unknown error occurred'))
            
    except requests.exceptions.RequestException as e:
        raise Exception(f"Request failed: {str(e)}")

if __name__ == '__main__':
    try:
        favicon_url = get_favicon('http://www.drodd.com/images15/nature31.jpg')
        print(f"Link to the favicon: {favicon_url}")
    except Exception as e:
        print(f"Error: {str(e)}")
← Return to API Endpoint Listing