API Endpoint Access URL
https://api.pixlab.io/decrypt
Get Your API Key & Try DECRYPT Now ↗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)}")
fetch('https://api.pixlab.io/decrypt?img=https://pixlab.xyz/wxfnq5886bad496f95.png&pwd=superpass&key=PIXLAB_API_KEY')
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
console.log("Link to the decrypted picture: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
<?php
$params = [
'img' => 'https://pixlab.xyz/wxfnq5886bad496f95.png',
'pwd' => 'superpass',
'key' => 'PIXLAB_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pixlab.io/decrypt?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
echo "Link to the decrypted picture: " . $reply['link'];
}
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('https://api.pixlab.io/decrypt')
params = {
'img' => 'https://pixlab.xyz/wxfnq5886bad496f95.png',
'pwd' => 'superpass',
'key' => 'PIXLAB_API_KEY'
}
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
reply = JSON.parse(response.body)
if reply['status'] != 200
puts reply['error']
else
puts "Link to the decrypted picture: #{reply['link']}"
end