API Documentation

Integrate AI background removal into your applications

Quick Start

Base URL

https://bgremoverfree.com/api

Content Type

multipart/form-data

Background Removal API

Remove backgrounds from images using AI

POST

Endpoint

POST /process/

Parameters

Parameter Type Required Description
image File Required Image file (JPEG, PNG, GIF, BMP) - Max 10MB

Response Format

Success Response

{
  "success": true,
  "message": "Background removed successfully!",
  "processing_time": 2.34,
  "image_data": "data:image/png;base64,iVBORw0KGgo..."
}

Error Response

{
  "success": false,
  "message": "Error description here"
}

Live API Tester

JavaScript

const formData = new FormData();
formData.append('image', imageFile);

fetch('/process/', {
    method: 'POST',
    body: formData
})
.then(response => response.json())
.then(data => {
    if (data.success) {
        // Display processed image
        document.getElementById('result').src = data.image_data;
        console.log('Processing time:', data.processing_time + 's');
    } else {
        console.error('Error:', data.message);
    }
})
.catch(error => {
    console.error('Network error:', error);
});

Python

import requests
import base64

url = 'http://localhost:8000/process/'
files = {'image': open('image.jpg', 'rb')}

response = requests.post(url, files=files)
data = response.json()

if data['success']:
    # Save processed image
    image_data = data['image_data'].split(',')[1]
    with open('processed.png', 'wb') as f:
        f.write(base64.b64decode(image_data))
    print(f"Processing time: {data['processing_time']}s")
else:
    print(f"Error: {data['message']}")

cURL

curl -X POST \
  http://localhost:8000/process/ \
  -F 'image=@/path/to/your/image.jpg' \
  -H 'Content-Type: multipart/form-data'

PHP

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'http://localhost:8000/process/',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => array(
        'image' => new CURLFile('/path/to/image.jpg')
    ),
));

$response = curl_exec($curl);
$data = json_decode($response, true);

if ($data['success']) {
    // Process the base64 image data
    $imageData = explode(',', $data['image_data'])[1];
    file_put_contents('processed.png', base64_decode($imageData));
    echo "Processing time: " . $data['processing_time'] . "s";
} else {
    echo "Error: " . $data['message'];
}

curl_close($curl);

Rate Limits & Performance

Max file size 10 MB
Supported formats JPEG, PNG, GIF, BMP
Average processing time 2-8 seconds
Concurrent requests No limit

Best Practices

Use high-contrast images for better results
Optimize image size before uploading
Handle errors gracefully in your application
Implement proper loading states
Cache processed images when possible