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"
}
Extract data from the UI interface using a JSON schema.
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"
}
Enter your API Key in the format: Bearer <token>. Get it from https://gbox.ai
Box ID
"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"
Action to extract data from the UI interface
Result of extract action execution
Was this page helpful?