Easy Integrations

Get started with our background removal API in your favorite framework or language. Simple guides and ready-to-use code snippets.

JavaScript

Node.js, React, Vue

Quick integration for JavaScript applications with fetch API and popular frameworks.

View Examples →

Python

Django, Flask, FastAPI

Simple integration with Python using requests library and popular web frameworks.

View Examples →

PHP

Laravel, Symfony

Easy integration with PHP applications using cURL or HTTP client libraries.

View Examples →

cURL

Command Line

Direct API access using cURL commands for testing and command-line integration.

View Examples →

More Languages

C#, Java, Go, Ruby

Integration examples for additional programming languages and frameworks.

View Examples →

Webhooks

Event-driven

Set up webhooks for asynchronous processing and real-time notifications.

View Examples →

JavaScript Integration

Basic Fetch API

async function removeBackground(imageFile) {
  const formData = new FormData();
  formData.append('image', imageFile);
  formData.append('modelType', 'portrait');
  formData.append('format', 'png');

  try {
    const response = await fetch('/api/remove-background', {
      method: 'POST',
      body: formData
    });

    if (response.ok) {
      const blob = await response.blob();
      return URL.createObjectURL(blob);
    }
  } catch (error) {
    console.error('Error:', error);
  }
}

React Hook

import { useState } from 'react';

function useBackgroundRemoval() {
  const [loading, setLoading] = useState(false);
  const [result, setResult] = useState(null);

  const removeBackground = async (file) => {
    setLoading(true);
    const formData = new FormData();
    formData.append('image', file);
    
    try {
      const response = await fetch('/api/remove-background', {
        method: 'POST',
        body: formData
      });
      
      const blob = await response.blob();
      setResult(URL.createObjectURL(blob));
    } catch (error) {
      console.error('Error:', error);
    } finally {
      setLoading(false);
    }
  };

  return { removeBackground, loading, result };
}

Python Integration

Using Requests

import requests

def remove_background(image_path, output_path):
    url = "https://your-api.com/api/remove-background"
    
    with open(image_path, 'rb') as f:
        files = {'image': f}
        data = {
            'modelType': 'portrait',
            'format': 'png'
        }
        
        response = requests.post(url, files=files, data=data)
        
        if response.status_code == 200:
            with open(output_path, 'wb') as output:
                output.write(response.content)
            return True
    
    return False

# Usage
remove_background('input.jpg', 'output.png')

FastAPI Integration

from fastapi import FastAPI, File, UploadFile
import requests

app = FastAPI()

@app.post("/process-image")
async def process_image(file: UploadFile = File(...)):
    # Save uploaded file temporarily
    with open(f"temp_{file.filename}", "wb") as buffer:
        buffer.write(await file.read())
    
    # Call RemoveBG API
    with open(f"temp_{file.filename}", "rb") as f:
        files = {'image': f}
        response = requests.post(
            "https://your-api.com/api/remove-background",
            files=files,
            data={'format': 'png'}
        )
    
    if response.status_code == 200:
        return {"success": True, "message": "Background removed"}
    
    return {"success": False, "error": "Processing failed"}

cURL Examples

Basic Background Removal

curl -X POST https://your-api.com/api/remove-background \
  -F "image=@photo.jpg" \
  -F "modelType=portrait" \
  -F "format=png" \
  --output result.png

With Custom Background Color

curl -X POST https://your-api.com/api/remove-background \
  -F "image=@photo.jpg" \
  -F "format=jpg" \
  -F "backgroundColor=#ff0000" \
  --output result.jpg

With Shadow Effect

curl -X POST https://your-api.com/api/remove-background \
  -F "image=@photo.jpg" \
  -F "format=png" \
  -F "shadowEnabled=true" \
  -F "shadowBlur=8" \
  -F "shadowOffsetX=3" \
  -F "shadowOffsetY=8" \
  -F "shadowOpacity=0.4" \
  --output result.png

Need Help with Integration?

Can't find your preferred language or framework? Need custom integration support?