Endpoint RajaOngkir for Step-by-Step Method
Description:
The Step-by-Step Method endpoint in RajaOngkir refers to the API used to retrieve a hierarchical list of locations
(provinces → cities → districts → subdistricts) in a structured, sequential manner. This data is essential for
applications that calculate shipping rates, as it provides the required location identifiers needed to define an origin
or destination when requesting shipping costs.
This endpoint serves as the foundation for any logistics or e-commerce platform that integrates with RajaOngkir, especially when users need to select where a package will be shipped from or delivered to through dropdown menus or form-based selections.
In short, this endpoint provides the geographic base data in a structured hierarchy (Province → City → District → Subdistrict) required to accurately calculate and display shipping options using the RajaOngkir service.
🔹 What the Step-by-Step Method Includes:
- Province List: Used to populate the first layer of location selection - provides all available provinces in Indonesia
- City/Regency List: Depends on the selected province; used to refine location selection to specific cities or regencies within that province
- District List: Offers more precise location targeting under a specific city or regency - provides district-level granularity
- Subdistrict List: (Optional) Provides the most detailed location level for maximum precision and accuracy in shipping calculations
- Calculate Cost: Uses the selected location data (either District ID or Subdistrict ID), along with weight and courier, to calculate the total shipping cost
🔹 Two Calculation Options:
Option A: Calculate by District ID
- Stop at district level in the hierarchy
- Faster process with fewer API calls
- Suitable for general shipping calculations
- Less precise but adequate for most use cases
Option B: Calculate by Subdistrict ID
- Continue to the most detailed subdistrict level
- More precise location-based pricing
- Recommended for accurate shipping cost calculations
- Requires one additional API call to get subdistrict data
Use Cases:
- Form-based applications with cascading dropdowns
- Applications requiring structured location selection
- When you need to display complete location hierarchy
- Perfect for traditional web forms and mobile app forms
- Ideal when users prefer guided selection process through multiple steps
- Suitable for applications where location accuracy can be flexible (District vs Subdistrict level)
- Great for admin panels and backend management systems