Keyboard Type
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/keyboard/type \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"selector": "<string>",
"timeout": 123,
"clear": true,
"delay": 123
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/keyboard/type"
payload = {
"text": "<string>",
"selector": "<string>",
"timeout": 123,
"clear": True,
"delay": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', selector: '<string>', timeout: 123, clear: true, delay: 123})
};
fetch('https://api.example.com/browser/sessions/{id}/keyboard/type', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/keyboard/type",
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([
'text' => '<string>',
'selector' => '<string>',
'timeout' => 123,
'clear' => true,
'delay' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/keyboard/type"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"clear\": true,\n \"delay\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/keyboard/type")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"clear\": true,\n \"delay\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/keyboard/type")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"clear\": true,\n \"delay\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"charactersTyped": 123
}Browser Sessions
Keyboard Type
Type text into the currently focused element or a specific selector, with optional clear-first behavior.
POST
/
browser
/
sessions
/
{id}
/
keyboard
/
type
Keyboard Type
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/keyboard/type \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"selector": "<string>",
"timeout": 123,
"clear": true,
"delay": 123
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/keyboard/type"
payload = {
"text": "<string>",
"selector": "<string>",
"timeout": 123,
"clear": True,
"delay": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', selector: '<string>', timeout: 123, clear: true, delay: 123})
};
fetch('https://api.example.com/browser/sessions/{id}/keyboard/type', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/keyboard/type",
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([
'text' => '<string>',
'selector' => '<string>',
'timeout' => 123,
'clear' => true,
'delay' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/keyboard/type"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"clear\": true,\n \"delay\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/keyboard/type")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"clear\": true,\n \"delay\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/keyboard/type")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"clear\": true,\n \"delay\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"charactersTyped": 123
}Overview
Dispatches real keydown+keyup events one character at a time against the active page of a browser session. Works with any focused input — ifselector is provided, the target element is focused (and optionally cleared) before typing.
Path Parameters
string
required
Browser session ID (UUID).
Body
string
required
Text to type. UTF-8 supported. Each character fires a native keydown+keyup pair so input/change/autocomplete listeners run.
string
Optional CSS selector to focus before typing. When omitted, keystrokes go to whatever element is currently focused.
integer
default:"5000"
How long to wait (ms) for the selector to become visible. Ignored when no selector is given.
boolean
default:"false"
When true, clears the field’s current value before typing. Safe default is
false so typing appends.integer
default:"40"
Base inter-key delay in milliseconds. Capped at 5000.
Example Request
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/keyboard/type" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"selector": "#email",
"text": "[email protected]",
"clear": true
}'
const response = await fetch(
"https://api.scrapengine.io/api/v1/browser/sessions/.../keyboard/type",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
selector: "#email",
text: "[email protected]",
clear: true,
}),
},
);
import requests
response = requests.post(
"https://api.scrapengine.io/api/v1/browser/sessions/.../keyboard/type",
headers={
"Authorization": "Bearer YOUR_API_KEY",
},
json={
"selector": "#email",
"text": "[email protected]",
"clear": True,
},
)
Response
Success Response (200)
boolean
True when the keystrokes were dispatched successfully.
integer
Number of characters (UTF-8 code points) dispatched.
{
"success": true,
"charactersTyped": 18
}
Error Responses
| Status | Description |
|---|---|
400 | Invalid body — missing text, delay out of range, bad parameters. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found, or selector did not become visible before timeout. |
503 | The browser session is temporarily unreachable. |
Notes
- Composed input is not supported. CJK dead-key composition, emoji composition sequences, and similar composed input are typed character-by-character, not as composition events.
- Existing value is preserved unless
clear: true. Typing appends to the field’s current value. Setclear: trueto overwrite. - Shadow-root and iframe targets aren’t addressable. If the element is inside a shadow root or cross-origin iframe, the selector must match the shadow host or the endpoint will return 404.
Was this page helpful?