API Documentation
Integrate EraseBG's powerful background removal directly into your applications with our simple REST API.
API Endpoint
POST https://api.erasebg.co/remove-bg/
Authentication
Headers
Include your API token in the request header:
Authorization: Bearer YOUR_API_TOKEN
Request Body
Send a multipart/form-data request with the image file:
Content-Type: multipart/form-data
image: [binary file data]
Supported formats: JPEG, PNG, WebP
Max file size: 20MB
Code Examples
curl -X POST https://api.erasebg.co/remove-bg/ \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "image=@/path/to/image.jpg" \
-o output.png
const formData = new FormData();
formData.append('image', imageFile);
const response = await fetch('https://api.erasebg.co/remove-bg/', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN'
},
body: formData
});
const blob = await response.blob();
const imageUrl = URL.createObjectURL(blob);
import requests
url = "https://api.erasebg.co/remove-bg/"
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
with open("image.jpg", "rb") as f:
files = {"image": f}
response = requests.post(url, headers=headers, files=files)
with open("output.png", "wb") as f:
f.write(response.content)
import java.net.http.*;
import java.nio.file.*;
HttpClient client = HttpClient.newHttpClient();
Path imagePath = Path.of("image.jpg");
String boundary = "----WebKitFormBoundary" + System.currentTimeMillis();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.erasebg.co/remove-bg/"))
.header("Authorization", "Bearer YOUR_API_TOKEN")
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofFile(imagePath))
.build();
HttpResponse<byte[]> response = client.send(request,
HttpResponse.BodyHandlers.ofByteArray());
Files.write(Path.of("output.png"), response.body());
Rate Limits
API requests are rate-limited based on your subscription plan:
- Pro Plan: 250 API requests per month
- Enterprise Plan: 1000 API requests per month
Rate limit headers are included in each response:
X-RateLimit-Limit: 250
X-RateLimit-Remaining: 247
X-RateLimit-Reset: 1704067200