Implement no-bg into your workflow
Our API is a simple HTTP interface with various options you might be interested in.
Removes the background of a JPG/JPEG/PNG image.
• File Size: up to 10 MB (full resolution), up to 5 MB (previews).
• Image Source: File upload (binary or as base64 encoded string) or direct from URL.
• Image Content: Any image with a foreground (e.g. humans, products, animals, vehicles, etc.).
• Output Resolution: up to 0.23 megapixels (previews), up to 25 megapixels (full resolution).
• Requires an API key to be supplied in the X-API-Key request header.
image
- Description: Source image file (binary)
- Type: string($binary)
resolution
- Description: Value of 0 will return a preview,
value of 1 will return a full resolution image
- Accepted Values: 0, 1
- Type: integer
X-Api-Key
- Description: Your API Key Here for authentication
- Type: string
(binary image data)
X-Credits-Price
- Description: Amount of credits charged for this transaction
- Type: float
X-Credits-Source
- Description: Deducted from monthly subscription credits
or pay-to-use credits
- Possible Outputs: credits, subCredits, free
- Type: string
errors
- Description: Invalid Parameters / Server Not Online / Failed To Deduct Credits
- Type: string
errorCode
- Description: Used for debugging
- Type: string
errors
- Description: Insufficient Credits
- Type: string
errorCode
- Description: Used for debugging
- Type: string
errors
- Description: Authentication Failed / Invalid API Key
- Type: string
errorCode
- Description: Used for debugging
- Type: string
errors
- Description: Exceeded File Size Limitations / Rate Limit
- Type: string
errorCode
- Description: Used for debugging
- Type: string
Get started integrating no-bg into your programs easily with our sample codes below
$ curl -H 'x-api-key: INSERT_YOUR_API_KEY_HERE' \
-F 'image=@/path/to/file.jpg' \
-F 'resolution=0' \
-f https://no-bg.com/api/v1.0.0/
// Requires "Apache HttpComponents" to be installed (see hc.apache.org)
Response response = Request.Post("https://no-bg.com/api/v1.0.0/")
.addHeader("x-api-key", "INSERT_YOUR_API_KEY_HERE")
.body(
MultipartEntityBuilder.create()
.addBinaryBody("image", new File("/path/to/file.jpg"))
.addTextBody("resolution", "0")
.build()
).execute();
response.saveContent(new File("no-bg.png"));
# Requires "requests" to be installed (see python-requests.org)
import requests
response = requests.post(
'https://no-bg.com/api/v1.0.0/',
files={'image': open('/path/to/file.jpg', 'rb')},
data={'resolution': '0'},
headers={'x-api-key': 'INSERT_YOUR_API_KEY_HERE'},
)
if response.status_code == requests.codes.ok:
with open('no-bg.png', 'wb') as out:
out.write(response.content)
else:
print("Error:", response.status_code, response.json())
// Requires "guzzle" module to be installed (see guzzlephp.org)
$client = new GuzzleHttp\Client();
$res = $client->post('https://no-bg.com/api/v1.0.0/', [
'multipart' => [
[
'name' => 'image',
'contents' => fopen('/path/to/file.jpg', 'r')
],
[
'name' => 'resolution',
'contents' => '0'
]
],
'headers' => [
;'x-api-key' => 'INSERT_YOUR_API_KEY_HERE'
]
]);
$fp = fopen("no-bg.png", "wb");
fwrite($fp, $res->getBody());
fclose($fp);
// Requires "request" module to be installed (see https://www.npmjs.com/package/request)
var request = require('request');
var fs = require('fs');
request.post({
url: 'https://no-bg.com/api/v1.0.0/',
formData: {
image: fs.createReadStream('/path/to/file.jpg'),
resolution: '0',
},
headers: {
'X-Api-Key': 'INSERT_YOUR_API_KEY_HERE'
},
encoding: null
}, function(error, response, body) {
if(error) return console.error('Request failed:', error);
if(response.statusCode != 200) return console.error('Error:', response.statusCode, body.toString('utf8'));
fs.writeFileSync("no-bg.png", body);
});
using (var client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
formData.Headers.Add("X-Api-Key", "INSERT_YOUR_API_KEY_HERE");
formData.Add(new ByteArrayContent(File.ReadAllBytes("/path/to/file.jpg")), "image", "file.jpg");
formData.Add(new StringContent("resolution"), "0");
var response = client.PostAsync("https://no-bg.com/api/v1.0.0/", formData).Result;
if(response.IsSuccessStatusCode) {
FileStream fileStream = new FileStream("no-bg.png", FileMode.Create, FileAccess.Write, FileShare.None);
response.Content.CopyToAsync(fileStream).ContinueWith((copyTask) =>{ fileStream.Close(); });
} else {
Console.WriteLine("Error: " + response.Content.ReadAsStringAsync().Result);
}
}
You can process up to 150 images per minute through our API. Depending on the input image resolution.
Input image (Examples) | Megapixels | Effective Rate Limit |
---|---|---|
625 x 400 | 1 MP | 150 images per minute |
1200 x 800 | 1 MP | 150 images per minute |
1600 x 1200 | 2 MP | 150 / 2 = 75 images per minute |
2500 x 1600 | 4 MP | 150 / 4 = 38 images per minute |
4000 x 2500 | 10 MP | 150 / 10 = 15 images per minute |
6250 x 4000 | 25 MP | 150 / 25 = 6 images per minute |
Discuss with our professionals about your business workflow and operations for them to have a better understanding on how your business can use no-bg to automate parts of your operations.
Talk To A Professional Now