This repository contains code samples to easily interact with our API.
More details about PhotoRoom's API 👉 https://www.photoroom.com/api
Link to the full documentation 👉 https://docs.photoroom.com/docs/api/
You can download a Playground that will enable you to easily call our API with a sample image:
To make it work, just get your apiKey
and add it to the Playground:
To integrate our API inside your app, just copy/paste the content of the file RemoveBackground.swift into your Xcode project.
Then, depending on whether you are using Swift Concurrency, you can call either:
// with Swift Concurrency
Task { @MainActor in
imageView.image = try await removeBackground(of: yourImage)
}
or
// 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 can also watch this short demo 🍿