DELETE API Endpoint

Version 2.197 (Release Notes ↗)

Description

Remove a previously stored media file. All your processed media files are stored by default on pixlab.xyz unless you set your own AWS S3 key (refer to your dashboard ↗ on how to do that). In which case, everything shall be stored on your own S3 bucket.

HTTP Methods

GET

HTTP Parameters

Required

Fields Type Description
link URL Target media URL or Unique media ID.
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.

HTTP Response

Fields Type Description
status Integer Status code 200 indicates success, any other code indicates failure.
id String Unique media ID.
deleted Boolean Result of the delete operation.
error String Error message if status != 200.

The API expects requests with application/json content type and always returns a JSON response. The response includes fields indicating operation status, media ID, deletion result, and potential error details.

For API key management and monitoring, visit PixLab Console.

Code Samples


import requests
from typing import Dict, Any

def process_image() -> None:
    """Generate an oilpaint effect image and delete it using PixLab API."""
    api_key = "PIXLAB_API_KEY"
    base_url = "https://api.pixlab.io"
    image_url = "http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg"
    
    try:
        # Generate oilpaint effect
        oilpaint_params = {
            'img': image_url,
            'radius': 3,
            'key': api_key
        }
        response = requests.get(f"{base_url}/oilpaint", params=oilpaint_params, timeout=10)
        response.raise_for_status()
        oilpaint_data: Dict[str, Any] = response.json()

        if oilpaint_data['status'] != 200:
            raise RuntimeError(oilpaint_data.get('error', 'Unknown error occurred during oilpaint processing'))

        # Delete the generated image
        delete_params = {
            'link': oilpaint_data['link'],
            'key': api_key
        }
        delete_response = requests.get(f"{base_url}/delete", params=delete_params, timeout=10)
        delete_response.raise_for_status()
        delete_data: Dict[str, Any] = delete_response.json()

        if delete_data['status'] != 200:
            raise RuntimeError(delete_data.get('error', 'Unknown error occurred during deletion'))
        
        print("Deletion succeeded")

    except requests.exceptions.RequestException as e:
        print(f"Request failed: {str(e)}")
    except Exception as e:
        print(f"An error occurred: {str(e)}")

if __name__ == "__main__":
    process_image()
← Return to API Endpoint Listing