Official PHP client for the Klik Resi API. Track shipments, calculate shipping rates, and look up Indonesian locations (provinces, cities, districts) across couriers such as JNE, J&T, Shopee Express, SiCepat, TIKI, and more.
Full API reference: docs.klikresi.com
- PHP 8.1+
- A PSR-18 HTTP client (Guzzle 7 is installed by default)
composer require klikresi/php-sdk<?php
require 'vendor/autoload.php';
use Klikresi\PhpSdk\Client;
use Klikresi\PhpSdk\Courier;
$client = new Client('YOUR-API-KEY');
$tracking = $client->tracking()->get('YOUR-AWB', Courier::JNE);
echo $tracking->status.PHP_EOL;
foreach ($tracking->histories as $history) {
echo $history->date->format('Y-m-d H:i').' '.$history->message.PHP_EOL;
}// Basic tracking (charged per successful request).
$t = $client->tracking()->get('YOUR-AWB', Courier::JNE);
// ID Express requires an extra `number` (phone number) parameter.
// When provided, it is passed through as a query parameter.
$t = $client->tracking()->get('YOUR-AWB', Courier::ID_EXPRESS, ['number' => '08123456789']);The response contains a normalized status
(DeliveryStatus::INFO_RECEIVED, IN_TRANSIT, OUT_FOR_DELIVERY,
FAILED_ATTEMPT, DELIVERED, RETURN_TO_SENDER, EXCEPTION, EXPIRED,
PENDING) plus origin, destination, and the full event history
(dates as DateTimeImmutable).
// By district IDs, optionally filtered to specific couriers.
$r = $client->rates()->calculateById('33.08.20', '32.09.31', 1, [Courier::JNE]);
// By location names.
$r = $client->rates()->calculateByName('Secang, Kabupaten Magelang, Jawa Tengah', 'Depok, Kabupaten Cirebon, Jawa Barat', 1);
// By postal codes.
$r = $client->rates()->calculateByPostalCode(56195, 45155, 1);All location endpoints are cursor-paginated. Request one page, or use the
all* helpers to fetch everything automatically.
// Search locations by keyword.
$page = $client->location()->search('depok', ['limit' => 10]);
echo $page->nextCursor.PHP_EOL;
// Single pages.
$provinces = $client->location()->provinces();
$cities = $client->location()->cities('33');
$districts = $client->location()->districts('33.08');
// Everything, following cursors automatically.
$all = $client->location()->allLocations('depok');
$allProvinces = $client->location()->allProvinces();// Fetch the profile of the account that owns the API key.
$me = $client->me()->get();The response contains the account id, name, email, and current balance.
Use the Courier constants: Courier::SPX, Courier::JNE, Courier::JNT,
Courier::SICEPAT, Courier::NINJA, Courier::POS, Courier::SAP,
Courier::LEX, Courier::LION, Courier::ID_EXPRESS, Courier::ANTERAJA,
Courier::WAHANA, Courier::TIKI.
Any non-2xx response throws a Klikresi\PhpSdk\Exceptions\ApiException
carrying the HTTP status and the API's message:
use Klikresi\PhpSdk\Exceptions\ApiException;
try {
$client->tracking()->get('YOUR-AWB', Courier::JNE);
} catch (ApiException $e) {
echo $e->getStatusCode().' '.$e->getMessage().PHP_EOL;
}The client constructor takes only your API key. The base URL defaults to
https://klikresi.com; it can be overridden with the KLIKRESI_BASE_URL
environment variable (useful for tests and proxies). Requests time out
after 30 seconds.
The client is built on PSR-18 and PSR-17: Guzzle 7 is used by default, and
you can plug in any other implementation by overriding the internal
createHttp() factory in a subclass.
See the examples directory for runnable samples.
MIT