Skip to main content
POST
/
browsers
/
{id}
/
computer
/
drag_mouse
JavaScript
import Kernel from '@onkernel/sdk';

const client = new Kernel({
  apiKey: process.env['KERNEL_API_KEY'], // This is the default and can be omitted
});

await client.browsers.computer.dragMouse('id', {
  path: [
    [0, 0],
    [0, 0],
  ],
});
import os
from kernel import Kernel

client = Kernel(
api_key=os.environ.get("KERNEL_API_KEY"), # This is the default and can be omitted
)
client.browsers.computer.drag_mouse(
id="id",
path=[[0, 0], [0, 0]],
)
package main

import (
"context"

"github.com/kernel/kernel-go-sdk"
"github.com/kernel/kernel-go-sdk/option"
)

func main() {
client := kernel.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Browsers.Computer.DragMouse(
context.TODO(),
"id",
kernel.BrowserComputerDragMouseParams{
Path: [][]int64{{0, 0}, {0, 0}},
},
)
if err != nil {
panic(err.Error())
}
}
curl --request POST \
--url https://api.onkernel.com/browsers/{id}/computer/drag_mouse \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"path": [
[
123
]
],
"delay": 0,
"steps_per_segment": 10,
"step_delay_ms": 50,
"hold_keys": [
"<string>"
],
"smooth": true,
"duration_ms": 5025
}
'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onkernel.com/browsers/{id}/computer/drag_mouse",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'path' => [
[
123
]
],
'delay' => 0,
'steps_per_segment' => 10,
'step_delay_ms' => 50,
'hold_keys' => [
'<string>'
],
'smooth' => true,
'duration_ms' => 5025
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.post("https://api.onkernel.com/browsers/{id}/computer/drag_mouse")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"path\": [\n [\n 123\n ]\n ],\n \"delay\": 0,\n \"steps_per_segment\": 10,\n \"step_delay_ms\": 50,\n \"hold_keys\": [\n \"<string>\"\n ],\n \"smooth\": true,\n \"duration_ms\": 5025\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.onkernel.com/browsers/{id}/computer/drag_mouse")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"path\": [\n [\n 123\n ]\n ],\n \"delay\": 0,\n \"steps_per_segment\": 10,\n \"step_delay_ms\": 50,\n \"hold_keys\": [\n \"<string>\"\n ],\n \"smooth\": true,\n \"duration_ms\": 5025\n}"

response = http.request(request)
puts response.read_body
{
  "code": "bad_request",
  "message": "Missing required field: app_name",
  "details": [
    {
      "code": "invalid_input",
      "message": "Provided version string is not semver compliant"
    }
  ],
  "inner_error": {
    "code": "invalid_input",
    "message": "Provided version string is not semver compliant"
  }
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

Browser session ID

Body

application/json
path
integer[][]
required

Ordered list of [x, y] coordinate pairs to move through while dragging. Must contain at least 2 points.

Minimum array length: 2
Required array length: 2 elements
button
enum<string>

Mouse button to drag with

Available options:
left,
middle,
right
delay
integer
default:0

Delay in milliseconds between button down and starting to move along the path.

Required range: x >= 0
steps_per_segment
integer
default:10

Number of relative move steps per segment in the path. Minimum 1.

Required range: x >= 1
step_delay_ms
integer
default:50

Delay in milliseconds between relative steps while dragging (not the initial delay).

Required range: x >= 0
hold_keys
string[]

Modifier keys to hold during the drag

smooth
boolean
default:true

Use human-like Bezier curves between path waypoints instead of linear interpolation. When true, steps_per_segment and step_delay_ms are ignored.

duration_ms
integer

Target total duration in milliseconds for the entire drag movement when smooth=true. Omit for automatic timing based on total path length.

Required range: 50 <= x <= 10000

Response

Drag performed