API Documentation

API Endpoints

Get User Credits

GET /wp-json/rembg/v1/credits

Returns the number of credits available for the current user.

Example Response:

{
  "isLoggedIn": true,
  "credits": 5
}

cURL Example:

curl -X GET \
  "https://rembg.barchin.com/wp-json/rembg/v1/credits" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Process Image

POST /wp-json/rembg/v1/process-image

Processes an image to remove its background.

Parameters:

  • image - Image file (JPEG or PNG)

Success Response:

{
  "image": "base64_encoded_image_data",
  "credits_remaining": 4,
  "isLoggedIn": true
}

Error Response (Insufficient Credits):

{
  "code": "insufficient_credits",
  "message": "Insufficient credits. Please purchase additional credits.",
  "data": {
    "status": 402
  }
}

cURL Example:

curl -X POST \
  "https://rembg.barchin.com/wp-json/rembg/v1/process-image" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "image=@/path/to/your/image.jpg"

Note: When using JWT authentication, the credentials are passed in the Authorization header. The response contains the processed image in base64 format, which can be decoded and saved to a file.

Usage Notes

Credits System

Each image processing request consumes one credit from your account balance. Non-authenticated requests will have a watermark added to the processed image.

Image Processing

  • Supported formats: JPG and PNG
  • Maximum file size: 10MB
  • The API returns a base64-encoded PNG image with transparency
  • Processing larger images may take more time