PHPackages                             juhara/rajaongkir - 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. juhara/rajaongkir

ActivePhp-class[API Development](/categories/api)

juhara/rajaongkir
=================

Advanced RajaOngkir API PHP Class

v1.0.1(3y ago)021MITPHPPHP ^7.4|^8.0.2

Since May 5Pushed 3y agoCompare

[ Source](https://github.com/zamronypj/rajaongkir)[ Packagist](https://packagist.org/packages/juhara/rajaongkir)[ Fund](https://opencollective.com/steevenz)[ Patreon](https://www.patreon.com/steevenz)[ RSS](/packages/juhara-rajaongkir/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

RajaOngkir
==========

[](#rajaongkir)

[RajaOngkir API](https://rajaongkir.com) PHP client

- Support all kind of RajaOngkir account (Starter, Basic, Pro).
- Get shipping cost based on weight (gram) and/or volume (width x heigth x length).

This is [original RajaOngkir library](https://github.com/steevenz/rajaongkir) fork with goal to add PHP 8.0 support also replace HTTP Client with Guzzle.

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

[](#requirements)

- PHP &gt;= 7.4, PHP &gt;= 8.0
- [Composer](https://getcomposer.org)
- [Guzzle](https://docs.guzzlephp.org/en/stable/index.html)

Installation
------------

[](#installation)

```
$ composer require juhara/rajaongkir

```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

Create instance for Starter account

```
$rajaongkir = new Juhara\Rajaongkir('YOUR_API_KEY', Rajaongkir::ACCOUNT_STARTER);
```

When account type is not set, it is assumed starter, so code below is same as above.

```
$rajaongkir = new Juhara\Rajaongkir('YOUR_API_KEY');
```

Create instance for Basic account

```
use Juhara\Rajaongkir;

$rajaongkir = new Rajaongkir('YOUR_API_KEY', Rajaongkir::ACCOUNT_BASIC);
```

Create instance for Pro account

```
use Juhara\Rajaongkir;

$rajaongkir = new Rajaongkir('YOUR_API_KEY', Rajaongkir::ACCOUNT_PRO);
```

### Get list of provinces

[](#get-list-of-provinces)

```
$provinces = $rajaongkir->getProvinces();
```

### Get detail of a province

[](#get-detail-of-a-province)

```
// province ID = 1
$province = $rajaongkir->getProvince(1);
```

### Get list of all cities

[](#get-list-of-all-cities)

```
$cities = $rajaongkir->getCities();
```

### Get list of cities in a province

[](#get-list-of-cities-in-a-province)

```
// province id = 1
$cities = $rajaongkir->getCities(1);
```

### Get city detail

[](#get-city-detail)

```
// city id = 1
$city = $rajaongkir->getCity(1);
```

### Get list of subdistricts in a city

[](#get-list-of-subdistricts-in-a-city)

```
// city id = 39
$subdistricts = $rajaongkir->getSubdistricts(39);
```

### Get subdistrict detail

[](#get-subdistrict-detail)

```
// subdistrict id = 537
$subdistrict = $rajaongkir->getSubdistrict(537);
```

### Get list all cities with international shipping support

[](#get-list-all-cities-with-international-shipping-support)

```
// not available for starter
$internationalOrigins = $rajaongkir->getInternationalOrigins();
```

### Get list all cities in a province with international shipping support

[](#get-list-all-cities--in-a-province-with-international-shipping-support)

```
// not available for starter
// province id = 6
$internationalOrigins = $rajaongkir->getInternationalOrigins(6);
```

### Get international origin detail

[](#get-international-origin-detail)

```
// not available for starter
// city id = 152
// province id = 6
$internationalOrigin = $rajaongkir->getInternationalOrigin(152, 6);
```

### Get international country list

[](#get-international-country-list)

```
// not available for starter
$internationalDestinations = $rajaongkir->getInternationalDestinations();
```

### Get international destination detail

[](#get-international-destination-detail)

```
// not available for starter
// country id = 108
$internationalDestination = $rajaongkir->getInternationalDestination(108);
```

### Get shipping cost based on weight (in gram)

[](#get-shipping-cost-based-on-weight-in-gram)

```
// origin city id = 501
// destination subdistrict  id = 574
// weight 1000 gram
// courier = 'jne'
$cost = $rajaongkir->getCost(['city' => 501], ['subdistrict' => 574], 1000, 'jne');
```

### Get shipping cost based on volume

[](#get-shipping-cost-based-on-volume)

```
// origin city id = 501
// destination subdistrict  id = 574
// volume 50x60x70
// courier = 'jne'
$cost = $rajaongkir->getCost(
    ['city' => 501],
    ['subdistrict' => 574],
    [
        'width'  => 50,
        'height' => 60,
        'length' => 70,
    ],
    'jne'
);
```

### Get shipping cost based on weight or volume

[](#get-shipping-cost-based-on-weight-or-volume)

```
// origin city id = 501
// destination subdistrict  id = 574
// weight 1000 gram
// volume 50x60x70
// courier = 'jne'
$cost = $rajaongkir->getCost(
    ['city' => 501],
    ['subdistrict' => 574],
    [
        'weight' => 1000,
        'length' => 50,
        'width'  => 50,
        'height' => 50,
    ],
    'jne'
);
```

### Get international shipping cost based on weight

[](#get-international-shipping-cost-based-on-weight)

```
// not available for starter
// origin city id = 152
// destination country id = 108
// weight 1400 gram
// courier = 'pos'
$cost = $rajaongkir->getCost(
    ['city' => 152],
    ['country' => 108],
    1400,
    'pos'
);
```

### Track shipping

[](#track-shipping)

```
// receipt id (no resi pengiriman) = 'SOCAG00183235715'
// courier = 'jne'
 $waybill = $rajaongkir->getWaybill('SOCAG00183235715', 'jne');
```

### Get IDR currency exchange to USD

[](#get-idr-currency-exchange-to-usd)

```
 $currency = $rajaongkir->getCurrency();
```

### Get latest error

[](#get-latest-error)

```
// get latest error
 if(false === ($waybill = $rajaongkir->getWaybill('SOCAG00183235715', 'jne'))) {
    var_dump($rajaongkir->getErrors());
 }
```

### Get courier list based on account type

[](#get-courier-list-based-on-account-type)

```
 $supportedCouriers = $rajaongkir->getSupportedCouriers();
```

### Get waybill tracking list based on account type

[](#get-waybill-tracking-list-based-on-account-type)

```
 $supportedWayBills = $rajaongkir->getSupportedWayBills();
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~0 days

Total

2

Last Release

1103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd0025c7497dfdd58effcb23d74b5cd5a970af180efcf70fd1f6a83da8136c23?d=identicon)[zamronypj](/maintainers/zamronypj)

---

Top Contributors

[![steevenz](https://avatars.githubusercontent.com/u/218405?v=4)](https://github.com/steevenz "steevenz (11 commits)")[![zamronypj](https://avatars.githubusercontent.com/u/6128462?v=4)](https://github.com/zamronypj "zamronypj (8 commits)")[![dankerizer](https://avatars.githubusercontent.com/u/587674?v=4)](https://github.com/dankerizer "dankerizer (2 commits)")[![sofyansitorus](https://avatars.githubusercontent.com/u/1689373?v=4)](https://github.com/sofyansitorus "sofyansitorus (2 commits)")[![totoprayogo1916](https://avatars.githubusercontent.com/u/2387514?v=4)](https://github.com/totoprayogo1916 "totoprayogo1916 (1 commits)")

---

Tags

phprajaongkirrajaongkir-apiapirajaongkir

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/juhara-rajaongkir/health.svg)

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[get-stream/stream-chat

A PHP client for Stream Chat (https://getstream.io/chat/)

301.8M2](/packages/get-stream-stream-chat)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

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