ಪ್ರಕಟಿಸಿದ ದಿನಾಂಕ

Removebg API ಡಾಕ್ಯುಮೆಂಟೇಶನ್

Cover

ತ್ವರಿತ ಪ್ರಾರಂಭ

curl --location 'https://removebg.one/api/v1/predict' \
--header 'Authorization: Bearer $API_KEY' \
--form 'file=@"test.png"'

ವಿನಂತಿ ಡೊಮೇನ್

https://removebg.one

ವಿನಂತಿ ಎಂಡ್‌ಪಾಯಿಂಟ್

/api/v1/predict

API ಕೀ ರಚಿಸಿ

API ಕೀ ಪುಟದಲ್ಲಿ ನಿಮ್ಮ API ಕೀ ಅನ್ನು ರಚಿಸಿ ಅಥವಾ ರಿಸೆಟ್ ಮಾಡಿ.

ವಿನಂತಿ ಪ್ಯಾರಾಮೀಟರ್ಗಳು

  1. ಪ್ರಸ್ತುತ, ಫೈಲ್ ಆಬ್ಜೆಕ್ಟ್‌ಗಳು ಮಾತ್ರ formData ಮೂಲಕ ಕಳುಹಿಸಬಹುದು, ಆದ್ದರಿಂದ ದಯವಿಟ್ಟು ಸದಾ Content-Type ಅನ್ನು multipart/form-data ಎಂದು ಹೊಂದಿಸಿ.

  2. API ಕೀ ಪುಟದಲ್ಲಿ API ಕೀ ರಚಿಸಿದ ನಂತರ, Authorization ವಿನಂತಿ ಹೆಡರ್‌ನಲ್ಲಿ ಕೀ ಮೌಲ್ಯವನ್ನು ಸೆಟ್ ಮಾಡಿ.

Content-Type: multipart/form-data
Authorization: Bearer $API_KEY

ನೋಡು: $API_KEY ಅನ್ನು ನಿಮ್ಮ ನಿಜವಾದ API ಕೀతో ಬದಲಾಯಿಸಿ.

ಪ್ರತಿಕ್ರಿಯೆ ಪ್ಯಾರಾಮೀಟರ್ಗಳು

0 ಎಂದು ಪ್ರದರ್ಶಿಸುವ ರಿಟರ್ನ್ ಕೋಡ್ ಎಂದರೆ API ಕರೆ ಯಶಸ್ವಿಯಾಗಿದೆ. ಯಾವುದೇ ಇತರ ಕೋಡ್ ವಿಫಲತೆಯನ್ನು ಸೂಚಿಸುತ್ತದೆ, ಮತ್ತು ವಿಫಲತೆಯ ನಿಖರವಾದ ಕಾರಣವನ್ನು ಸಂದೇಶ ಕ್ಷೇತ್ರದಲ್ಲಿ ನೀಡಲಾಗುತ್ತದೆ.

  1. ಯಶಸ್ವಿ ಪ್ರತಿಕ್ರಿಯೆ
{
    "code": 0,
    "data": {
        "cutoutUrl": "https://r.removebg.one/static/8d062cc4-7d1d-4390-b958-a88e3a714e68.png?signature=...",
        "maskUrl": "https://r.removebg.one/static/acd1904f-e7b6-4e20-92cc-29f19659caf8.png?signature=..."
    }
}
  1. ವಿಫಲವಾದ ಪ್ರತಿಕ್ರಿಯೆ
{
    "code": 400,
    "message": "Invalid request parameters."
}

ದಯವಿಟ್ಟು ಗಮನಿಸಿ: ಯಶಸ್ವಿಯಾಗಿ ಪಡೆದ ಚಿತ್ರ URL 1 ಗಂಟೆಗೆ ಮಾತ್ರ ಮಾನ್ಯವಾಗಿದೆ. ನಿಮ್ಮ ಬಳಕೆಯ ಸಂದರ್ಭದಲ್ಲಿ ಸಮಯೋಚಿತವಾಗಿ ಅದನ್ನು ಉಳಿಸು ಅಥವಾ ಬಳಕೆದಾರರಿಗೆ ಸೂಚಿಸಿ.

ಕೋಡ್ ಉದಾಹರಣೆಗಳು

Fetch

const formData = new FormData()
formData.append('file', File)
fetch('https://removebg.one/api/v1/predict', {
  method: 'POST',
  body: formData,
  headers: {
    Authorization: 'Bearer $API_KEY',
  },
})

Java

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.util.EntityUtils;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.File;
 
public class RemoveBgApiRequest {
    public static void main(String[] args) throws Exception {
        String apiKey = "YOUR_API_KEY"; // Replace with your API key
        String filePath = "test.png";  // Replace with your file path
        String url = "https://removebg.one/api/v1/predict";
        
        File file = new File(filePath);
        
        // Create HTTP client
        try (CloseableHttpClient client = HttpClients.createDefault()) {
            HttpPost post = new HttpPost(url);
            post.setHeader("Authorization", "Bearer " + apiKey);
            
            // Build multipart form data
            FileBody fileBody = new FileBody(file);
            HttpEntity entity = MultipartEntityBuilder.create()
                    .addPart("file", fileBody)
                    .build();
            post.setEntity(entity);
            
            // Execute request
            String response = EntityUtils.toString(client.execute(post).getEntity());
            
            // Parse the JSON response
            JsonObject jsonResponse = JsonParser.parseString(response).getAsJsonObject();
            int code = jsonResponse.get("code").getAsInt();
            
            if (code == 0) {
                // Success
                System.out.println("Success: Response data = " + jsonResponse.getAsJsonObject("data"));
            } else {
                // Failure
                String message = jsonResponse.has("message") ? jsonResponse.get("message").getAsString() : "Unknown error";
                System.out.println("Failure: " + message);
            }
        }
    }
}

Python

import requests
 
# Replace with your actual API key
api_key = 'your_api_key_here'
url = 'https://removebg.one/api/v1/predict'
 
# Path to the image file
file_path = 'test.png'
 
# Set up the headers with Authorization
headers = {
    'Authorization': f'Bearer {api_key}'
}
 
# Open the image file in binary mode
with open(file_path, 'rb') as image_file:
    # Send the POST request with the file
    response = requests.post(url, headers=headers, files={'file': image_file})
 
# Check the response status
if response.code == 0:
    print('Request successful')
    # You can save or process the response content as needed
    with open('output.png', 'wb') as output_file:
        output_file.write(response.content)
else:
    print(f'Error: {response.code}')
 

ಅಂತಿಮ ಟಿಪ್ಪಣಿಗಳು

ಯಾವುದೇ ಪ್ರಶ್ನೆಗಳಿದ್ದರೆ, ದಯವಿಟ್ಟು ನಮ್ಮನ್ನು [email protected] ನಲ್ಲಿ ಇಮೇಲ್ ಮೂಲಕ ಸಂಪರ್ಕಿಸಿ.

ಲೇಖಕರು