Search by

Official PHP SDK for the Watchlog watch price tracking API.

v0.1.0 2026-11-30 20:35 UTC

This package is auto-updated.

Last update: 2026-12-01 17:14:47 UTC


README

The official PHP SDK for the Watchlog watch price tracking API.

Track watch prices, by reference number or single listing, with a scheduled watchlist, price history and alerts.

The SDK exposes 9 methods, one per documented endpoint (with array-shape PHPDoc for static analysis), plus clearTargetPrice() and a generic request(). It sends requests through any PSR-18 client and uses Guzzle by default.

Requirements

  • PHP 8.1 or newer

Installation

composer require watchlogdev/sdk

Get your API key

Sign up for Watchlog or sign in, then copy your API key from the dashboard. The client reads the WATCHLOG_API_KEY environment variable when no key is passed.

Quick start

<?php

require 'vendor/autoload.php';

use Watchlog\Client;

$client = new Client(getenv('WATCHLOG_API_KEY') ?: null);
$response = $client->searchWatches(['query' => 'submariner']);
print_r($response->data);

Parameter arrays use the names of the API reference. Unknown names throw a SerializationException; use request() for undocumented parameters.

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 PATCH /products/{id} with {"target_price": null}.

null values are omitted, false and 0 are sent, and lists repeat the parameter name.

Any endpoint

$response = $client->request('GET', '/account');

Errors

use Watchlog\Exception\ApiException;

try {
    $client->searchWatches(['query' => 'submariner']);
} catch (ApiException $exception) {
    echo $exception->status, ': ', $exception->getMessage();
}
Exception When
ConfigurationException Missing API key, invalid options or unsupported method.
SerializationException A required parameter is missing, unknown or can't be sent.
TransportException Network failure or timeout.
ApiException Non-2xx status (status, errorCode, errorMessage, responseBody, rawResponse).
ResponseDecodingException A success response could not be decoded.

errorCode is the API's error.code, such as insufficient_credits, product_limit or not_found (null when the body has none).

All of them extend Watchlog\Exception\WatchlogException.

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.

$client = new Client(null, ['max_retries' => 5, 'retry_delay' => 0.5]);
$client->searchWatches(['query' => 'submariner'], new RequestOptions(maxRetries: 0)); // one request without retries

Batch requests

batch() sends several calls with at most 10 requests in flight ($concurrency), through Guzzle's connection pool, and returns one BatchResult per call in input order. A failing call never stops the others. With a custom PSR-18 client the calls run one after another.

$inputs = ['submariner', 'speedmaster', 'royal oak'];
$calls = array_map(static fn(string $value): array => ['searchWatches', ['query' => $value]], $inputs);

foreach ($client->batch($calls, concurrency: 5) as $result) {
    if ($result->ok()) {
        print_r($result->value->data);
    } else {
        echo $inputs[$result->index], ': ', $result->error->getMessage(), "\n";
    }
}
Constant Default Description
Client::DEFAULT_CONCURRENCY 10 Tasks run at the same time by batch
Client::DEFAULT_TIMEOUT 120.0 Request timeout (seconds)
Client::MAX_RETRIES 3 Retry attempts after a network error, a 408/5xx
Client::RETRY_BACKOFF_FACTOR 1.5 Exponential backoff multiplier
Client::DEFAULT_RETRY_DELAY 1.0 Delay before the first retry (seconds)

Options and custom HTTP clients

$client = new Client(null, [
    'timeout' => 60.0,               // seconds, default 120 (default Guzzle client only)
    'headers' => ['X-Trace' => 'abc'],
    'http_client' => $psr18Client,   // optional: any PSR-18 client
]);

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…
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…
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 reference on this market…
getWatchHistory() GET /history Every price Watchlog read for a reference or listing id in a currency over the period, whoever tracks it, oldest first, with the lowest, hi…
listProducts() GET /products Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with watch_id (and marketplace) to kno…
searchWatches() GET /search Watch models matching the keywords first (watch_id is their reference number, price the lowest asking price last seen across the whole mark…
trackProduct() POST /products Adds a watch to your watchlist: a model by its reference number (126610LN), priced at the lowest asking price among the current listings th…
updateProduct() PATCH /products/{id} Target price, drop alerts, check interval, or pause. Send only what changes. On the free plan, alerts (price drop, back on the market, targ…

All Watchlog SDKs

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

Trademarks

Watch brand and model names are trademarks of their respective owners. Watchlog is an independent service, not affiliated with any watch brand, dealer or marketplace.

License

MIT — see LICENSE.