Integrazione API Web – Documentazione ByByBG
🌐 Web / HTML SDK

Integrazione Web / HTML

Integra la rimozione dello sfondo basata su AI nei tuoi siti web utilizzando HTML, PHP e richieste API sicure.

INTRODUZIONE

API Background Remover per il Web

Integra facilmente la rimozione automatica dello sfondo in siti web, CMS, landing page e piattaforme online.

📤

🔐

🖼️

STEP 1

Modulo HTML di Upload

Crea un semplice modulo HTML per consentire agli utenti di caricare immagini.

<input type="file" id="imageInput">

<button onclick="removeBg()">
    Remove Background
</button>

<div id="result"></div>
STEP 2

async function removeBg(){

    const fileInput =
    document.getElementById("imageInput");

    const result =
    document.getElementById("result");

    if(!fileInput.files.length){
        alert("Select image");
        return;
    }

    const formData = new FormData();

    formData.append(
        "file",
        fileInput.files[0]
    );

    result.innerHTML = "Processing...";

    const response = await fetch(
        "/web/remove-bg",
        {
            method:"POST",
            body:formData
        }
    );

    if(!response.ok){

        result.innerHTML =
        "Something went wrong";

        return;
    }

    const blob =
    await response.blob();

    const url =
    URL.createObjectURL(blob);

    result.innerHTML = `
        <img src="${url}">
    `;
}
STEP 3

SECURITY

Raccomandazioni di Sicurezza

  • Non esporre mai la tua API Key nel codice frontend.
  • Convalida tutti i file caricati prima dell'elaborazione.
  • Limita la dimensione dei file caricati per evitare abusi.
  • Utilizza sempre HTTPS per le richieste API.
  • Memorizza le API Key nelle variabili d'ambiente del server.
ERRORS

Status
Description
401
413
429
500

Continua con JavaScript

Scopri come utilizzare JavaScript e Fetch API per integrare ByByBG nelle applicazioni web moderne.