What if you could add professional-grade AI image processing to any application with just a few lines of code? Welcome to the PerfectPX External APIβyour gateway to integrating cutting-edge image AI into websites, mobile apps, automation workflows, and more.
What is the PerfectPX API?
The PerfectPX External API is a RESTful API that provides programmatic access to all our AI-powered image processing tools. Instead of manually using our Studio interface, you can automate everything through code.
β‘ What You Can Build
- β E-commerce product photo processors
- β Social media content generators
- β Photo editing mobile apps
- β Bulk image processing pipelines
- β AI art creation platforms
- β Real estate photo enhancers
- β Profile picture makers
- β Automated marketing workflows
Quick Start: Your First API Call
Let's remove a background in under 5 minutes:
Step 1: Get Your API Key
# Navigate to your profile
https://perfectpx.org/profile/api-keys
# Click "Generate New API Key"
# Copy and store securely
Step 2: Make Your First Call
curl -X POST https://api.perfectpx.org/ext/processor/dismantle/remove-background \
-H "Authorization: YOUR_API_KEY" \
-F "file=@/path/to/your/image.jpg"
Step 3: Get Your Result
{
"statusCode": 200,
"data": {
"run": {
"image": "https://cdn.perfectpx.org/result_abc123.png",
"original_url": "https://cdn.perfectpx.org/original_abc123.jpg",
"run_id": "abc123def456",
"deductCredits": 1
},
"user": {
"credits": 299,
"creditsUsed": 1,
"imagesProcessed": 1
}
},
"message": "success"
}
That's it! You just removed a background using AI. π
Available API Endpoints
π Status & Account
// Check your credit balance
GET /ext/status
Response:
{
"credits": 299,
"creditsUsed": 1,
"imagesProcessed": 1
}
π¨ Generate
Text-to-Image
POST /ext/processor/generate/text-to-image
Payload:
{
"prompt": "A futuristic city at sunset, cyberpunk style"
}
Credits: 3
Image Edit
POST /ext/processor/generate/image-edit
Payload:
- images: [file1, file2, ...]
- prompt: "Combine into single composition"
Credits: 4
Smart Expand
POST /ext/processor/generate/smart-expand
Payload:
- file: image file
- target_width: 1024
- target_height: 768
- img_width: 512
- img_height: 512
- top_left_x: 256
- top_left_y: 128
Credits: 5
β¨ Enhance
// Upscale images
POST /ext/processor/enhance/upscale
Credits: 4
// Enhance quality
POST /ext/processor/enhance/image-enhancer
Credits: 1
// Enhance portraits
POST /ext/processor/enhance/portrait-enhancer
Credits: 1
// Reduce noise
POST /ext/processor/enhance/noise-reduction
Credits: 1
// Unblur images
POST /ext/processor/enhance/unblur
Credits: 1
π§ Dismantle
// Remove backgrounds
POST /ext/processor/dismantle/remove-background
Credits: 1
// Erase objects
POST /ext/processor/dismantle/object-eraser
Credits: 1
// Replace sky
POST /ext/processor/dismantle/sky-replacer
Credits: 1
π Artistic
// Technical pen contour
POST /ext/processor/artistic/sketch-ink/technical-pen-contour
// Comic noir ink
POST /ext/processor/artistic/sketch-ink/comic-noir-ink
// And 7 more artistic styles!
Credits: 1 each
π 3D
// Extract geometry maps
POST /ext/processor/3d/extract-geometry
Returns: alpha, normal, and depth maps
Credits: 4
Code Examples for Every Language
JavaScript/Node.js
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
async function removeBackground(imagePath) {
const form = new FormData();
form.append('file', fs.createReadStream(imagePath));
try {
const response = await axios.post(
'https://api.perfectpx.org/ext/processor/dismantle/remove-background',
form,
{
headers: {
'Authorization': 'YOUR_API_KEY',
...form.getHeaders()
}
}
);
console.log('Result URL:', response.data.data.run.image);
console.log('Credits remaining:', response.data.data.user.credits);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
removeBackground('./product.jpg');
Python
import requests
def remove_background(image_path):
url = 'https://api.perfectpx.org/ext/processor/dismantle/remove-background'
headers = {
'Authorization': 'YOUR_API_KEY'
}
files = {
'file': open(image_path, 'rb')
}
response = requests.post(url, headers=headers, files=files)
result = response.json()
if result['statusCode'] == 200:
print(f"Result URL: {result['data']['run']['image']}")
print(f"Credits remaining: {result['data']['user']['credits']}")
return result['data']['run']['image']
else:
print(f"Error: {result['message']}")
return None
remove_background('product.jpg')
PHP
<?php
function removeBackground($imagePath) {
$url = 'https://api.perfectpx.org/ext/processor/dismantle/remove-background';
$ch = curl_init();
$file = new CURLFile($imagePath);
$data = ['file' => $file];
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => [
'Authorization: YOUR_API_KEY'
]
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
if ($result['statusCode'] === 200) {
echo "Result URL: " . $result['data']['run']['image'] . "\n";
echo "Credits remaining: " . $result['data']['user']['credits'] . "\n";
return $result['data']['run']['image'];
}
curl_close($ch);
}
removeBackground('product.jpg');
Ruby
require 'httparty'
def remove_background(image_path)
url = 'https://api.perfectpx.org/ext/processor/dismantle/remove-background'
response = HTTParty.post(url,
headers: { 'Authorization' => 'YOUR_API_KEY' },
body: { file: File.open(image_path) }
)
result = JSON.parse(response.body)
if result['statusCode'] == 200
puts "Result URL: #{result['data']['run']['image']}"
puts "Credits remaining: #{result['data']['user']['credits']}"
result['data']['run']['image']
else
puts "Error: #{result['message']}"
nil
end
end
remove_background('product.jpg')
Real-World Integration Examples
Example 1: E-commerce Product Processor
// Automated product photo pipeline
async function processProductPhoto(imagePath) {
// Step 1: Remove background (1 credit)
const noBg = await removeBackground(imagePath);
// Step 2: Enhance quality (1 credit)
const enhanced = await enhanceImage(noBg.imageUrl);
// Step 3: Generate multiple sizes
const thumbnail = await resizeImage(enhanced.imageUrl, 300, 300);
const large = await resizeImage(enhanced.imageUrl, 1200, 1200);
return {
original: enhanced.imageUrl,
thumbnail,
large
};
}
// Process entire catalog
const products = await getProductsNeedingPhotos();
for (const product of products) {
const processed = await processProductPhoto(product.imagePath);
await updateProductImages(product.id, processed);
}
Example 2: Social Media Content Generator
from perfectpx import PerfectPXAPI
api = PerfectPXAPI('YOUR_API_KEY')
def create_instagram_post(theme, style):
# Generate base image
prompt = f"{theme} in {style} style, vibrant colors, instagram worthy"
base_image = api.text_to_image(prompt)
# Enhance for social media
enhanced = api.enhance_image(base_image)
# Apply artistic filter
final = api.apply_filter(enhanced, 'pristine-graphite-outline')
return final
# Generate week's worth of content
themes = ['morning coffee', 'sunset vibes', 'minimalist workspace']
for theme in themes:
post = create_instagram_post(theme, 'modern minimalist')
schedule_post(post, next_available_slot())
Example 3: Real Estate Photo Enhancer
async function enhanceListingPhotos(propertyId) {
const photos = await getPropertyPhotos(propertyId);
const enhanced = [];
for (const photo of photos) {
// Enhance quality
let result = await api.enhanceImage(photo);
// Replace sky if outdoor photo
if (isOutdoorPhoto(photo)) {
result = await api.replaceSky(result);
}
// Remove unwanted objects
if (hasUnwantedObjects(photo)) {
result = await api.objectEraser(result, detectObjects(photo));
}
enhanced.push(result);
}
await updatePropertyPhotos(propertyId, enhanced);
return enhanced;
}
Best Practices & Optimization
1. Implement Error Handling
async function processImageWithRetry(imagePath, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
const result = await api.removeBackground(imagePath);
return result;
} catch (error) {
if (error.statusCode === 429) {
// Rate limited - wait and retry
await sleep(5000 * (i + 1));
} else if (error.statusCode === 402) {
// Out of credits
await notifyAdmin('API credits depleted');
throw error;
} else {
// Other error - retry
if (i === maxRetries - 1) throw error;
}
}
}
}
2. Cache Results
import hashlib
import redis
redis_client = redis.Redis()
def process_with_cache(image_path, operation):
# Generate cache key
with open(image_path, 'rb') as f:
file_hash = hashlib.md5(f.read()).hexdigest()
cache_key = f"{operation}:{file_hash}"
# Check cache
cached = redis_client.get(cache_key)
if cached:
return cached.decode()
# Process and cache
result = api.process(image_path, operation)
redis_client.setex(cache_key, 3600, result) # Cache for 1 hour
return result
3. Batch Processing
async function batchProcessImages(images) {
const BATCH_SIZE = 10;
const results = [];
for (let i = 0; i < images.length; i += BATCH_SIZE) {
const batch = images.slice(i, i + BATCH_SIZE);
const batchResults = await Promise.all(
batch.map(img => api.removeBackground(img))
);
results.push(...batchResults);
// Log progress
console.log(`Processed ${i + batch.length}/${images.length}`);
}
return results;
}
4. Monitor Usage
import logging
from datetime import datetime
class APIUsageTracker:
def __init__(self):
self.usage = []
def track(self, endpoint, credits_used):
self.usage.append({
'timestamp': datetime.now(),
'endpoint': endpoint,
'credits': credits_used
})
def get_daily_usage(self):
today = datetime.now().date()
return sum(
u['credits'] for u in self.usage
if u['timestamp'].date() == today
)
def alert_if_high_usage(self, threshold=100):
daily = self.get_daily_usage()
if daily > threshold:
logging.warning(f"High API usage: {daily} credits today")
tracker = APIUsageTracker()
Security Essentials
π Critical Security Rules
- Never expose API keys in client-side code
- Never commit API keys to version control
- Never share API keys publicly
- Always use environment variables
- Always rotate keys if compromised
- Always use HTTPS for API calls
Proper Key Storage
# .env file (add to .gitignore!)
PERFECTPX_API_KEY=your_api_key_here
# Load in your application
require('dotenv').config();
const API_KEY = process.env.PERFECTPX_API_KEY;
Pricing & Credits
API Pricing Model
- Pay-as-you-go: $0.02 per credit
- No subscription required for API usage
- Credits never expire when purchased as top-ups
- Volume discounts available for enterprise
Cost Examples
πΌοΈ Remove 100 backgrounds: 100 credits = $2.00
β¨ Enhance 50 images: 50 credits = $1.00
π¨ Generate 20 images: 60 credits = $1.20
π Total for typical monthly use: ~$10-50
Compare to hiring a designer:
- Freelancer: $50-200 per project
- Agency: $500+ per project
- ROI: 95%+ cost savings
Download Postman Collection
We've created a complete Postman collection with:
- β All endpoints pre-configured
- β Example requests for every tool
- β Environment variables setup
- β Expected response examples
π₯
Download Postman Collection
Getting Help
Documentation
Support Channels
- π§ Email: info@perfectpx.org
- π Help Center
Response Times
- General questions: Within 24 hours
- Critical issues: Within 4 hours
- Enterprise support: Within 1 hour
Success Stories
"We integrated PerfectPX API into our e-commerce platform and processed over 10,000 product images in a weekend. What would have taken months of manual work was done in days, saving us $50,000 in outsourcing costs."
β CTO, Online Fashion Retailer
"The API enabled us to build a unique photo editing app in just 2 weeks. Our users love the AI features, and we're not spending a fortune on infrastructure."
β Founder, Mobile App Startup
Start Building Today
Ready to Transform Your Application? --Get your API key and start building in minutes.
- β Get API Key
- π Full API Documentation
The future of image processing is programmable. Build it with PerfectPX API. β‘
Top comments (0)