DECRYPT API Endpoint

Version 2.197 (Release Notes ↗)

Description

Decrypt API endpoint deciphers images encoded by the Encrypt endpoint, providing a seamless solution for developers and creators to manage encrypted image data. Deciphers a given image that has been enciphered via encrypt.

HTTP Methods

GET, POST

HTTP Parameters

Required

Fields Type Description
img URL Input image URL. If you want to upload your image directly from your app, then submit a multipart/form-data POST request. PixLab recommend the PNG format but you are free to use any format suitable for you task.
pwd String Passphrase. The image is not readable until it has been deciphered using this passphrase.
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 image output. But, if this parameter is set to true then the image binary contents is returned 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 if you want to upload your image directly. If you are using JSON, then your image must be already uploaded somewhere. Call store if you want to upload an image for example before invoking this endpoint.

HTTP Response

The endpoint returns application/json if the optional blob parameter is not set.

This endpoint returns a JSON Object after each call unless the blob parameter is specified, in which case the image binary contents are returned instead. 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 image output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard ↗ for configuration).
id String Unique image ID.
error String Error message if status != 200.

Code Samples


import requests


def decrypt_image(image_url: str, passphrase: str, api_key: str) -> str:
    """Decrypt an image using the PixLab API.
    
    Args:
        image_url: URL of the encrypted image
        passphrase: Decryption passphrase
        api_key: PixLab API key
        
    Returns:
        URL of the decrypted image
        
    Raises:
        Exception: If API request fails or returns error status
    """
    params = {
        'img': image_url,
        'pwd': passphrase,
        'key': api_key
    }
    
    try:
        response = requests.get(
            'https://api.pixlab.io/decrypt',
            params=params,
            timeout=10
        )
        response.raise_for_status()
        data = response.json()
        
        if data.get('status') != 200:
            raise Exception(data.get('error', 'Unknown error occurred'))
            
        return data['link']
        
    except requests.exceptions.RequestException as e:
        raise Exception(f"API request failed: {str(e)}")


if __name__ == '__main__':
    try:
        decrypted_url = decrypt_image(
            image_url='https://pixlab.xyz/wxfnq5886bad496f95.png',
            passphrase='superpass',
            api_key='PIXLAB_API_KEY'
        )
        print(f"Link to the decrypted picture: {decrypted_url}")
    except Exception as e:
        print(f"Error: {str(e)}")
← Return to API Endpoint Listing