SDKs overview

PhotoRoom offers Software Development Kits (SDKs) to facilitate the integration of its API services into various programming environments. These SDKs abstract the underlying RESTful API calls, allowing developers to interact with PhotoRoom's image processing functionalities using language-specific constructs. The primary purpose of these libraries is to simplify common tasks such as uploading images, requesting background removal, and applying editing operations, thereby reducing the boilerplate code required for direct HTTP interactions.

The availability of official SDKs for widely used languages such as Python and Node.js indicates PhotoRoom's focus on developer accessibility for its core services, which include background removal, object removal, and image re-sizing. These SDKs typically handle API authentication, request formatting, and response parsing, enabling developers to focus on application logic rather than API communication details. For developers working with other languages or specific frameworks, PhotoRoom also provides extensive API documentation with Curl examples, allowing for custom client implementations.

Official SDKs by language

PhotoRoom provides official SDKs for Python and Node.js, designed to streamline integration with its image editing and background removal API. These libraries are maintained by PhotoRoom and are recommended for developers building applications that require programmatic access to PhotoRoom's features. Each SDK aims to provide a native-like experience within its respective language ecosystem, adhering to common coding conventions and package management practices.

The official SDKs typically include methods for:

  • Authenticating API requests using a provided API key.
  • Uploading image files for processing.
  • Specifying output parameters, such as background color, image format, and resolution.
  • Handling API responses, including retrieving processed images or error messages.

Below is a summary of the official SDKs available:

Language Package Name Install Command Maturity
Python photoroom pip install photoroom Stable
Node.js @photoroom/node-sdk npm install @photoroom/node-sdk Stable

These SDKs are designed to be compatible with standard development environments for Python and Node.js, ensuring broad usability. Developers can find detailed usage instructions and examples within the PhotoRoom API documentation.

Installation

Installing PhotoRoom's official SDKs involves using the standard package managers for Python and Node.js. Before installation, developers should ensure they have the correct runtime environment set up, such as Python 3.x or a recent Node.js LTS version.

Python SDK Installation

To install the PhotoRoom Python SDK, use pip, the Python package installer. It is recommended to install SDKs within a virtual environment to manage dependencies effectively and avoid conflicts with system-wide packages. Virtual environments, as described in the Microsoft Python documentation, isolate project dependencies.

# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install the PhotoRoom Python SDK
pip install photoroom

After installation, the photoroom package will be available for import in your Python projects.

Node.js SDK Installation

For the Node.js SDK, use npm (Node Package Manager) or yarn. Ensure Node.js and npm are installed on your system. The Node.js SDK is published under the @photoroom scope, indicating it's an official package within the npm ecosystem.

# Install the PhotoRoom Node.js SDK using npm
npm install @photoroom/node-sdk

# Or using yarn
yarn add @photoroom/node-sdk

Once installed, you can import the SDK into your Node.js applications using CommonJS require or ES Modules import syntax.

Quickstart example

This section provides quickstart examples for using the PhotoRoom SDKs to perform a common task: removing the background from an image. Before running these examples, ensure you have installed the respective SDK and obtained your API key from the PhotoRoom developer dashboard.

Python Quickstart: Remove Background

This Python example demonstrates how to upload an image and receive a version with the background removed. Replace 'YOUR_API_KEY' and 'path/to/your/image.jpg' with your actual API key and image file path.

import photoroom

# Initialize the client with your API key
client = photoroom.Client(api_key='YOUR_API_KEY')

# Path to the input image file
input_image_path = 'path/to/your/image.jpg'

# Path for the output image file
output_image_path = 'output_image_no_bg.png'

try:
    # Open the image file in binary read mode
    with open(input_image_path, 'rb') as image_file:
        # Call the background removal API
        result = client.remove_background(
            image_file=image_file,
            format='png',
            # Optional: Specify a background color (e.g., green)
            # bg_color=(0, 255, 0)
        )
        
    # Save the processed image
    with open(output_image_path, 'wb') as output_file:
        output_file.write(result.image_bytes)
    
    print(f"Background removed successfully! Image saved to {output_image_path}")

except photoroom.PhotoroomError as e:
    print(f"An API error occurred: {e}")
except FileNotFoundError:
    print(f"Error: Input image file not found at {input_image_path}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

Node.js Quickstart: Remove Background

This Node.js example performs the same background removal task. Ensure you have fs (Node.js File System module) for file operations and replace placeholders as needed.

const { PhotoRoom } = require('@photoroom/node-sdk');
const fs = require('fs');

const apiKey = 'YOUR_API_KEY';
const inputImagePath = 'path/to/your/image.jpg';
const outputImagePath = 'output_image_no_bg.png';

async function removeImageBackground() {
  try {
    const client = new PhotoRoom({ apiKey });

    // Read the image file as a buffer
    const imageBuffer = fs.readFileSync(inputImagePath);

    const result = await client.removeBackground({
      imageFile: imageBuffer,
      format: 'png',
      // Optional: Specify a background color (e.g., red)
      // bgColor: [255, 0, 0]
    });

    // Save the processed image buffer to a file
    fs.writeFileSync(outputImagePath, result.image);

    console.log(`Background removed successfully! Image saved to ${outputImagePath}`);
  } catch (error) {
    if (error.response && error.response.data) {
      console.error('API Error:', error.response.data);
    } else if (error.code === 'ENOENT') {
      console.error(`Error: Input image file not found at ${inputImagePath}`);
    } else {
      console.error('An unexpected error occurred:', error.message);
    }
  }
}

removeImageBackground();

These examples illustrate the basic steps for initializing the client, calling an API method, and handling the response. The PhotoRoom API supports various parameters for customization, such as output dimensions, quality, and specific background options, all accessible through the SDK methods. Refer to the PhotoRoom API reference for a comprehensive list of available parameters and endpoints.

Community libraries

While PhotoRoom provides official SDKs for Python and Node.js, the broader developer community may contribute libraries or wrappers for other programming languages or frameworks. These community-driven projects can extend PhotoRoom's reach to developers working in environments not directly supported by official SDKs. Community libraries are typically hosted on platforms like GitHub and distributed via language-specific package managers.

When considering a community library, developers should evaluate several factors:

  • Maintenance Status: Check the last commit date, open issues, and pull requests to gauge active development.
  • Documentation: Assess the clarity and completeness of the library's documentation and examples.
  • Features Covered: Verify if the library supports the specific PhotoRoom API endpoints and functionalities required for your project.
  • Licensing: Understand the open-source license under which the library is distributed.
  • Community Support: Look for evidence of an active community that can provide assistance or share insights.

As of late 2025, PhotoRoom's official documentation primarily highlights its Python and Node.js SDKs. Developers seeking community-contributed libraries for other languages are encouraged to search public repositories like GitHub or language-specific package indexes (e.g., RubyGems for Ruby, Maven Central for Java) for third-party integrations. These community efforts often fill gaps and provide alternative implementations that cater to diverse developer preferences and project requirements. For example, developers might find wrappers for PHP or Go that use HTTP client libraries to interface with the standard HTTP methods outlined in RFC 7231 for REST APIs.