MAKEGIF API Endpoint

Version 2.197 (Release Notes ↗)

Description

Generate GIF from a set of static images using the MAKEGIF API endpoint. Ideal for developers and creators looking to animate visuals. Generate GIF from a set of static images.

HTTP Methods

POST

HTTP Parameters

Required

Fields Type Description
frames Array JSON array holding the static images URL (See below).
key String Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to.

Optional

Fields Type Description
blob Boolean By default, this API endpoint return a JSON Object holding the link to the gif output. But, if this parameter is set to true then the gif binary contents is returned instead.
delay Integer Milliseconds delay between consecutive frames.

POST Request Body

application/json

Only JSON data is allowed. The field of interest here is the frames parameter which must be a JSON array holding the URL of each static image that compose the future GIF. The following are the required parameters for each object in the frames array:

Fields Type Description
img URL Input image URL. If you want to upload your image directly from your app, call store before invoking this one.

So, a typical frames array should look like this (See the example section for a working snippet).


frames =  [
    {
        "img":"https://cdn1.iconfinder.com/data/icons/human-6/48/266-512.png"
    },
    {
        "img":"https://cdn1.iconfinder.com/data/icons/human-6/48/267-512.png"
    },
    {
        "img":"https://cdn1.iconfinder.com/data/icons/human-6/48/278-512.png"
    },
    {
        "img":"https://cdn1.iconfinder.com/data/icons/human-6/48/279-512.png"
    }
]

HTTP Response

Returns application/json if the optional blob parameter is not set.

Returns a JSON Object after each call unless the blob parameter is specified, in which case the GIF binary content is returned directly. The JSON response contains the following fields:

Fields Type Description
status Integer Status code 200 indicates success, any other code indicates failure.
link URL Link to the media output stored on the pixlab.xyz storage server. You can configure custom S3 storage (see your dashboard ↗ for configuration).
id String Unique media identifier.
error String Error message when status != 200.

Code Samples


import requests
import json
from typing import Dict, Any, List

def generate_gif(api_key: str, image_urls: List[str]) -> None:
    """Generate a GIF from a set of static images using the PixLab API."""
    endpoint = 'https://api.pixlab.io/makegif'
    headers = {'Content-Type': 'application/json'}
    
    frames = [{"img": url} for url in image_urls]
    payload = {
        'key': api_key,
        'frames': frames
    }
    
    try:
        response = requests.post(
            endpoint,
            headers=headers,
            data=json.dumps(payload),
            timeout=10
        )
        response.raise_for_status()
        reply = response.json()
        
        if reply.get('status') != 200:
            print(f"Error: {reply.get('error', 'Unknown error')}")
        else:
            print(f"GIF location: {reply['link']}")
    except requests.exceptions.RequestException as e:
        print(f"Request failed: {e}")
    except json.JSONDecodeError:
        print("Error: Invalid JSON response")
    except KeyError:
        print("Error: Malformed API response")

if __name__ == "__main__":
    PIXLAB_API_KEY = "My_PIXLAB_API_KEY"
    IMAGE_URLS = [
        "https://cdn1.iconfinder.com/data/icons/human-6/48/266-512.png",
        "https://cdn1.iconfinder.com/data/icons/human-6/48/267-512.png",
        "https://cdn1.iconfinder.com/data/icons/human-6/48/278-512.png",
        "https://cdn1.iconfinder.com/data/icons/human-6/48/279-512.png"
    ]
    generate_gif(PIXLAB_API_KEY, IMAGE_URLS)
← Return to API Endpoint Listing