Raja Ongkir API
Via Composer
$ composer require ngopibareng/rajaongkir-laravel
Publish config :
php artisan vendor:publish
Setting .env code :
RAJAONGKIR_API_KEY=YOUR_API_KEY
RAJAONGKIR_ACCOUNT_TYPE=starter/basic/pro
# Cache every request
RAJAONGKIR_CACHE_ENABLED=true
RAJAONGKIR_CACHE_DRIVER=file/redis
- PHP >= 7.3
- Laravel >= 7
Get all couriers :
use RajaongkirLaravel as RajaOngkir;
$couriers = RajaOngkir::courier()->all();
Get supported couriers for shipping cost
use RajaongkirLaravel as RajaOngkir;
$couriers = RajaOngkir::courier()->getSupported();
use RajaongkirLaravel as RajaOngkir;
$couriers = RajaOngkir::courier()->getInternationalCouriers();
use RajaongkirLaravel as RajaOngkir;
$couriers = RajaOngkir::courier()->getDomesticCouriers();
Get all provinces :
use RajaongkirLaravel as RajaOngkir;
$provinces = RajaOngkir::province()->get();
$response = $province->response()->toArray();
Get province by province id
use RajaongkirLaravel as RajaOngkir;
$province = RajaOngkir::province()->find(11);
$response = $province->response()->toArray();
Get all cities :
use RajaongkirLaravel as RajaOngkir;
$cities = RajaOngkir::city()->get();
$response = $cities->response()->toArray();
Get city by parameters
use RajaongkirLaravel as RajaOngkir;
$cities = RajaOngkir::city();
$cities = $cities->whereCityID(11)->get(); //by city_id
$cities = $cities->province(11)->get(); //by province_id
Get districts by parameters :
use RajaongkirLaravel as RajaOngkir;
$city_id = 11;
$districts = RajaOngkir::district()->get($city_id); // by city_id
$districts = $districts->whereID()->get(); //by district_id
$response = $districts->response()->toArray();
Get international origin by parameters :
use RajaongkirLaravel as RajaOngkir;
$internationals = RajaOngkir::internationalOrigin()->get(); // all
$internationals = $internationals->city(11)->get(); //by city_id
$internationals = $internationals->province(11)->get(); //by province_id
$response = $internationals->response()->toArray();
Get international destination by parameters :
use RajaongkirLaravel as RajaOngkir;
$internationals = RajaOngkir::internationalDestination()->get(); // all
$internationals = $internationals->country(11)->get(); //by country_id
Get international cost by parameters :
use RajaongkirLaravel as RajaOngkir;
$parameters = [
'origin' => 155, // origin city_id
'destination' => 80, // destination city_id
'weight' => 1300, // weight
'courier' => 'jne' // courier code
];
$internationals = RajaOngkir::internationalCost()->get($parameters);
$response = $internationals->response()->toArray();
Get latest conversion currency (Dollar & Rupiah)
use RajaongkirLaravel as RajaOngkir;
$currency = RajaOngkir::currency()->get();
$response = $currency->response()->toArray();
Get shipping cost by parameters :
use RajaongkirLaravel as RajaOngkir;
$parameters = [
'origin' => 155, // origin city_id
'originType' => 'city',
'destination' => 444, // destination city_id
'destinationType'=> 'city',
'weight' => 1300, // weight
'courier' => 'jne' // courier code
];
$costs = RajaOngkir::cost()->get($parameters);
$response = $costs->response()->toArray();
Get waybill by parameters :
use RajaongkirLaravel as RajaOngkir;
$trackingCode = '';
$courierCode = 'jne';
$waybills = RajaOngkir::waybill()->find($trackingCode, $courierCode);
$response = $waybills->response()->toArray();
Pre Cache rajaongkir request
# Avaiable cache : province, city, subdistrict, internationalDestination, internationalOrigin
# Pre-cache all raja ongkir request
php artisan rajaongkir:cache
# Pre-cache selected request raja ongkir
php artisan rajaongkir:cache province
Remove cache
# Avaiable cache : province, city, subdistrict, internationalDestination, internationalOrigin
# Remove all raja ongkir caches
php artisan rajaongkir:cache-clear
# Remove selected raja ongkir cache
php artisan rajaongkir:cache-clear province
use RajaongkirLaravel as RajaOngkir;
$widget = RajaOngkir::widget();
$widget = $widget->setID('widget-rajaongkir'); //set selector id
$widget = $widget->build($theme = 'light');
Please see the changelog for more information on what has changed recently.
$ composer test
Please see contributing.md for details and a todolist.
MIT. Please see the license file for more information.