Skip to content

Commit fc801c0

Browse files
pirateclaude
andauthored
Remove deprecated headers and standardize README (#8)
- Replace README header with standardized Stagehand branding - Update docs URL to /v3/sdk/java - Remove MCP Server section from README - Remove x_language, x_sdk_version, frame_id deprecated headers from Main.java 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d61f7a4 commit fc801c0

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

README.md

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,67 @@
1-
# Stagehand Java API Library
2-
3-
<!-- x-release-please-start-version -->
4-
5-
[![Maven Central](https://img.shields.io/maven-central/v/com.browserbase.api/stagehand-java)](https://central.sonatype.com/artifact/com.browserbase.api/stagehand-java/0.6.0)
6-
[![javadoc](https://javadoc.io/badge2/com.browserbase.api/stagehand-java/0.6.0/javadoc.svg)](https://javadoc.io/doc/com.browserbase.api/stagehand-java/0.6.0)
7-
8-
<!-- x-release-please-end -->
9-
10-
The Stagehand Java SDK provides convenient access to the [Stagehand REST API](https://docs.stagehand.dev) from applications written in Java.
11-
12-
It is generated with [Stainless](https://www.stainless.com/).
13-
14-
## MCP Server
15-
16-
Use the Stagehand MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
17-
18-
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=stagehand-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsInN0YWdlaGFuZC1tY3AiXX0)
19-
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22stagehand-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22stagehand-mcp%22%5D%7D)
20-
21-
> Note: You may need to set environment variables in your MCP client.
22-
23-
<!-- x-release-please-start-version -->
24-
25-
The REST API documentation can be found on [docs.stagehand.dev](https://docs.stagehand.dev). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.browserbase.api/stagehand-java/0.6.0).
26-
27-
<!-- x-release-please-end -->
1+
<div id="toc" align="center" style="margin-bottom: 0;">
2+
<ul style="list-style: none; margin: 0; padding: 0;">
3+
<a href="https://stagehand.dev">
4+
<picture>
5+
<source media="(prefers-color-scheme: dark)" srcset="media/dark_logo.png" />
6+
<img alt="Stagehand" src="media/light_logo.png" width="200" style="margin-right: 30px;" />
7+
</picture>
8+
</a>
9+
</ul>
10+
</div>
11+
<p align="center">
12+
<strong>The AI Browser Automation Framework</strong><br>
13+
<a href="https://docs.stagehand.dev/v3/sdk/java">Read the Docs</a>
14+
</p>
15+
16+
<p align="center">
17+
<a href="https://github.com/browserbase/stagehand/tree/main?tab=MIT-1-ov-file#MIT-1-ov-file">
18+
<picture>
19+
<source media="(prefers-color-scheme: dark)" srcset="media/dark_license.svg" />
20+
<img alt="MIT License" src="media/light_license.svg" />
21+
</picture>
22+
</a>
23+
<a href="https://stagehand.dev/discord">
24+
<picture>
25+
<source media="(prefers-color-scheme: dark)" srcset="media/dark_discord.svg" />
26+
<img alt="Discord Community" src="media/light_discord.svg" />
27+
</picture>
28+
</a>
29+
</p>
30+
31+
<p align="center">
32+
<a href="https://trendshift.io/repositories/12122" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12122" alt="browserbase%2Fstagehand | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
33+
</p>
34+
35+
<p align="center">
36+
If you're looking for other languages, you can find them
37+
<a href="https://docs.stagehand.dev/v3/first-steps/introduction"> here</a>
38+
</p>
39+
40+
<div align="center" style="display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 0;">
41+
<b>Vibe code</b>
42+
<span style="font-size: 1.05em;"> Stagehand with </span>
43+
<a href="https://director.ai" style="display: flex; align-items: center;">
44+
<span>Director</span>
45+
</a>
46+
<span> </span>
47+
<picture>
48+
<img alt="Director" src="media/director_icon.svg" width="25" />
49+
</picture>
50+
</div>
51+
52+
## What is Stagehand?
53+
54+
Stagehand is a browser automation framework used to control web browsers with natural language and code. By combining the power of AI with the precision of code, Stagehand makes web automation flexible, maintainable, and actually reliable.
55+
56+
## Why Stagehand?
57+
58+
Most existing browser automation tools either require you to write low-level code in a framework like Selenium, Playwright, or Puppeteer, or use high-level agents that can be unpredictable in production. By letting developers choose what to write in code vs. natural language (and bridging the gap between the two) Stagehand is the natural choice for browser automations in production.
59+
60+
1. **Choose when to write code vs. natural language**: use AI when you want to navigate unfamiliar pages, and use code when you know exactly what you want to do.
61+
62+
2. **Go from AI-driven to repeatable workflows**: Stagehand lets you preview AI actions before running them, and also helps you easily cache repeatable actions to save time and tokens.
63+
64+
3. **Write once, run forever**: Stagehand's auto-caching combined with self-healing remembers previous actions, runs without LLM inference, and knows when to involve AI whenever the website changes and your automation breaks.
2865

2966
## Installation
3067

@@ -81,8 +118,6 @@ import java.util.Map;
81118
import java.util.Optional;
82119

83120
public class Main {
84-
private static final String SDK_VERSION = "3.0.6";
85-
86121
public static void main(String[] args) {
87122
// Create client using environment variables:
88123
// BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID, MODEL_API_KEY
@@ -92,8 +127,6 @@ public class Main {
92127
SessionStartResponse startResponse = client.sessions().start(
93128
SessionStartParams.builder()
94129
.modelName("openai/gpt-5-nano")
95-
.xLanguage(SessionStartParams.XLanguage.TYPESCRIPT)
96-
.xSdkVersion(SDK_VERSION)
97130
.build()
98131
);
99132

@@ -102,14 +135,10 @@ public class Main {
102135

103136
try {
104137
// Navigate to a webpage
105-
// frameId is required - use empty string for the main frame
106138
client.sessions().navigate(
107139
SessionNavigateParams.builder()
108140
.id(sessionId)
109141
.url("https://news.ycombinator.com")
110-
.frameId("")
111-
.xLanguage(SessionNavigateParams.XLanguage.TYPESCRIPT)
112-
.xSdkVersion(SDK_VERSION)
113142
.build()
114143
);
115144
System.out.println("Navigated to Hacker News");
@@ -119,8 +148,6 @@ public class Main {
119148
SessionObserveParams.builder()
120149
.id(sessionId)
121150
.instruction("find the link to view comments for the top post")
122-
.xLanguage(SessionObserveParams.XLanguage.TYPESCRIPT)
123-
.xSdkVersion(SDK_VERSION)
124151
.build()
125152
);
126153

@@ -143,8 +170,6 @@ public class Main {
143170
SessionActParams.builder()
144171
.id(sessionId)
145172
.input(action)
146-
.xLanguage(SessionActParams.XLanguage.TYPESCRIPT)
147-
.xSdkVersion(SDK_VERSION)
148173
.build()
149174
);
150175
System.out.println("Act completed: " + actResponse.data().result().message());
@@ -168,8 +193,6 @@ public class Main {
168193
)))
169194
.putAdditionalProperty("required", JsonValue.from(List.of("commentText")))
170195
.build())
171-
.xLanguage(SessionExtractParams.XLanguage.TYPESCRIPT)
172-
.xSdkVersion(SDK_VERSION)
173196
.build()
174197
);
175198

@@ -204,8 +227,6 @@ public class Main {
204227
))
205228
.cua(false)
206229
.build())
207-
.xLanguage(SessionExecuteParams.XLanguage.TYPESCRIPT)
208-
.xSdkVersion(SDK_VERSION)
209230
.build()
210231
);
211232

@@ -217,8 +238,6 @@ public class Main {
217238
client.sessions().end(
218239
SessionEndParams.builder()
219240
.id(sessionId)
220-
.xLanguage(SessionEndParams.XLanguage.TYPESCRIPT)
221-
.xSdkVersion(SDK_VERSION)
222241
.build()
223242
);
224243
System.out.println("Session ended");

stagehand-java-example/src/main/java/com/stagehand/api/example/Main.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
* - MODEL_API_KEY: Your OpenAI API key
3030
*/
3131
public class Main {
32-
33-
// SDK version for API compatibility (matches TypeScript SDK v3)
34-
private static final String SDK_VERSION = "3.0.6";
35-
3632
public static void main(String[] args) {
3733
// Create client using environment variables
3834
// BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID, MODEL_API_KEY
@@ -42,8 +38,6 @@ public static void main(String[] args) {
4238
SessionStartResponse startResponse = client.sessions().start(
4339
SessionStartParams.builder()
4440
.modelName("openai/gpt-5-nano")
45-
.xLanguage(SessionStartParams.XLanguage.TYPESCRIPT)
46-
.xSdkVersion(SDK_VERSION)
4741
.build()
4842
);
4943

@@ -56,9 +50,6 @@ public static void main(String[] args) {
5650
SessionNavigateParams.builder()
5751
.id(sessionId)
5852
.url("https://news.ycombinator.com")
59-
.frameId("") // Empty string for main frame
60-
.xLanguage(SessionNavigateParams.XLanguage.TYPESCRIPT)
61-
.xSdkVersion(SDK_VERSION)
6253
.build()
6354
);
6455
System.out.println("Navigated to Hacker News");
@@ -68,8 +59,6 @@ public static void main(String[] args) {
6859
SessionObserveParams.builder()
6960
.id(sessionId)
7061
.instruction("find the link to view comments for the top post")
71-
.xLanguage(SessionObserveParams.XLanguage.TYPESCRIPT)
72-
.xSdkVersion(SDK_VERSION)
7362
.build()
7463
);
7564

@@ -91,8 +80,6 @@ public static void main(String[] args) {
9180
SessionActParams.builder()
9281
.id(sessionId)
9382
.input(action)
94-
.xLanguage(SessionActParams.XLanguage.TYPESCRIPT)
95-
.xSdkVersion(SDK_VERSION)
9683
.build()
9784
);
9885
System.out.println("Act completed: " + actResponse.data().result().message());
@@ -117,8 +104,6 @@ public static void main(String[] args) {
117104
)))
118105
.putAdditionalProperty("required", JsonValue.from(List.of("commentText")))
119106
.build())
120-
.xLanguage(SessionExtractParams.XLanguage.TYPESCRIPT)
121-
.xSdkVersion(SDK_VERSION)
122107
.build()
123108
);
124109

@@ -161,8 +146,6 @@ public static void main(String[] args) {
161146
))
162147
.cua(false)
163148
.build())
164-
.xLanguage(SessionExecuteParams.XLanguage.TYPESCRIPT)
165-
.xSdkVersion(SDK_VERSION)
166149
.build(),
167150
RequestOptions.builder().timeout(Duration.ofMinutes(5)).build()
168151
);
@@ -176,8 +159,6 @@ public static void main(String[] args) {
176159
client.sessions().end(
177160
SessionEndParams.builder()
178161
.id(sessionId)
179-
.xLanguage(SessionEndParams.XLanguage.TYPESCRIPT)
180-
.xSdkVersion(SDK_VERSION)
181162
.build()
182163
);
183164
System.out.println("Session ended");

0 commit comments

Comments
 (0)