The agent that turns websites into APIs!
Generate a Java program that replicates the API calls found in the traffic. The following are guidelines — use your judgment on what's appropriate for the specific API:
Use
java.net.http.HttpClient(built into the JDK since 11) for requests — no HTTP library dependency neededUse Gson for JSON parsing/serialization — the one dependency this needs, since the JDK has no built-in JSON support
Create a minimal Maven project (
pom.xml) with the Gson dependency and theexec-maven-plugin, so the client runs with a single command and no extra flags. A conventional Maven layout only compilessrc/main/java, but{client_filename}is saved at the project root (see below) — override the build's<sourceDirectory>to.(project root) in the POM somvn compileactually finds and compiles itConfigure
exec-maven-pluginfor theexec:execgoal with exactly this configuration — do not use theexec:javagoal or<mainClass>:exec:javainvokesmainreflectively in-process, which fails on the package-privateApiClientclass described below ("symbolic reference class is not accessible"), whileexec:execspawns a realjavaprocess, and its<classpath/>element expands to the full dependency classpath with the correct platform-specific separator (:on macOS/Linux,;on Windows):<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.1.0</version> <configuration> <executable>java</executable> <arguments> <argument>-classpath</argument> <classpath/> <argument>ApiClient</argument> </arguments> </configuration> </plugin>Create a separate method for each distinct API endpoint, with a small class for its response shape
Reuse one
HttpClientinstance across requests rather than creating a new one per callInclude a
mainmethod with example usageThe output file is named
{client_filename}(lowercase with underscores), so name the top-level class holdingmainexactlyApiClient, declared package-private, without thepublicmodifier — apublicclass's filename must exactly match its class name, and this generator's file naming convention doesn't follow Java's usual PascalCase file naming. A package-private top-level class compiles and runs identically; it just isn't visible from other packages, which this single-file client has no need for.
Authentication & credentials:
- Hardcode all cookies, tokens, session IDs, and auth headers found in the traffic directly in the program
- The user should be able to run the program immediately after
mvn compile— no env vars, no additional config files, no manual setup beyond what's generated - If the API uses cookies, build the
HttpClientwith aCookieHandler/CookieManagerso cookies persist across requests - If the API uses Bearer tokens or API keys, hardcode them in the request headers
- Handle auth refresh so the program doesn't go stale: if you see a token refresh endpoint, OAuth refresh flow, or login endpoint in the traffic, implement automatic re-authentication when a request returns 401/403. If cookies have expiry, re-fetch them before they expire
Testing:
- Run:
{run_command} - You have up to 5 attempts to fix issues
Save the program to: {scripts_dir}/{client_filename}
Save documentation to: {scripts_dir}/README.md
Save the Maven project file to: {scripts_dir}/pom.xml