PHPackages                             blissjaspis/laravel-rajaongkir-komerce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. blissjaspis/laravel-rajaongkir-komerce

ActiveLibrary[API Development](/categories/api)

blissjaspis/laravel-rajaongkir-komerce
======================================

Laravel Rajaongkir From Komerce

v2.1.0(1mo ago)228MITPHPPHP ^8.2CI passing

Since Jul 18Pushed 1mo agoCompare

[ Source](https://github.com/blissjaspis/laravel-rajaongkir-komerce)[ Packagist](https://packagist.org/packages/blissjaspis/laravel-rajaongkir-komerce)[ Docs](https://github.com/blissjaspis/laravel-rajaongkir-komerce)[ RSS](/packages/blissjaspis-laravel-rajaongkir-komerce/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (23)Versions (7)Used By (0)

Laravel RajaOngkir From Komerce
===============================

[](#laravel-rajaongkir-from-komerce)

[![Tests](https://github.com/blissjaspis/laravel-rajaongkir-komerce/actions/workflows/tests.yml/badge.svg)](https://github.com/blissjaspis/laravel-rajaongkir-komerce/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/0b88139715d87882a8ca9ee087d3bdd08870bbf94494731e454dedc72fa877da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c6973736a61737069732f6c61726176656c2d72616a616f6e676b69722d6b6f6d657263652e737667)](https://packagist.org/packages/blissjaspis/laravel-rajaongkir-komerce)[![Total Downloads](https://camo.githubusercontent.com/e456da9c500b1329bf21d69bdc127319af421e166b089322e106e7c52f834963/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626c6973736a61737069732f6c61726176656c2d72616a616f6e676b69722d6b6f6d657263652e737667)](https://packagist.org/packages/blissjaspis/laravel-rajaongkir-komerce)[![License](https://camo.githubusercontent.com/64767aa5abeae839bcb75de9670b7c1b1e6e872ee53d26a47b3dcef937a7b615/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626c6973736a61737069732f6c61726176656c2d72616a616f6e676b69722d6b6f6d657263652e737667)](https://packagist.org/packages/blissjaspis/laravel-rajaongkir-komerce)

This package provides a simple and easy-to-use Laravel wrapper for the RajaOngkir Komerce API. It supports two methods of address lookup: hierarchical step-by-step selection and direct search with autocomplete functionality.

Requirements
------------

[](#requirements)

RequirementVersionPHP^8.2Laravel^11.0, ^12.0, or ^13.0Installation
------------

[](#installation)

You can install the package via composer:

```
composer require blissjaspis/laravel-rajaongkir-komerce
```

You must publish the configuration file with:

```
php artisan vendor:publish --tag=rajaongkir-komerce-config
```

Or using the provider:

```
php artisan vendor:publish --provider="BlissJaspis\RajaOngkir\Providers\RajaOngkirServiceProvider" --tag="config"
```

Add the following to your `.env` file:

```
RAJAONGKIR_API_KEY=your-api-key
RAJAONGKIR_BASE_URL=https://rajaongkir.komerce.id/api/v1

# Optional
RAJAONGKIR_TIMEOUT=30
RAJAONGKIR_RETRY_TIMES=0
RAJAONGKIR_RETRY_SLEEP=100
RAJAONGKIR_FAKE=false
```

Set `RAJAONGKIR_FAKE=true` in local development to stub all API responses without calling Komerce.

The package is auto-discovered via Laravel's package discovery. No manual registration is required.

Usage
-----

[](#usage)

There are two ways to use Rajaongkir-Komerce:

1. **Step-by-step method**. This was the old method before Komerce acquired Rajaongkir and changed the API.
2. **Direct Search**. This is the latest method used by Komerce after they acquired Rajaongkir.

For existing users whose data is still using the old method, you can continue using method 1.

This package supports 2 ways to access RajaOngkir data:

1. Step-by-step location lookup (`province -> city -> district -> subdistrict`)
2. Direct search and shipping cost lookup (search by keyword, then calculate cost)

You can call the API through the facade or Laravel's service container:

```
use BlissJaspis\RajaOngkir\Facades\RajaOngkir;
use BlissJaspis\RajaOngkir\RajaOngkir as RajaOngkirClient;

// Via Facade (recommended)
$response = RajaOngkir::getProvinces();
$provinces = $response->data;

// Via dependency injection (interface)
use BlissJaspis\RajaOngkir\Contracts\RajaOngkirClient;

public function __construct(private RajaOngkirClient $rajaOngkir) {}

// Or resolve from the container
app(RajaOngkirClient::class)->getProvinces();
```

API methods return a `RajaOngkirResponse` object with `meta`, `data`, `status()`, and `successful()`. Use `getListCourier()` when you need the static courier list (hardcoded from Komerce documentation — no API endpoint).

`RajaOngkir` is registered as a **singleton** in the service container, so the facade and `app()` resolve the same instance.

### Error handling

[](#error-handling)

Failed HTTP requests and API error responses throw `BlissJaspis\RajaOngkir\Exceptions\RajaOngkirException`:

```
use BlissJaspis\RajaOngkir\Exceptions\RajaOngkirException;
use BlissJaspis\RajaOngkir\Facades\RajaOngkir;

try {
    $response = RajaOngkir::getProvinces();
} catch (RajaOngkirException $exception) {
    $statusCode = $exception->statusCode;
    $body = $exception->response;
}
```

### Choosing Between Methods

[](#choosing-between-methods)

**Use Method 1 (Step-by-step)** if:

- You have existing user data stored in the hierarchical format
- You prefer structured location selection with multiple dropdowns
- You're migrating from the old Rajaongkir API structure

**Use Method 2 (Direct Search)** if:

- You're building a new application
- You want a better user experience with search/autocomplete
- You want to simplify your frontend code and reduce API calls
- You want to provide international shipping options

Method 2 is recommended for new implementations as it provides a more modern and user-friendly approach.

### Method 1: Step-by-Step Location Lookup

[](#method-1-step-by-step-location-lookup)

Use this method when users select addresses hierarchically.

#### 1. Finding Provinces

[](#1-finding-provinces)

```
$response = RajaOngkir::getProvinces();
$provinces = $response->data;

{
  "meta": {
    "message": "Success Get Provinces",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "id": 11,
      "name": "DKI Jakarta"
    },
    {
      "id": 6,
      "name": "Jawa Barat"
    }
    // ... more provinces
  ]
}
```

#### 2. Finding Cities

[](#2-finding-cities)

```
$provinceId = 11;
$cities = RajaOngkir::getCity($provinceId);

{
  "meta": {
    "message": "Success Get Cities",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "id": 1,
      "name": "Jakarta Pusat"
    },
    {
      "id": 2,
      "name": "Jakarta Selatan"
    }
    // ... more cities
  ]
}
```

#### 3. Finding Districts

[](#3-finding-districts)

```
$cityId = 1;
$districts = RajaOngkir::getDistrict($cityId);

{
  "meta": {
    "message": "Success Get Districts",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "id": 1,
      "name": "Kemayoran"
    }
    // ... more districts
  ]
}
```

#### 4. Finding Subdistricts

[](#4-finding-subdistricts)

```
$districtId = 1;
$subdistricts = RajaOngkir::getSubDistrict($districtId);

{
  "meta": {
    "message": "Success Get Subdistricts",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "id": 1,
      "name": "Sumur Batu"
    }
    // ... more subdistricts
  ]
}
```

### Method 2: Direct Search and Cost Lookup

[](#method-2-direct-search-and-cost-lookup)

Use this method when users type destination keywords directly, then you calculate shipping.

#### 1. Searching Domestic Destinations

[](#1-searching-domestic-destinations)

```
$search = 'sinduharjo';
$limit = 10; // optional
$offset = 0; // optional
$destinations = RajaOngkir::searchDomestic($search, $limit, $offset);

{
  "meta": {
    "message": "Success Get Domestic Destinations",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "id": 31555,
      "label": "SINDUHARJO, NGAGLIK, SLEMAN, DI YOGYAKARTA, 55581",
      "subdistrict_name": "SINDUHARJO",
      "district_name": "NGAGLIK",
      "city_name": "SLEMAN",
      "province_name": "DI YOGYAKARTA",
      "zip_code": "55581"
    }
  ]
}
```

#### 2. Searching International Destinations

[](#2-searching-international-destinations)

```
$search = 'Malaysia';
$limit = 10; // optional
$offset = 0; // optional
$destinations = RajaOngkir::searchInternational($search, $limit, $offset);

{
  "meta": {
    "message": "Success Get International Destinations",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "id": 108,
      "name": "Malaysia"
    }
    // ... more destinations
  ]
}
```

#### 3. Calculating Domestic Shipping Cost

[](#3-calculating-domestic-shipping-cost)

```
$origin = 1;
$destination = 108;
$weight = 1000;
$courier = 'jne';
$filter = 'lowest';

$cost = RajaOngkir::getCostDomestic($origin, $destination, $weight, $courier, $filter);

{
  "meta": {
    "message": "Success Calculate Domestic Shipping cost",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "name": "Nusantara Card Semesta",
      "code": "ncs",
      "service": "DARAT",
      "description": "Regular Darat",
      "cost": 8000,
      "etd": "6-7 day"
    },
    {
      "name": "Citra Van Titipan Kilat (TIKI)",
      "code": "tiki",
      "service": "ECO",
      "description": "Economy Service",
      "cost": 15000,
      "etd": "5 day"
    }
  ]
}
```

#### 4. Calculating International Shipping Cost

[](#4-calculating-international-shipping-cost)

```
$origin = 1;
$destination = 108;
$weight = 1000;
$courier = 'jne';
$filter = 'lowest';

$cost = RajaOngkir::getCostInternational($origin, $destination, $weight, $courier, $filter);

{
  "meta": {
    "message": "Success Calculate International Shipping Cost",
    "code": 200,
    "status": "success"
  },
  "data": [
    {
      "name": "Rayspeed Indonesia",
      "code": "ray",
      "service": "Regular Service",
      "description": "Retail",
      "currency": "IDR",
      "cost": 55000,
      "etd": ""
    },
    {
      "name": "Lion Parcel",
      "code": "lion",
      "service": "INTERPACK",
      "description": "Active",
      "currency": "IDR",
      "cost": 65000,
      "etd": "2-3 day"
    }
  ]
}
```

#### 5. Tracking Waybill

[](#5-tracking-waybill)

```
$waybill = 'MT685U91';
$courier = 'jne';

$waybill = RajaOngkir::getWaybill($waybill, $courier);

{
  "meta": {
    "message": "Success Get Waybill",
    "code": 200,
    "status": "success"
  },
  "data": {
    "delivered": true,
    "summary": {
      "courier_code": "wahana",
      "courier_name": "Wahana Prestasi Logistik",
      "waybill_number": "MT685U91",
      "service_code": "",
      "waybill_date": "2024-10-08",
      "shipper_name": "TOKO ALAT LUKIS (08112XXXXXX)",
      "receiver_name": "FIKRI EL SARA (085668XXXXXX)",
      "origin": "",
      "destination": "di Kota Sukabumi",
      "status": "DELIVERED"
    },
    "details": {
      "waybill_number": "MT685U91",
      "waybill_date": "2024-10-08",
      "waybill_time": "11:14:29",
      "weight": "",
      "origin": "",
      "destination": "di Kota Sukabumi",
      "shipper_name": "TOKO ALAT LUKIS (08112XXXXXX)",
      "shipper_address1": "",
      "shipper_address2": "",
      "shipper_address3": "",
    }
    "delivery_status": {
      "status": "DELIVERED",
      "pod_receiver": "FIKRI EL SARA (085668XXXXXX)",
      "pod_date": "2024-10-11",
      "pod_time": "09:26:13"
    },
    "manifest": [
      // ... more manifest
    ]
  }
}
```

### Other Useful Methods

[](#other-useful-methods)

`getListCourier()` returns a static list of supported courier codes and display names (not an API call):

```
$couriers = RajaOngkir::getListCourier();

// [
//     'jne' => 'JNE',
//     'sicepat' => 'SICEPAT',
//     'tiki' => 'TIKI',
//     // ...
// ]
```

API Reference
-------------

[](#api-reference)

For comprehensive API documentation including:

- Complete method signatures with parameter types
- Detailed response structures
- Error handling examples
- Testing examples
- Best practices
- Migration guides
- Troubleshooting

Please see [API-REFERENCE.md](API-REFERENCE.md) for detailed technical documentation optimized for developers and AI assistants.

Testing &amp; Quality
---------------------

[](#testing--quality)

This package uses [GitHub Actions](.github/workflows/tests.yml) for continuous integration: lint runs once, then tests run across PHP 8.2–8.5 and Laravel 11–13.

CommandDescription`composer test`Run PHPUnit tests`composer lint`Syntax check, Pint (dry-run), and PHPStan (level 6)`composer analyse`Run PHPStan static analysis only`composer format`Auto-format code with Laravel Pint`composer check`Run `lint` + `test` (recommended before PRs)```
composer check
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

For contribution guidelines and local development setup, see [CONTRIBUTING](CONTRIBUTING.md).

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Bliss Jaspis](https://github.com/blissjaspis)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance91

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~76 days

Total

6

Last Release

44d ago

Major Versions

1.2.0 → 2.0.02026-03-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8768022?v=4)[jaspis](/maintainers/jaspis)[@jaspis](https://github.com/jaspis)

---

Top Contributors

[![blissjaspis](https://avatars.githubusercontent.com/u/19877298?v=4)](https://github.com/blissjaspis "blissjaspis (26 commits)")

---

Tags

laravelshippingindonesiacourierlogisticsrajaongkirkomerce

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/blissjaspis-laravel-rajaongkir-komerce/health.svg)

```
[![Health](https://phpackages.com/badges/blissjaspis-laravel-rajaongkir-komerce/health.svg)](https://phpackages.com/packages/blissjaspis-laravel-rajaongkir-komerce)
```

###  Alternatives

[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816334.1k3](/packages/defstudio-telegraph)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
