
unirest-java-3
Unirest-Java 3.x HTTP client library for Java 8+. Use when making HTTP requests (GET/POST/PUT/DELETE), building REST API clients, handling JSON responses, file uploads/downloads, async requests, mocking HTTP calls for testing, configuring proxies, or caching responses. Covers Unirest 3.x (Apache HttpClient based, default GSON included, kong.unirest package) with object mapping, request/response interceptors, and migration guidance.
- Installs
- 78
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/full-stack-skills/java-skills --skill unirest-java-3- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads unirest-java-3 automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Unirest-Java 3.x Reference (v3.14.5)
This skill covers the Unirest-Java 3.x HTTP client library for Java 8+. It uses Apache HttpClient 4 as the HTTP engine and includes GSON as the default JSON parser.
Capability Boundaries
✅ Strong Suits
- Building HTTP requests (GET, POST, PUT, DELETE, PATCH) with fluent API
- JSON/object mapping with built-in GSON (no extra dependency needed)
- Async requests with CompletableFuture (via Apache HttpAsyncClient)
- File uploads with progress monitoring
- Mock testing for HTTP clients
- Response caching with configurable eviction
- Proxy configuration (simple, system, per-request)
- Request/response interceptors for logging and auth
- Connection pool tuning (
concurrency(total, perRoute)) - Socket timeout control (independent of connect timeout)
- Automatic retries on socket errors (
automaticRetries()) - Shutdown hooks for background thread management
- Custom HostnameVerifier support
⚠️ Requirements
- Java 8 or higher
- Apache HttpClient 4 (transitive dependency)
- Maven/Gradle dependency management
❌ Out of Scope (with alternatives)
- HTTP/2 → use Unirest 4.x (defaults to HTTP/2)
- WebSocket via Unirest → use Apache HttpClient WebSocket or dedicated library
- Server-Sent Events (SSE) → use Unirest 4.x or custom implementation
- Custom executor support → not available in 3.x
- Java Authenticator integration → use Apache-specific auth mechanisms
- ProxySelector support → use per-request proxies or system properties
When to Use This Skill
Use this skill when the user needs to:
- Make HTTP requests to REST APIs in Java 8+ projects
- Use Apache HttpClient as the HTTP engine
- Have built-in GSON without extra dependencies
- Tune connection pools (
concurrency()) - Control socket timeout independently
- Use automatic retries on socket errors
- Configure per-request proxies
- Use custom HostnameVerifier
Quick Start
Maven dependency (Unirest 3.14.5):
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.14.5</version>
</dependency>
✅ No JSON module declaration needed — GSON is included by default.
Minimal GET request:
String body = Unirest.get("https://api.example.com/users")
.asString()
.getBody();
Minimal POST with JSON:
HttpResponse<JsonNode> response = Unirest.post("https://api.example.com/users")
.header("Content-Type", "application/json")
.body(new User("Alice", "alice@example.com"))
.asJson();
Critical: Installation
Unirest 3.x is a single dependency that includes GSON by default:
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.14.5</version>
</dependency>
✅ No need to declare a separate JSON module —
JsonObjectMapper(GSON-based) is included.
Critical: Configuration
All configuration goes through Unirest.config():
Unirest.config()
.connectTimeout(5000)
.socketTimeout(10000)
.concurrency(200, 20)
.setDefaultHeader("Accept", "application/json")
.setDefaultBasicAuth("user", "pass")
.followRedirects(true)
.verifySsl(true)
.enableCookieManagement(true)
.automaticRetries(true)
.proxy("proxy.com", 8080, "user", "pass");
Key config options:
| Method | Impact | Default |
|---|---|---|
connectTimeout(int) | Connection timeout (ms) | 10000 |
socketTimeout(int) | Socket/read timeout (ms) | 60000 |
concurrency(int, int) | Max total connections, max per route | 200/20 |
followRedirects(boolean) | Follow HTTP redirects | true |
verifySsl(boolean) | Enforce SSL verification | true |
enableCookieManagement(boolean) | Accept/store cookies | true |
automaticRetries(boolean) | Auto-retry on socket errors (up to 4 times) | true |
retryAfter(boolean) | Auto-retry on 429/529 with Retry-After header | false |
defaultBaseUrl(String) | Default base URL for all requests | none |
addShutdownHook(boolean) | Register JVM shutdown hook | false |
useSystemProperties(boolean) | Use system properties for proxies etc. | true |
Multiple configurations:
// Primary instance (same as static Unirest)
UnirestInstance unirest = Unirest.primaryInstance();
// Spawn a new independent instance
UnirestInstance custom = Unirest.spawnInstance();
custom.config().connectTimeout(3000);
⚠️ If you spawn a new instance, YOU are responsible for shutting it down.
See references/configuration.md for full config table, interceptors, object mappers, and metrics.
Critical: Making Requests
Basic request types:
Unirest.get("http://localhost/users").asString();
Unirest.post("http://localhost/users").body(json).asJson();
Unirest.put("http://localhost/users/1").body(user).asEmpty();
Unirest.delete("http://localhost/users/1").asEmpty();
Route parameters:
Unirest.get("http://localhost/users/{id}")
.routeParam("id", "42")
.asString();
// Results in http://localhost/users/42
Query parameters:
Unirest.get("http://localhost/search")
.queryString("q", "unirest")
.queryString("page", 1)
.asString();
Headers and auth:
Unirest.get("http://localhost/protected")
.header("X-Custom", "value")
.basicAuth("user", "pass")
.asString();
Form data:
Unirest.post("http://localhost/form")
.field("name", "Alice")
.field("age", 30)
.asEmpty();
File upload:
Unirest.post("http://localhost/upload")
.field("file", new File("/path/to/file.zip"))
.asEmpty();
Async request:
CompletableFuture<HttpResponse<JsonNode>> future = Unirest.get("http://localhost/data")
.asJsonAsync(response -> {
System.out.println(response.getBody());
});
Per-request proxy (3.x only):
Unirest.get("http://localhost/data")
.proxy("proxy.com", 8080)
.asString();
JSON Patch (RFC-6902):
Unirest.jsonPatch("http://localhost/resource")
.add("/fruits/-", "Apple")
.remove("/bugs")
.replace("/name", "Updated")
.asJson();
See references/requests.md for upload progress, paged requests, client certificates, and more.
Critical: Handling Responses
Response types:
// String
String body = Unirest.get(url).asString().getBody();
// Object mapping (GSON included by default)
Book book = Unirest.get(url).asObject(Book.class).getBody();
// Generic types
List<Book> books = Unirest.get(url)
.asObject(new GenericType<List<Book>>(){}).getBody();
// JSON
JsonNode json = Unirest.get(url).asJson().getBody();
// File
File file = Unirest.get(url).asFile("/tmp/download.zip").getBody();
// Empty (status/headers only)
HttpResponse resp = Unirest.delete(url).asEmpty();
Error handling:
Unirest.get("http://localhost/data")
.asJson()
.ifSuccess(response -> handleSuccess(response))
.ifFailure(response -> {
log.error("Status: " + response.getStatus());
response.getParsingError().ifPresent(e -> {
log.error("Parse error: " + e.getMessage());
});
});
Parsing errors:
response.getParsingError().ifPresent(ex -> {
String originalBody = ex.getOriginalBody();
String message = ex.getMessage();
});
Map error objects:
HttpResponse<Book> book = Unirest.get(url).asObject(Book.class);
Error err = book.mapError(Error.class);
See references/responses.md for download progress, large responses, body mapping, and more.
Critical: Mocking
Static mock:
MockClient mock = MockClient.register();
mock.expect(HttpMethod.GET, "http://api.example.com/users")
.thenReturn("{\"name\":\"Alice\"}")
.withStatus(200);
String body = Unirest.get("http://api.example.com/users")
.asString().getBody();
// body == "{\"name\":\"Alice\"}"
mock.verifyAll(); // Verify all expects were called
Instance mock (3.x requires both clients):
UnirestInstance unirest = Unirest.spawnInstance();
MockClient mock = MockClient.register(unirest);
// In 3.x, the mock implements both Client and AsyncClient
Body matching:
mock.expect(HttpMethod.POST, "http://api.example.com/users")
.body(FieldMatcher.of("name", "Alice", "role", "admin"))
.thenReturn()
.withStatus(201);
Verify with times:
var expect = mock.expect(HttpMethod.GET, "http://api.example.com/users").thenReturn();
expect.verify(); // At least once
expect.verify(Times.never()); // Never called
See references/mocking.md for POJO responses, multiple expects, and more.
Critical: Caching
Basic caching:
Unirest.config().cacheResponses(true);
Advanced caching with options:
Unirest.config().cacheResponses(Cache.builder()
.depth(100) // Max entries
.maxAge(5, TimeUnit.MINUTES)); // Entry TTL
Custom cache (e.g., Guava):
Unirest.config().cacheResponses(
Cache.builder().backingCache(new MyGuavaCache()));
See references/caching.md for custom cache implementation details.
Critical: Proxies
Simple proxy:
Unirest.config().proxy("proxy.com", 8080, "user", "pass");
Per-request proxy (3.x only):
Unirest.get("http://localhost/data")
.proxy("proxy.com", 8080)
.asString();
System properties (default: true in 3.x):
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "7777");
// useSystemProperties defaults to true in 3.x
See references/proxies.md for details.
Quick Fixes
| Error | Cause | Fix |
|---|---|---|
NoClassDefFoundError: kong/unirest/Unirest | Wrong package | Use import kong.unirest.* (not kong.unirest.core.*) |
asObject() returns null body | Response parsing failed | Check response.getParsingError() for details |
ConnectException: Connection timed out | Server unreachable or timeout too low | Increase connectTimeout or check network |
SocketTimeoutException | Read timeout exceeded | Increase socketTimeout (default 60000ms) |
SSLHandshakeException | SSL verification failure | Use verifySsl(false) for dev only, fix certs in prod |
| Proxy not working | System props may be disabled | Check useSystemProperties(true) (default true in 3.x) |
| Too many connections | Connection pool exhausted | Increase concurrency(total, perRoute) |
| Automatic retries not working | Disabled or not applicable | Check automaticRetries(true) (default true) |
Gotchas
- Java 8+ is sufficient — 3.x runs on Java 8 (unlike 4.x which requires Java 11+)
- GSON included by default — No need to declare a separate JSON module (unlike 4.x)
- Package is
kong.unirest— Notkong.unirest.core(that's 4.x) - Single Maven dependency —
unirest-java:3.14.5(unlike 4.x which uses BOM + core + module) - Apache HttpClient engine — Uses Apache HttpClient 4 (not java.net.http.HttpClient)
- Socket timeout is independent —
socketTimeout()controls read timeout separately fromconnectTimeout() - Connection pool tuning —
concurrency(total, perRoute)lets you tune Apache's connection pool - Automatic retries enabled by default —
automaticRetries(true)retries socket errors up to 4 times - Per-request proxies supported —
request.proxy(host, port)works (removed in 4.x) - HostnameVerifier supported —
hostnameVerifier(verifier)for custom SSL hostname verification - Shutdown hooks available —
addShutdownHook(true)registers JVM shutdown hooks - System proxy props enabled by default —
useSystemPropertiesdefaults totrue(unlike 4.x) - No WebSocket via Unirest — Use Apache HttpClient WebSocket or a dedicated library
- No SSE support —
Unirest.sse()does not exist in 3.x - Mock registration requires both clients — MockClient implements both
ClientandAsyncClient
References
Requests
- requests.md — Route params, query params, headers, auth, body types, file uploads, upload progress, async, paged requests, per-request proxy
Responses
- responses.md — asEmpty/asString/asObject/asJson/asFile, GenericType, parsing errors, error object mapping, download progress, large responses, error handling
Configuration
- configuration.md — Full config options table, global interceptors, multiple configurations, object mappers, metrics, Apache-specific options
Mocking
- mocking.md — Static/instance mocks, multiple expects (scoring), verification, body matching, form params, POJO responses
Caching
- caching.md — Basic/advanced caching, custom cache implementations
Proxies
- proxies.md — Simple proxy, system properties, per-request proxy
FAQ
What does the unirest-java-3 skill do?
Unirest-Java 3.x HTTP client library for Java 8+. Use when making HTTP requests (GET/POST/PUT/DELETE), building REST API clients, handling JSON responses, file uploads/downloads, async requests, mocking HTTP calls for testing, configuring proxies, or caching responses. Covers Unirest 3.x (Apache HttpClient based, default GSON included, kong.unirest package) with object mapping, request/response interceptors, and migration guidance.
How do I install unirest-java-3?
Run npx skills add https://github.com/full-stack-skills/java-skills --skill unirest-java-3 in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/unirest-java-3/ (personal) or .claude/skills/unirest-java-3/ (project).
Which AI agents can use unirest-java-3?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is unirest-java-3 safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains unirest-java-3?
It is published by full-stack-skills in full-stack-skills/java-skills. It has 78 recorded installs.
More from full-stack-skills/java-skills
java-development-manual
full-stack-skills/java-skills
Java开发手册规约集合,基于阿里巴巴Java开发手册(嵩山版)。 涵盖7大维度:编程规约、异常日志、单元测试、安全规约、MySQL数据库、工程结构、设计规约。 当用户需要:(1) 编写或审查Java代码 (2) 检查命名/代码规范 (3) 处理异常和日志 (4) 编写单元测试 (5) 安全编码 (6) 数据库设计 (7) 工程架构设计时使用此skill。 触发词:Java规范、阿里规约、代码规范、开发手册、编程规约、异常处理、单元测试、安全、MySQL、工程结构、设计模式。
mybatis-plus-patterns
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
java-code-comments
full-stack-skills/java-skills
Provides comprehensive guidance for adding Java code comments following industry standards and best practices. This skill helps add class-level comments, method-level comments, and field-level comments to Java code. Use when the user wants to add comments to Java code, needs to document Java classes/methods/fields, wants to improve code documentation, or needs to generate JavaDoc comments. This skill covers Controller, Service, ServiceImpl, Mapper, Model, Entity, BO (Business Object), DTO, VO, and other common Java component types. The skill follows a systematic workflow: scan codebase, identify components, create todo list, and add comments in order (class comments → method comments → field comments).
java-conventions
full-stack-skills/java-skills
统一 Java 项目编码规范与注释规范(SLF4J+Lombok 日志、Bean Lombok 注解选择、判空 Objects/Optional、工具类优先级 Spring→Apache Commons→Hutool→Guava、复杂逻辑用设计模式/简单逻辑不拆分、Controller/Service/ServiceImpl/Mapper 注释一致性)。当需要“按 Java 规范重构/Review/补全注释/统一日志/统一工具类使用/补全 JavaDoc”时使用。
mybatis-patterns
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
mapstruct-patterns
full-stack-skills/java-skills
MapStruct 最佳实践模式。从官方 Reference Guide 提炼,覆盖 Mapper 三种定义方式(接口/抽象类/default方法)、Spring 注入策略(CONSTRUCTOR推荐/SETTER解决循环依赖)、嵌套映射模式(显式子方法 dot notation 一次性配置)、@Qualifier @Named 的安全选择、Lombok 集成规则、@MappingComposition 谨慎使用。 纠正 LLM 最常见的错误:用反射 BeanUtils 而非编译期 MapStruct、嵌套映射全写在一个方法、不知 SETTER 解决循环依赖。
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.