API Endpoint Access URL
https://api.pixlab.io/copy
Get Your API Key & Try COPY Now ↗Description
Copy media from a remote location and store it on Pixlab's storage server or your AWS S3 bucket. Copy a media from a remote location and store it on the pixlab.xyz storage server. If you have already set your own AWS S3 keys (refer to your dashboard ↗ on how to do that), then the media shall be copied to your S3 bucket.
HTTP Methods
GET
HTTP Parameters
Required
Fields | Type | Description |
---|---|---|
link |
URL | Input media URL or Unique 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. |
link |
URL | Link to the media output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard ↗ on how to do that). |
id |
String | Unique media ID. |
error |
String | Error message if status != 200. |
Code Samples
import requests
def copy_image_to_bucket(image_url: str, api_key: str) -> str:
"""Copy an image to the PixLab bucket and return the new URL."""
response = requests.get(
'https://api.pixlab.io/copy',
params={
'img': image_url,
'key': api_key
},
timeout=10
)
response.raise_for_status()
data = response.json()
if data['status'] != 200:
raise ValueError(data.get('error', 'Unknown error occurred'))
return data['link']
if __name__ == '__main__':
try:
copied_url = copy_image_to_bucket(
image_url='http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg',
api_key='My_PIXLAB_API_KEY'
)
print(f"Copied image: {copied_url}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
except ValueError as e:
print(f"API error: {e}")
fetch('https://api.pixlab.io/copy?img=http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg&key=My_PIXLAB_API_KEY')
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
console.log("Copied image: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
<?php
$apiKey = 'My_PIXLAB_API_KEY';
$imageUrl = 'http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg';
$endpoint = 'https://api.pixlab.io/copy';
$queryParams = [
'img' => $imageUrl,
'key' => $apiKey
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint . '?' . http_build_query($queryParams));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new RuntimeException('cURL error: ' . curl_error($ch));
}
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
echo "Copied image: " . $reply['link'];
}
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://api.pixlab.io/copy')
params = { img: 'http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg', key: 'My_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 "Copied image: #{reply['link']}"
end
Similar API Endpoints
store, delete, put, mogrify, facedetect, bg-remove, bw, nsfw, ocr