Skip to content

About

Official Java SDK for the ZalTrack Zalando price tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

ZalTrack Java SDK

The official Java SDK for the ZalTrack Zalando price tracking API.

Track Zalando prices and products with a scheduled watchlist, price history and alerts.

The SDK exposes 9 typed methods, one per documented endpoint, each with a parameter builder, plus clearTargetPrice() and a generic request(). It uses java.net.http.HttpClient and Jackson.

Requirements

  • Java 17 or newer

Installation

The SDK is not on Maven Central. Build it from source, which installs it in your local Maven repository:

git clone https://github.com/zaltrackdev/zaltrack-java.git
cd zaltrack-java
mvn -q install -DskipTests

Then add it to your project. Maven:

<dependency>
  <groupId>dev.zaltrack</groupId>
  <artifactId>zaltrack</artifactId>
  <version>0.1.0</version>
</dependency>

Gradle, with mavenLocal() in your repositories:

implementation("dev.zaltrack:zaltrack:0.1.0")

Get your API key

Sign up for ZalTrack or sign in, then copy your API key from the dashboard. ZalTrackClient.fromEnv() reads the ZALTRACK_API_KEY environment variable.

Quick start

import dev.zaltrack.ApiResponse;
import dev.zaltrack.ZalTrackClient;
import dev.zaltrack.params.SearchZalandoParams;

ZalTrackClient client = ZalTrackClient.fromEnv();
ApiResponse response = client.searchZalando(SearchZalandoParams.builder().query("nike trainers").build());
System.out.println(response.json().toPrettyString());

Parameter builders mirror the API reference; build() checks required parameters. Use response.as(MyType.class) to map the JSON onto your own types.

HTTP methods

Each method uses the HTTP verb of its endpoint. GET and DELETE send parameters in the query string; POST and PATCH send them as a JSON body, except wait on /products/{id}/check, which stays in the query string. Null values are never sent; to remove a product's target price, call client.clearTargetPrice(id), which sends {"target_price": null}.

Any endpoint

ApiResponse response = client.request("GET", "/account", Map.of());

Errors

try {
  client.searchZalando(SearchZalandoParams.builder().query("nike trainers").build());
} catch (ZalTrackApiException e) {
  System.err.println(e.status() + ": " + e.getMessage());
}
Exception When
ZalTrackConfigurationException Missing API key, invalid options or unsupported method.
ZalTrackSerializationException A required parameter is missing or a value can't be sent.
ZalTrackTransportException Network failure, timeout or interruption.
ZalTrackApiException Non-2xx status (status(), errorMessage(), errorCode() such as insufficient_credits, responseBody(), rawResponse()).
ZalTrackResponseDecodingException A success response could not be decoded.

All of them extend the unchecked ZalTrackException.

Retries

Requests are retried up to 3 times after a network error, a 408, 500, 502, 503 or 504. Other statuses, such as 400, 401, 402, 404 or 429, and client-side timeouts are not retried: the API's rate limits last until the hour (or the day) is over, and on the free plan every retry would count as a request. The delay starts at 1 second and grows 1.5× per retry (capped at 30 seconds); a Retry-After header wins.

ZalTrackClient client = ZalTrackClient.builder().maxRetries(5).retryDelay(Duration.ofMillis(500)).build();
client.searchZalando(SearchZalandoParams.builder().query("nike trainers").build(), RequestOptions.builder().maxRetries(0).build()); // one request without retries

Batch requests

batch() runs a function per item on 10 threads (concurrency) and returns one BatchResult per item, in input order. A failing item never stops the others.

List<String> inputs = List.of("nike trainers", "rain jacket", "leather boots");
List<BatchResult<ApiResponse>> results = client.batch(inputs, 5, value ->
    client.searchZalando(SearchZalandoParams.builder().query(value).build()));
for (BatchResult<ApiResponse> result : results) {
  if (result.ok()) {
    System.out.println(result.value().json());
  } else {
    System.err.println(inputs.get(result.index()) + ": " + result.error().getMessage());
  }
}
Constant Default Description
ZalTrackClient.DEFAULT_CONCURRENCY 10 Tasks run at the same time by batch
ZalTrackClient.DEFAULT_TIMEOUT Duration.ofSeconds(120) Request timeout
ZalTrackClient.MAX_RETRIES 3 Retry attempts after a network error, a 408/5xx
ZalTrackClient.RETRY_BACKOFF_FACTOR 1.5 Exponential backoff multiplier
ZalTrackClient.DEFAULT_RETRY_DELAY Duration.ofSeconds(1) Delay before the first retry

Configuration

ZalTrackClient client = ZalTrackClient.builder()
    .apiKey(System.getenv("ZALTRACK_API_KEY"))
    .timeout(Duration.ofSeconds(60)) // default 120 s, null disables
    .header("X-Trace", "abc")
    .transport(ZalTrackTransport.fromHttpClient(myHttpClient)) // optional
    .build();

Endpoints

9 methods, generated from the OpenAPI document.

Method HTTP Description
checkProduct() POST /products/{id}/check Asks for a check right away (1 credit), at most once per 5 minutes; earlier calls return the product unchanged. A paused product has to be…
clearTargetPrice() PATCH /products/{id} Removes the target price: sends {"target_price": null}.
deleteProduct() DELETE /products/{id} Removes the product and its price history.
getAccount() GET /account Your plan, the credits left (monthly allowance and packs), how many products you track and the credits they use per month, the credits each…
getArticleHistory() GET /history Every price ZalTrack read for an article reference on a marketplace over the period, whoever tracks it, oldest first, with the lowest, high…
getProduct() GET /products/{id} The product's latest state and every price read of the period, oldest first. The history covers every read of this article reference on thi…
listProducts() GET /products Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with article_id (and marketplace) to k…
searchZalando() GET /search Zalando search results (sponsored included), to find the article reference of a product. Free, limited to 30 searches per hour.
trackProduct() POST /products Adds an article reference or a Zalando link to your watchlist. The first check runs in the background within seconds (checking is true unti…
updateProduct() PATCH /products/{id} Target price, drop alerts, check interval, or pause. Send only what changes. On the free plan, alerts (price drop, back in stock, target pr…

All ZalTrack SDKs

SDK Package Install
Node.js @zaltrack/sdk npm install @zaltrack/sdk
Python zaltrack pip install zaltrack
Go zaltrack-go go get github.com/zaltrackdev/zaltrack-go
.NET ZalTrack dotnet add package ZalTrack
Ruby zaltrack gem install zaltrack
PHP zaltrack/sdk composer require zaltrack/sdk
Java zaltrack-java build from source, see its README
CLI @zaltrack/cli npm install -g @zaltrack/cli
MCP server @zaltrack/mcp npx -y @zaltrack/mcp

Trademarks

ZALANDO® is a registered trademark of Zalando SE. ZalTrack is not affiliated with, endorsed or sponsored by Zalando.

License

MIT — see LICENSE.

About

Official Java SDK for the ZalTrack Zalando price tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages