Plattformen
Mobile Apps
iOS, Android, Flutter und React Native – über Ihr Backend.
Code-Beispiele, Endpunkte und Fehlercodes sind in jeder Sprache identisch.
iOS-, Android-, Flutter- und React Native-Apps greifen auf Ihr Backend zu, und Ihr Backend ruft TryOnCloud auf. Speichern Sie den API-Schlüssel niemals in der App: Jeder kann ihn aus dem App-Bundle extrahieren.
POST /try-on (photo + product image URL)
POST /api/v1/generate (X-API-KEY)
200 image/png
200 image/png
Erstellen Sie den Backend-Endpunkt mit Node.js, Python oder PHP. Rufen Sie ihn anschließend aus der App auf:
React Native
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
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)
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)
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()) }Stellen Sie das HTTP-Timeout auf mindestens 120 Sekunden ein; ein „Try-on“ dauert etwa 20 Sekunden.
In unzuverlässigen Mobilfunknetzen sollte Ihr Backend pro Anprobe einen Idempotency-Key senden, damit ein erneuter Versuch nie doppelt berechnet wird. Alternativ nutzen Sie einen asynchronen Auftrag und benachrichtigen die App (zum Beispiel per Push-Nachricht), sobald der Webhook generation.completed eintrifft.