BGREMOVE API Endpoint

Version 2.197 (Release Notes ↗)

Description

Programmatically remove backgrounds from input images and video frames using your preferred programming language, processing multiple regions and images of varying sizes. Designed for developers, content creators, and marketing agencies seeking automated background removal in bulk.
The Remove Background API isolates image subjects by removing the background. Use this API for complete background & object removal without additional editing needs. It powers the Bulk Background Removal ↗ online webapp. Explore it to see the API in action.

HTTP Methods

GET, POST

HTTP Parameters

Required

Fields Type Description
img URL Input image URL to remove the background or unwanted objects from. If you want to upload an image directly from your app, then submit a multipart/form-data POST request instead. Refer to the POST Request Data section below.
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

Fields Type Description
blob Boolean By default, the Background remove API endpoint always returns a JSON Object (see Response Details ↓) containing the BASE64 encoded image output or a direct link to the output image stored in your private AWS S3 bucket if you've already connected your S3 storage credentials from the PixLab Console ↗. However, if this parameter is set to true, the raw image binary content is returned instead (see the Code Sample section for implementation details).

POST Request Body

This section details the requirements for using a POST request instead of a simple GET request.

Allowed Content-Types:

  • multipart/form-data
  • application/json

Use multipart/form-data to directly upload your image from you app (see the REST API code samples or The PixLab Github Repository↗ for a working example). If you're using JSON, the media file must already be uploaded. Consider calling store to upload an image before invoking this endpoint.

HTTP Response

application/json

By default, the Background removal API endpoint always returns a JSON Object containing the BASE64 encoded image output or a direct link to the output image stored in your private AWS S3 bucket if you've already connected your S3 storage credentials from the PixLab Console ↗. if one the other side, the blob parameter (documented above) is set to true, the raw image binary content is returned instead.

Fields Type Description
status Integer HTTP 200 indicates success. Any other code indicates failure.
imgData Base64 Data Base64 encoded string of the output image data.
mimeType String Mime type such as image/png of the output image.
extension String Extension such as jpeg of the output image.
link URL Optionally, a direct link to the output image (instead of the imgData field) stored on your own AWS S3 bucket if you already connected your AWS S3 credentials from the PixLab Console ↗.
error String Error description when status != 200.
blob BLOB Optionally, the image blob data is returned instead of this JSON object if the blob parameter (documented above) is set to true.

Code Samples


import requests

← Return to API Endpoint Listing