Skip to content

Latest commit

 

History

History
55 lines (37 loc) · 2.25 KB

README.md

File metadata and controls

55 lines (37 loc) · 2.25 KB

App Icon

join-slack api-calls license

PhotoRoom API Code Samples 📸

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/

iOS

Option A - Test the API with an Xcode Playground

You can download a Playground that will enable you to easily call our API with a sample image:

remove_background_playground

To make it work, just get your apiKey and add it to the Playground:

remove_background_api_key

Option B - Integrate the API in your app

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 🍿