Search docs

Search the TryOnCloud API docs

Platforms

Mobile apps

iOS, Android, Flutter and React Native, through your backend.

iOS, Android, Flutter and React Native apps call your backend, and your backend calls TryOnCloud. Never put the API key in the app: anyone can extract it from the app bundle.

Mobile app
Your backend

POST /try-on (photo + product image URL)

â–¶

POST /api/v1/generate (X-API-KEY)

â—€

200 image/png

â—€

200 image/png

â—€

Build the backend endpoint with Node.js, Python or PHP. Then call it from the app:

React Native

js
const form = new FormData()
form.append("person", { uri: photo.uri, name: "person.jpg", type: "image/jpeg" })
form.append("garmentUrl", product.imageUrl)

const res = await fetch("https://api.yourapp.com/try-on", { method: "POST", body: form })
// Show the result: save the PNG with expo-file-system or react-native-fs, then render it.

Flutter

dart
final req = http.MultipartRequest('POST', Uri.parse('https://api.yourapp.com/try-on'))
  ..files.add(await http.MultipartFile.fromPath('person', photo.path))
  ..fields['garmentUrl'] = product.imageUrl;
final res = await http.Response.fromStream(await req.send());
if (res.statusCode == 200) {
  setState(() => resultBytes = res.bodyBytes); // Image.memory(resultBytes!)
}

Swift (iOS)

swift
var req = URLRequest(url: URL(string: "https://api.yourapp.com/try-on")!)
req.httpMethod = "POST"
req.timeoutInterval = 120
// Build a multipart body with "person" (JPEG data) and "garmentUrl", then:
let (data, response) = try await URLSession.shared.upload(for: req, from: body)
if (response as? HTTPURLResponse)?.statusCode == 200 { image = UIImage(data: data) }

Kotlin (Android)

kotlin
val body = MultipartBody.Builder().setType(MultipartBody.FORM)
    .addFormDataPart("person", "person.jpg", photoFile.asRequestBody("image/jpeg".toMediaType()))
    .addFormDataPart("garmentUrl", product.imageUrl)
    .build()
val request = Request.Builder().url("https://api.yourapp.com/try-on").post(body).build()
client.newCall(request).execute().use { res -> if (res.isSuccessful) bitmap = BitmapFactory.decodeStream(res.body!!.byteStream()) }

Set the HTTP timeout to at least 120 seconds; a try-on takes about 20 seconds.

On unreliable mobile networks, have your backend send an Idempotency-Key per try-on so a retry is never charged twice, or use an async job and notify the app (for example with a push notification) when the generation.completed webhook arrives.