POST
/
boxes
/
{boxId}
/
actions
/
extract
JavaScript
import GboxSDK from "gbox-sdk";
import { z } from "zod";

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});

async function main() {
  const box = await gboxSDK.create({ type: "android" });

  // Extract with JSON Schema
  console.info(
    await box.action.extract({
      instruction: "extract the app count from the home page",
      schema: {
        type: "object",
        properties: {
          count: { type: "number" }
        },
        required: ["count"]
      }
    })
  );

  // Define Zod schema
  const extractSchema = z.object({
    text: z.string(),
    isClickable: z.boolean().optional()
  });

  // Extract with Zod Schema
  console.info(
    await box.action.extract({
      instruction: "extract the text from the login button",
      schema: extractSchema
    })
  );
}

main();
{
"data": "test@example.com"
}

Authorizations

Authorization
string
header
required

Enter your API Key in the format: Bearer <token>. Get it from https://gbox.ai

Path Parameters

boxId
string
required

Box ID

Example:

"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"

Body

application/json

Action to extract data from the UI interface

Response

200 - application/json

Result of extract action execution