Java
Coordinates: io.github.valeryverkhoturov:wb-api-client on Maven Central.
- Java: 8+ (compiled with
-source 1.8 -target 1.8) - HTTP: OkHttp 4
- JSON: Gson + gson-fire
- Secret wrapper: per-sub-module
SecretString
Install
<dependency>
<groupId>io.github.valeryverkhoturov</groupId>
<artifactId>wb-api-client</artifactId>
<version>LATEST</version>
</dependency>dependencies {
implementation("io.github.valeryverkhoturov:wb-api-client:LATEST")
}dependencies {
implementation 'io.github.valeryverkhoturov:wb-api-client:LATEST'
}libraryDependencies += "io.github.valeryverkhoturov" % "wb-api-client" % "LATEST"Replace LATEST with the current 1.YYYYMMDD.N version from releases.
Package layout
Base package: io.github.valeryverkhoturov.wbapi. Each WB category lives in a sub-package with its own ApiClient, models, and api classes.
import io.github.valeryverkhoturov.wbapi.items.ApiClient;
import io.github.valeryverkhoturov.wbapi.items.api.ItemsApi;Sub-packages
general, items, orders_fbs, orders_dbw, dbs, in_store_pickup, orders_fbw, promotion, communications, rates, analytics, reports, finances.
Full per-module API class listing: clients/java/README.md.
Auth
import io.github.valeryverkhoturov.wbapi.items.ApiClient;
import io.github.valeryverkhoturov.wbapi.items.api.ItemsApi;
ApiClient client = new ApiClient();
client.setAccessToken("<your WB JWT>");
ItemsApi api = new ItemsApi(client);setAccessToken takes a plain String and wraps it in the sub-module's SecretString internally — the token redacts under logging and debug dumps from that point on.
One SecretString per sub-package — why?
The wrapper is generated into each sub-package rather than shared across the whole library because openapi-generator emits fully isolated SDKs per spec — there is no shared "core" module. Consolidating would require an additional generator pass with cross-module coupling. The cost is a class per sub-package; the benefit is the client remains a pure openapi-generator output with only surgical patches.
Practically you never touch them: setAccessToken wraps your plain string in the sub-module's own SecretString — io.github.valeryverkhoturov.wbapi.items.SecretString vs .orders_fbs.SecretString — automatically.
Custom OkHttp client
Wire your own instance for proxying, interceptors, or custom timeouts:
import okhttp3.OkHttpClient;
import java.time.Duration;
OkHttpClient http = new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(120))
.build();
ApiClient client = new ApiClient(http);
client.setAccessToken(TOKEN);Java 8 vs newer
The generator emits Java-8-compatible code with threetenbp for date/time. If you're on Java 11+, this still works — no need to add a "modern" dependency. If you'd rather use java.time directly, the models expose the underlying string values via set*ToString / get*ToString methods where applicable.
Testing
Override the base path:
ApiClient client = new ApiClient();
client.setBasePath("http://localhost:8080");See also
