API Endpoint Access URL
https://api.pixlab.io/store
Get Your API Key & Try STORE Now ↗Description
Upload local media files, including videos and images, to the PixLab storage cluster or your connected S3 Bucket. This API endpoint, STORE, is essential for initiating processing tasks like mogrify, merge, and drawlines, ensuring media files are remotely available for seamless handling.
Upload a local media file whether video or image to the pixlab.xyz storage cluster or to your own S3 Bucket if already connected from your dashboard ↗. This API endpoint is always the first step for some processing tasks like mogrify, merge, drawlines, etc. that require a media file to be remotely available before processing it.
HTTP Methods
POST
HTTP Parameters
Allowed Content-Type
:multipart/form-data
Required
Fields | Type | Description |
---|---|---|
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 Parameters
Fields | Type | Description |
---|---|---|
comment |
String | Optional comment to associate with the uploaded media. |
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 cluster 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
from typing import Dict, Any
def upload_image(image_path: str, api_key: str, comment: str = "") -> str:
"""Upload a local image to PixLab storage server.
Args:
image_path: Path to the local image file.
api_key: Your PixLab API key.
comment: Optional comment for the uploaded image.
Returns:
The URL of the uploaded image.
Raises:
requests.exceptions.RequestException: If the upload fails.
ValueError: If the API response indicates an error.
"""
try:
with open(image_path, 'rb') as image_file:
response = requests.post(
'https://api.pixlab.io/store',
files={'file': image_file},
data={
'comment': comment,
'key': api_key,
},
timeout=30
)
response.raise_for_status()
data: Dict[str, Any] = response.json()
if data.get('status') != 200:
raise ValueError(data.get('error', 'Unknown error occurred'))
return data['link']
except FileNotFoundError as e:
raise FileNotFoundError(f"Image file not found: {image_path}") from e
# Example usage:
if __name__ == "__main__":
try:
image_url = upload_image(
image_path='./local_image.png',
api_key='My_PIXLAB_API_KEY',
comment='Super Secret Stuff'
)
print(f"Uploaded image link: {image_url}")
except Exception as e:
print(f"Error uploading image: {e}")
// Upload a local image to the remote https://pixlab.xyz storage server or your own S3 bucket.
// Use the output link for other purposes such as processing via mogrify, drawrectangles, etc. or simply serving content.
const formData = new FormData();
formData.append('file', document.querySelector('input[type="file"]').files[0]);
formData.append('comment', 'Super Secret Stuff');
formData.append('key', 'My_PIXLAB_API_KEY');
fetch('https://api.pixlab.io/store', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.error(reply.error);
} else {
console.log("Upload Pic Link: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
php
<?php
$url = 'https://api.pixlab.io/store';
$filePath = './local_image.png';
$apiKey = 'My_PIXLAB_API_KEY';
$comment = 'Super Secret Stuff';
if (!file_exists($filePath)) {
throw new Exception("File not found: " . $filePath);
}
$postData = [
'key' => $apiKey,
'comment' => $comment,
'file' => new CURLFile($filePath, mime_content_type($filePath), basename($filePath))
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception("cURL error: " . curl_error($ch));
}
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
throw new Exception($reply['error']);
} else {
echo "Upload Pic Link: " . $reply['link'];
}
?>
require 'net/http'
require 'json'
require 'uri'
# Upload a local image to the remote https://pixlab.xyz storage server or your own S3 bucket depending on the configuration from your dashboard.
# Use the output link for other purposes such as processing via mogrify, drawrectangles, etc. or simply serving content.
uri = URI.parse('https://api.pixlab.io/store')
request = Net::HTTP::Post.new(uri)
request.set_form(
[
['file', File.open('./local_image.png', 'rb')],
['comment', 'Super Secret Stuff'],
['key', 'My_PIXLAB_API_KEY']
],
'multipart/form-data'
)
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
reply = JSON.parse(response.body)
if reply['status'] != 200
puts reply['error']
else
puts "Upload Pic Link: #{reply['link']}"
end
Similar API Endpoints
sfw, ocr, bg-remove, facedetect, docscan, mogrify, blur, faceverify ↗, facelookup ↗, screencapture, delete, copy, meme, grayscale