Photoroom API Documentation
Ask or search…
⌃K

iOS / Swift Integration

If you work on an e-commerce iOS app, you know how important it is to provide users with high-quality images of the products they want to sell. However, taking pictures with a clean background can be a challenge for many users. This is where the PhotoRoom API comes in handy!
With the PhotoRoom API, you can easily remove the background of images in your iOS app, improving the overall quality of the pictures your users will upload.
In this tutorial, I will show you how you can integrate the PhotoRoom API into your iOS app in just a few minutes.

Step 1: Get Your API Key

The first thing you need to do is get your API key. Here are the steps you'll need to follow:

Step 2: Use our Sample Code

Visit PhotoRoom’s GitHub to find a sample code that's ready to use. Simply copy and paste the code into your Xcode project, and update the placeholder with your own API key.

Step 3: Call the API

Now it's time to call the API in your code! Just use the function removeBackground(of: yourImage) and pass in your original UIImage as an argument. The function will return a new UIImage with the background removed.
// with Swift Concurrency
Task { @MainActor in
imageView.image = try await removeBackground(of: yourImage)
}
​
// without Swift Concurrency
removeBackground(of: yourImage) { result in
switch result {
case let .success(backgroundRemoved):
imageView.image = backgroundRemoved
case let .failure(error):
// handle the `error`
}
}

​
You're done!

That's it! With just these three easy steps, you can integrate the PhotoRoom Background Removal API into your iOS app and provide your users with high-quality images with clean backgrounds.
According to resellers who use the PhotoRoom app, this feature can increase sales by 20 up to 100%.
If you want to learn more about the PhotoRoom API and get your API key, visit https://www.photoroom.com/api.