Skip to main content
POST
/
boxes
/
{boxId}
/
actions
/
swipe
JavaScript
import GboxSDK from "gbox-sdk";

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" });

  // Swipe up
  await box.action.swipe({
    direction: "up",
    duration: "200ms"
  });

  // Swipe with enum distance
  await box.action.swipe({
    direction: "up",
    distance: "medium",
    duration: "500ms"
  });

  // Swipe with custom pixel distance
  await box.action.swipe({
    direction: "up",
    distance: 300,
    duration: "500ms"
  });

  // Swipe with natural language location
  await box.action.swipe({
    direction: "up",
    distance: 300,
    duration: "500ms",
    location: "screen bottom"
  });

  // Swipe with custom path
  await box.action.swipe({
    start: { x: 100, y: 150 },
    end: { x: 400, y: 300 },
    duration: "200ms"
  });

  // Swipe with natural language location
  await box.action.swipe({
    start: "screen bottom",
    end: "screen top",
    duration: "200ms"
  });
}

main();
{
  "message": "Action executed successfully",
  "actionId": "c9bdc193-b54b-4ddb-a035-5ac0c598d32d",
  "screenshot": {
    "trace": {
      "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
    },
    "before": {
      "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
    },
    "after": {
      "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
    }
  }
}

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
  • Swipe Simple
  • Swipe Advanced

Simple swipe action configuration. The gesture will be performed from the center of the screen towards the specified direction.

direction
enum<string>
required

Direction to swipe. The gesture will be performed from the center of the screen towards this direction.

Available options:
up,
down,
left,
right,
upLeft,
upRight,
downLeft,
downRight
Example:

"up"

duration
string
default:500ms

Duration of the swipe

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: "500ms", "30s", "5m", "1h" Default: 500ms

Example:

"500ms"

distance

Distance of the swipe. Can be either a number (in pixels) or a predefined enum value (tiny, short, medium, long). If not provided, the swipe will be performed from the center of the screen to the screen edge

Example:

300

location
string

Natural language description of the location where the swipe should originate. If not provided, the swipe will be performed from the center of the screen.

Example:

"Chrome App"

options
object

Action options. When options.screenshot is provided, ALL deprecated screenshot fields (outputFormat, presignedExpiresIn, screenshotDelay, screenshotRange, includeScreenshot) will be completely ignored. Action common options

Example:
{
"screenshot": {
"outputFormat": "base64",
"presignedExpiresIn": "30m",
"delay": "500ms",
"phases": ["before", "after"]
}
}

Response

200 - application/json

Result of an UI action execution with optional screenshots

message
string
required

message

Example:

"Action executed successfully"

actionId
string
required

Unique identifier for each action. Use this ID to locate the action and report issues.

Example:

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

screenshot
object

Optional screenshot data. Only present when screenshots are requested via options.screenshot.phases or deprecated fields Complete screenshot result with operation trace, before and after images

Example:
{
"trace": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"before": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"after": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
}
}
I