### Example API Request with cURL Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/api-key This cURL command shows a practical example of making a GET request to the Komship Delivery API sandbox. It includes the necessary 'x-api-key' header for authentication. This request retrieves a list of available couriers. ```bash curl --request GET \ --url https://api-sandbox.collaborator.komerce.id \ --header 'x-api-key: YOUR_API_KEY' ``` -------------------------------- ### Search Destination by Keyword (GoLang) Source: https://rajaongkir.com/docs/delivery-order-api/search-destination This GoLang example demonstrates how to search for destinations using a keyword. It constructs the request URL, sets the necessary headers including the API key, and sends a GET request to the Search Destination Endpoint. ```go package main import ( "fmt" "io/ioutil" "net/http" "strings" ) func main() { apiKey := "yourapikey" keyword := "53131" url := fmt.Sprintf("https://api-sandbox.collaborator.komerce.id/tariff/api/v1/destination/search?keyword=%s", keyword) client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Add("x-api-key", apiKey) res, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Example API Request using cURL Source: https://rajaongkir.com/docs/payment-api/getting-started/authentication This example demonstrates how to make an authenticated API request using the cURL command-line tool. Replace YOUR_API_KEY with your actual API key. ```bash curl --location 'https://api-sandbox.collaborator.komerce.id/user/api/v1/user/methods' \ --header 'x-api-key: YOUR_API_KEY' ``` -------------------------------- ### Search Destination by Keyword (JavaScript) Source: https://rajaongkir.com/docs/delivery-order-api/search-destination This JavaScript example shows how to perform a search for destinations using a keyword. It utilizes the fetch API to make a GET request to the Search Destination Endpoint, including the API key and search keyword in the request. ```javascript const apiKey = 'yourapikey'; const keyword = '53131'; fetch(`https://api-sandbox.collaborator.komerce.id/tariff/api/v1/destination/search?keyword=${keyword}`, { method: 'GET', headers: { 'x-api-key': apiKey } }) .then(response => response.json()) .then(data => { console.log(data); }) .catch(error => { console.error('Error:', error); }); ``` -------------------------------- ### API Key Authentication Example (cURL) Source: https://rajaongkir.com/docs/payment-api/getting-started/available-endpoints This example demonstrates how to authenticate API requests using your API Key. The `x-api-key` header is required for both production and sandbox environments. Replace `YOUR_API_KEY` with your actual API key. ```bash # Production curl --location 'https://api.collaborator.komerce.id/user/api/v1/user/methods' \ --header 'x-api-key: YOUR_API_KEY' # Sandbox curl --location 'https://api-sandbox.collaborator.komerce.id/user/api/v1/user/methods' \ --header 'x-api-key: YOUR_API_KEY' ``` -------------------------------- ### Example Curl Request - Production Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/base-url A sample curl command to retrieve a list of available couriers using the production environment. Requires a valid production API key. ```bash curl --request GET \ --url https://api.collaborator.komerce.id/ \ --header 'x-api-key: YOUR_PRODUCTION_KEY' ``` -------------------------------- ### Example Curl Request - Sandbox Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/base-url A sample curl command to retrieve a list of available couriers using the sandbox environment. Requires a valid sandbox API key. ```bash curl --request GET \ --url https://api-sandbox.collaborator.komerce.id/ \ --header 'x-api-key: YOUR_SANDBOX_KEY' ``` -------------------------------- ### GET /api/v1/user/methods Source: https://rajaongkir.com/docs/payment-api/getting-started/flow-overview-page Retrieve a list of available payment methods, including banks for Virtual Accounts (e.g., BNI, BCA, Mandiri) and QRIS availability. This endpoint is useful for dynamically displaying supported payment options to customers. ```APIDOC ## GET /api/v1/user/methods ### Description Retrieve a list of available payment methods, including banks for Virtual Accounts and QRIS availability. ### Method GET ### Endpoint /api/v1/user/methods ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **methods** (object) - An object containing available payment methods. - **va_banks** (array) - List of available banks for Virtual Accounts. - **qris_available** (boolean) - Indicates if QRIS is available. #### Response Example ```json { "methods": { "va_banks": ["BNI", "BCA", "Mandiri"], "qris_available": true } } ``` ``` -------------------------------- ### Handle Webhook Notifications (Node.js) Source: https://rajaongkir.com/docs/delivery-order-api/webhook Node.js example using Express.js to handle Komerce webhook notifications. It demonstrates parsing JSON request bodies and sending a 200 OK response. ```javascript const express = require('express'); const app = express(); const port = 3000; // Middleware to parse JSON bodies app.use(express.json()); app.post('/webhook', (req, res) => { const eventData = req.body; console.log('Received webhook event:', eventData); // Process the event data (e.g., update database, notify users) // ... your processing logic here ... // Respond with 200 OK to acknowledge receipt res.sendStatus(200); }); app.listen(port, () => { console.log(`Webhook server listening at http://localhost:${port}`); }); // To run this: npm install express // Then: node your_file_name.js ``` -------------------------------- ### Handle Webhook Notifications (PHP) Source: https://rajaongkir.com/docs/delivery-order-api/webhook A PHP script example for handling Komerce webhook notifications. It demonstrates reading the raw POST data, decoding the JSON, and returning a 200 HTTP status code. ```php 'Invalid JSON received']); exit; } // Log or process the event data error_log('Received webhook event: ' . print_r($event_data, true)); // ... your processing logic here ... // Respond with 200 OK http_response_code(200); ?> // Note: Ensure your web server is configured to allow POST requests to this script. ``` -------------------------------- ### API Request Header Example Source: https://rajaongkir.com/docs/payment-api/getting-started/authentication This snippet shows the required headers for authenticating API requests to the Komerce Payment API. It includes the API key and content type. ```http x-api-key : YOUR_API_KEY Content-Type: application/json ``` -------------------------------- ### Handle Webhook Notifications (JavaScript) Source: https://rajaongkir.com/docs/delivery-order-api/webhook Example of a JavaScript server-side handler for receiving Komerce webhook notifications. It shows how to parse the incoming JSON payload and respond with a 200 OK status. ```javascript app.post('/webhook', (req, res) => { const eventData = req.body; console.log('Received webhook event:', eventData); // Process the event data (e.g., update database, notify users) // ... your processing logic here ... // Respond with 200 OK to acknowledge receipt res.sendStatus(200); }); // Note: This is a simplified example. You'll need to set up an Express.js server or similar framework. ``` -------------------------------- ### API Request Headers Example Source: https://rajaongkir.com/docs/payment-api/getting-started/endpoint This snippet shows the required headers for authenticating API requests. It includes the API key for authorization and specifies the content type as JSON. Ensure you replace 'YOUR_API_KEY' with your actual key. ```http -H "x-api-key: YOUR_API_KEY" -H "Content-Type: application/json" ``` -------------------------------- ### Search District by City ID (Node.js) Source: https://rajaongkir.com/docs/shipping-cost/endpoint-rajaongkir-for-form-base-calculate-cost/search_district This Node.js example uses the 'axios' library to make a GET request to the Search District endpoint. Ensure you have axios installed (`npm install axios`). ```javascript const axios = require('axios'); const cityId = '575'; const apiKey = 'YOUR_API_KEY'; const url = `https://rajaongkir.komerce.id/api/v1/destination/district/${cityId}`; axios.get(url, { headers: { 'Key': apiKey } }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error:', error); }); ``` -------------------------------- ### Example cURL Request with API Key Source: https://rajaongkir.com/docs/shipping-cost/getting_started/apikey An example using cURL to make a GET request to the RajaOngkir API, including the API key in the request header for authentication. This is useful for testing API access. ```bash curl --request GET \ --url https://rajaongkir.komerce.id/api/v1 \ --header 'key: YOUR_API_KEY' ``` -------------------------------- ### Search International Destination (GoLang) Source: https://rajaongkir.com/docs/shipping-cost/endpoint-rajaongkir-for-search-base/search-international-destination A GoLang example for searching international destinations. It demonstrates making an HTTP GET request with the required API key and search parameters. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" ) func searchInternationalDestination(apiKey, searchTerm string) (map[string]interface{}, error) { baseURL := "https://rajaongkir.komerce.id/api/v1/destination/international-destination" params := url.Values{} params.Add("search", searchTerm) params.Add("limit", "99") params.Add("offset", "99") requestURL := fmt.Sprintf("%s?%s", baseURL, params.Encode()) client := &http.Client{} req, err := http.NewRequest("GET", requestURL, nil) if err != nil { return nil, fmt.Errorf("failed to create request: %w", err) } req.Header.Set("key", apiKey) res, err := client.Do(req) if err != nil { return nil, fmt.Errorf("failed to execute request: %w", err) } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } var result map[string]interface{} if err := json.Unmarshal(body, &result); err != nil { return nil, fmt.Errorf("failed to unmarshal response: %w", err) } return result, nil } // Example usage: // func main() { // apiKey := "YOUR_API_KEY" // searchTerm := "japan" // data, err := searchInternationalDestination(apiKey, searchTerm) // if err != nil { // fmt.Println("Error:", err) // return // } // fmt.Printf("%+v\n", data) // } ``` -------------------------------- ### Search City by Province ID (GoLang) Source: https://rajaongkir.com/docs/shipping-cost/endpoint-rajaongkir-for-form-base-calculate-cost/search_city This GoLang example demonstrates how to make an HTTP GET request to the Search City endpoint. It includes the API key and province ID in the request headers and URL. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) func searchCities(provinceID string, apiKey string) (map[string]interface{}, error) { url := fmt.Sprintf("https://rajaongkir.komerce.id/api/v1/destination/city/%s", provinceID) client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, fmt.Errorf("failed to create request: %w", err) } req.Header.Set("Key", apiKey) resp, err := client.Do(req) if err != nil { return nil, fmt.Errorf("failed to execute request: %w", err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } var result map[string]interface{} if err := json.Unmarshal(body, &result); err != nil { return nil, fmt.Errorf("failed to unmarshal JSON: %w", err) } return result, nil } // Example usage: // func main() { // apiKey := "YOUR_API_KEY" // provinceID := "12" // data, err := searchCities(provinceID, apiKey) // if err != nil { // fmt.Println("Error:", err) // return // } // fmt.Printf("%+v\n", data) // } ``` -------------------------------- ### Search City by Province ID (JavaScript) Source: https://rajaongkir.com/docs/shipping-cost/endpoint-rajaongkir-for-form-base-calculate-cost/search_city This JavaScript example shows how to make a GET request to the Search City endpoint using the fetch API. It includes the necessary API key and province ID in the URL. ```javascript async function searchCities(provinceId, apiKey) { const url = `https://rajaongkir.komerce.id/api/v1/destination/city/${provinceId}`; try { const response = await fetch(url, { method: 'GET', headers: { 'Key': apiKey } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { console.error('Error fetching cities:', error); return null; } } // Example usage: // searchCities(12, 'YOUR_API_KEY').then(data => console.log(data)); ``` -------------------------------- ### Calculate Domestic Shipping Cost by District (Node.js) Source: https://rajaongkir.com/docs/shipping-cost/endpoint-rajaongkir-for-form-base-calculate-cost/calculate-cost This Node.js example shows how to calculate domestic shipping costs using the RajaOngkir API. It uses the `axios` library to send a POST request with the necessary form data, including origin, destination, weight, and courier information. Ensure you replace 'YOUR_API_KEY' with your valid API key and install axios (`npm install axios`). ```javascript const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const originDistrictId = '1391'; const destinationDistrictId = '1376'; const weight = '1000'; // in grams const couriers = 'jne:sicepat:ide:sap:jnt:ninja:tiki:lion:anteraja:pos:ncs:rex:rpx:sentral:star:wahana:dse'; const url = 'https://rajaongkir.komerce.id/api/v1/calculate/district/domestic-cost'; const data = new URLSearchParams({ 'origin': originDistrictId, 'destination': destinationDistrictId, 'weight': weight, 'courier': couriers, 'price': 'lowest' }); axios.post(url, data, { headers: { 'key': apiKey, 'Content-Type': 'application/x-www-form-urlencoded' } }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error:', error.response ? error.response.data : error.message); }); ``` -------------------------------- ### Search City by Province ID (Node.js) Source: https://rajaongkir.com/docs/shipping-cost/endpoint-rajaongkir-for-form-base-calculate-cost/search_city This Node.js example utilizes the 'node-fetch' library to make a GET request to the Search City endpoint. It demonstrates how to include the API key and province ID for retrieving city data. ```javascript const fetch = require('node-fetch'); async function searchCities(provinceId, apiKey) { const url = `https://rajaongkir.komerce.id/api/v1/destination/city/${provinceId}`; try { const response = await fetch(url, { method: 'GET', headers: { 'Key': apiKey } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { console.error('Error fetching cities:', error); return null; } } // Example usage: // searchCities(12, 'YOUR_API_KEY').then(data => console.log(data)); ``` -------------------------------- ### Sandbox vs. Production Keys Source: https://rajaongkir.com/docs/payment-api/getting-started/authentication Information on the different base URLs and key prefixes for sandbox and production environments. ```APIDOC ## Sandbox vs. Production Keys ### Description Komerce provides separate environments for testing (sandbox) and live transactions (production). It is recommended to use distinct API keys for each environment to prevent data mix-ups. ### Environments | Environment | Base URL | Key Prefix | Description | |---------------|-------------------------------------------|------------|-------------------------------------------------------------------------------| | Sandbox | `https://api-sandbox.collaborator.komerce.id/user` | `sandbox` | Used for testing transactions. Payments are simulated and not processed by banks. | | Production | `https://api.collaborator.komerce.id/user` | `live` | Used for live payments in real transactions. | ``` -------------------------------- ### Retrieve Order Details using GoLang Source: https://rajaongkir.com/docs/delivery-order-api/detail_order This GoLang code snippet demonstrates how to fetch order details from the API. It constructs the URL with the order number and sets the 'x-api-key' header. The response is then unmarshaled into a Go struct for easy access to the order information. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" ) type OrderDetails struct { // Define your struct fields based on the API response // Example: OrderID string `json:"order_id"` Status string `json:"status"` ShippingInfo struct { Courier string `json:"courier"` Cost float64 `json:"cost"` } } func getOrderDetail(orderId string, apiKey string) (*OrderDetails, error) { params := url.Values{} params.Add("order_no", orderId) url := fmt.Sprintf("https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/detail?%s", params.Encode()) req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, fmt.Errorf("failed to create request: %w", err) } req.Header.Set("x-api-key", apiKey) client := &http.Client{} res, err := client.Do(req) if err != nil { return nil, fmt.Errorf("failed to execute request: %w", err) } defer res.Body.Close() if res.StatusCode != http.StatusOK { bodyBytes, _ := ioutil.ReadAll(res.Body) return nil, fmt.Errorf("unexpected status code: %d, body: %s", res.StatusCode, string(bodyBytes)) } body, err := ioutil.ReadAll(res.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } var orderDetails OrderDetails err = json.Unmarshal(body, &orderDetails) if err != nil { return nil, fmt.Errorf("failed to unmarshal response: %w", err) } return &orderDetails, nil } // Example usage: // func main() { // orderId := "KOMXXXXXXXXXXXXXXXXX" // apiKey := "inputapikey" // // orderDetails, err := getOrderDetail(orderId, apiKey) // if err != nil { // fmt.Println("Error:", err) // return // } // // fmt.Printf("Order Details: %+v\n", orderDetails) // } ``` -------------------------------- ### Payment Flow Overview Source: https://rajaongkir.com/docs/payment-api/getting-started/flow-overview-page This section outlines the standard payment flow using the Komerce Payment API, from fetching available methods to checking payment status. ```APIDOC ## Payment Flow Overview This section outlines the standard payment flow using the Komerce Payment API. 1. **Fetch Available Payment Methods**: Retrieve a list of available payment options (Virtual Accounts and QRIS). 2. **Create Payment Transaction**: Initiate a payment request to generate a Virtual Account number or QRIS QR code. 3. **Customer Payment Process**: The customer completes the payment via their selected channel. 4. **Check Payment Status**: Retrieve the current transaction status and related payment details. ``` -------------------------------- ### POST /api/v1/user/payment/create Source: https://rajaongkir.com/docs/payment-api/getting-started/flow-overview-page Create a payment transaction, generating either a Virtual Account number or a QRIS QR code. This endpoint registers the transaction in the Komerce system. ```APIDOC ## POST /api/v1/user/payment/create ### Description Create a payment transaction via Virtual Account or QRIS. ### Method POST ### Endpoint /api/v1/user/payment/create ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **payment_type** (string) - Required - The type of payment ('VA' or 'QRIS'). - **amount** (number) - Required - The transaction amount. - **customer_details** (object) - Optional - Details about the customer. - **email** (string) - Customer's email. - **phone** (string) - Customer's phone number. - **name** (string) - Customer's name. ### Request Example ```json { "payment_type": "VA", "amount": 100000, "customer_details": { "email": "customer@example.com", "phone": "081234567890", "name": "John Doe" } } ``` ### Response #### Success Response (200) - **transaction_id** (string) - The unique identifier for the transaction. - **payment_details** (object) - Details specific to the payment type. - **va_number** (string) - The Virtual Account number (if payment_type is 'VA'). - **qr_string** (string) - The QRIS QR code string (if payment_type is 'QRIS'). - **status** (string) - The initial status of the transaction (e.g., 'PENDING'). #### Response Example ```json { "transaction_id": "txn_12345abcde", "payment_details": { "va_number": "9876543210", "qr_string": null }, "status": "PENDING" } ``` ``` -------------------------------- ### GET /order/api/v1/orders/detail Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/base-url Retrieves detailed information about a submitted order. ```APIDOC ## GET /order/api/v1/orders/detail ### Description This endpoint provides comprehensive details about a specific order, including its current status, tracking information, and shipment details. ### Method GET ### Endpoint `/order/api/v1/orders/detail` ### Parameters #### Query Parameters - **order_id** (string) - Required - The ID of the order to retrieve details for. ### Request Example ```bash curl --request GET \ --url https://api.collaborator.komerce.id/order/api/v1/orders/detail?order_id=ORD123456789 \ --header 'x-api-key: YOUR_API_KEY' ``` ### Response #### Success Response (200) - **order_details** (object) - An object containing all details of the order. - **order_id** (string) - The order ID. - **tracking_number** (string) - The tracking number. - **status** (string) - The current status of the order. - **shipment_details** (object) - Details about the shipment. #### Response Example ```json { "order_details": { "order_id": "ORD123456789", "tracking_number": "JN123456789", "status": "Shipped", "shipment_details": { "origin": "Jakarta", "destination": "Surabaya", "courier": "JNE" } } } ``` ``` -------------------------------- ### Environment Details Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/base-url Information on how to access the Komerce API through production and sandbox environments. ```APIDOC ## Environments ### Production Environment **Base URL:** `https://api.collaborator.komerce.id/` Use this URL for live operations. Requires a valid production API key. ### Sandbox Environment **Base URL:** `https://api-sandbox.collaborator.komerce.id/` Use this URL for testing purposes. Requires a valid sandbox API key. ## Switching Between Environments To switch environments, simply change the base URL in your requests. Always use the correct API key for the environment you are targeting. ``` -------------------------------- ### Cancel Order Request (JavaScript, PHP, GoLang, Node.js) Source: https://rajaongkir.com/docs/delivery-order-api/cancel_order Examples for canceling an order using JavaScript, PHP, GoLang, and Node.js. These snippets show how to construct the API request, including setting headers and the request body with the order number. Ensure you replace placeholders with your actual API key and order number. ```JavaScript const apiKey = 'inputapikey'; const orderNumber = 'KOMXXXXXXXXXXXXXXXXX'; fetch('https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/cancel', { method: 'PUT', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'x-api-key': apiKey }, body: JSON.stringify({ order_no: orderNumber }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```PHP $apiKey = 'inputapikey'; $orderNumber = 'KOMXXXXXXXXXXXXXXXXX'; $url = 'https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/cancel'; $data = json_encode(['order_no' => $orderNumber]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json', 'x-api-key: ' . $apiKey ]); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $response; } costl_close($ch); ``` ```GoLang package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { apiKey := "inputapikey" orderNumber := "KOMXXXXXXXXXXXXXXXXX" url := "https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/cancel" requestBody, err := json.Marshal(map[string]string{ "order_no": orderNumber, }) if err != nil { fmt.Println("Error marshaling JSON:", err) return } req, err := http.NewRequest("PUT", url, bytes.NewBuffer(requestBody)) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("Accept", "application/json") req.Header.Set("x-api-key", apiKey) client := &http.Client{} res, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println("Status Code:", res.StatusCode) fmt.Println("Response Body:", string(body)) } ``` ```Node.js const fetch = require('node-fetch'); const apiKey = 'inputapikey'; const orderNumber = 'KOMXXXXXXXXXXXXXXXXX'; async function cancelOrder() { try { const response = await fetch('https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/cancel', { method: 'PUT', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'x-api-key': apiKey }, body: JSON.stringify({ order_no: orderNumber }) }); const data = await response.json(); console.log(data); } catch (error) { console.error('Error:', error); } } cancelOrder(); ``` -------------------------------- ### GET /order/api/v1/orders/history-airway-bill Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/base-url Checks the tracking history of an airway bill (AWB). ```APIDOC ## GET /order/api/v1/orders/history-airway-bill ### Description This endpoint allows you to retrieve the tracking history and current status of a shipment using its airway bill (AWB) number. ### Method GET ### Endpoint `/order/api/v1/orders/history-airway-bill` ### Parameters #### Query Parameters - **tracking_number** (string) - Required - The airway bill (tracking) number of the shipment. ### Request Example ```bash curl --request GET \ --url https://api.collaborator.komerce.id/order/api/v1/orders/history-airway-bill?tracking_number=JN123456789 \ --header 'x-api-key: YOUR_API_KEY' ``` ### Response #### Success Response (200) - **tracking_history** (array) - A list of tracking events. - **timestamp** (string) - The date and time of the tracking event. - **location** (string) - The location where the event occurred. - **description** (string) - A description of the tracking event. #### Response Example ```json { "tracking_history": [ { "timestamp": "2023-10-27 10:00:00", "location": "Jakarta", "description": "Package received by courier" }, { "timestamp": "2023-10-27 15:30:00", "location": "Transit Hub", "description": "Package in transit" } ] } ``` ``` -------------------------------- ### Create Order Request Body (cURL, JavaScript, PHP, GoLang) Source: https://rajaongkir.com/docs/delivery-order-api/Store_order/store_order This snippet demonstrates how to construct and send a request to the Store Order Endpoint. It includes the required JSON payload with order, shipping, payment, and product details. Ensure the 'x-api-key' header is correctly set. ```curl curl --location 'https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/store' \ --header 'x-api-key: inputapikey' \ --header 'Content-Type: application/json' \ --data-raw '{ "order_date": "2025-05-21", "brand_name": "Xiaomi Official", "shipper_name": "XIAOMI", "shipper_phone": "82121669737", "shipper_destination_id": 5969, "shipper_address": "Alamat pengirim", "origin_pin_point": "-7.274631, 109.207174", "receiver_name": "Buyer Bandung", "receiver_phone": "8123458282", "receiver_destination_id": 4956, "receiver_address": "Alamat penerima", "shipper_email": "admin@admin.com", "destination_pin_point": "-7.274631, 109.207174", "shipping": "JNE", "shipping_type": "REG23", "payment_method": "BANK TRANSFER", "shipping_cost": 16000, "shipping_cashback": 4000, "service_fee": 0, "additional_cost": 0, "grand_total": 516000, "cod_value": 0, "insurance_value": 5631.11, "order_details": [ { "product_name": "Xiaomi Redmi Note 99", "product_variant_name": "Blue 8/256", "product_price": 315555, "product_weight": 1000, "product_width": 10, "product_height": 8, "product_length": 50, "qty": 1, "subtotal": 315555 } ] }' ``` ```javascript const url = 'https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/store'; const apiKey = 'inputapikey'; const orderData = { "order_date": "2025-05-21", "brand_name": "Xiaomi Official", "shipper_name": "XIAOMI", "shipper_phone": "82121669737", "shipper_destination_id": 5969, "shipper_address": "Alamat pengirim", "origin_pin_point": "-7.274631, 109.207174", "receiver_name": "Buyer Bandung", "receiver_phone": "8123458282", "receiver_destination_id": 4956, "receiver_address": "Alamat penerima", "shipper_email": "admin@admin.com", "destination_pin_point": "-7.274631, 109.207174", "shipping": "JNE", "shipping_type": "REG23", "payment_method": "BANK TRANSFER", "shipping_cost": 16000, "shipping_cashback": 4000, "service_fee": 0, "additional_cost": 0, "grand_total": 516000, "cod_value": 0, "insurance_value": 5631.11, "order_details": [ { "product_name": "Xiaomi Redmi Note 99", "product_variant_name": "Blue 8/256", "product_price": 315555, "product_weight": 1000, "product_width": 10, "product_height": 8, "product_length": 50, "qty": 1, "subtotal": 315555 } ] }; fetch(url, { method: 'POST', headers: { 'x-api-key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(orderData) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```php "2025-05-21", "brand_name" => "Xiaomi Official", "shipper_name" => "XIAOMI", "shipper_phone" => "82121669737", "shipper_destination_id" => 5969, "shipper_address" => "Alamat pengirim", "origin_pin_point" => "-7.274631, 109.207174", "receiver_name" => "Buyer Bandung", "receiver_phone" => "8123458282", "receiver_destination_id" => 4956, "receiver_address" => "Alamat penerima", "shipper_email" => "admin@admin.com", "destination_pin_point" => "-7.274631, 109.207174", "shipping" => "JNE", "shipping_type" => "REG23", "payment_method" => "BANK TRANSFER", "shipping_cost" => 16000, "shipping_cashback" => 4000, "service_fee" => 0, "additional_cost" => 0, "grand_total" => 516000, "cod_value" => 0, "insurance_value" => 5631.11, "order_details" => [ [ "product_name" => "Xiaomi Redmi Note 99", "product_variant_name" => "Blue 8/256", "product_price" => 315555, "product_weight" => 1000, "product_width" => 10, "product_height" => 8, "product_length" => 50, "qty" => 1, "subtotal" => 315555 ] ] ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($orderData)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'x-api-key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $response; } cert_close($ch); ?> ``` ```go package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { url := "https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/store" apiKey := "inputapikey" orderData := map[string]interface{}{ "order_date": "2025-05-21", "brand_name": "Xiaomi Official", "shipper_name": "XIAOMI", "shipper_phone": "82121669737", "shipper_destination_id": 5969, "shipper_address": "Alamat pengirim", "origin_pin_point": "-7.274631, 109.207174", "receiver_name": "Buyer Bandung", "receiver_phone": "8123458282", "receiver_destination_id": 4956, "receiver_address": "Alamat penerima", "shipper_email": "admin@admin.com", "destination_pin_point": "-7.274631, 109.207174", "shipping": "JNE", "shipping_type": "REG23", "payment_method": "BANK TRANSFER", "shipping_cost": 16000, "shipping_cashback": 4000, "service_fee": 0, "additional_cost": 0, "grand_total": 516000, "cod_value": 0, "insurance_value": 5631.11, "order_details": [] } orderData["order_details"] = []interface{}{ map[string]interface{}{ "product_name": "Xiaomi Redmi Note 99", "product_variant_name": "Blue 8/256", "product_price": 315555, "product_weight": 1000, "product_width": 10, "product_height": 8, "product_length": 50, "qty": 1, "subtotal": 315555 } } jsonData, err := json.Marshal(orderData) if err != nil { fmt.Println("Error marshalling JSON:", err) return } req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Set("x-api-key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} res, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### GET /tariff/api/v1/calculate Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/base-url Calculates estimated shipping costs based on origin and destination. ```APIDOC ## GET /tariff/api/v1/calculate ### Description This endpoint calculates the estimated shipping cost between a specified origin and destination, considering various courier options. ### Method GET ### Endpoint `/tariff/api/v1/calculate` ### Parameters #### Query Parameters - **origin** (string) - Required - The origin ID. - **destination** (string) - Required - The destination ID. - **courier** (string) - Required - The courier code (e.g., 'jne', 'pos', 'tiki'). - **weight** (integer) - Required - The total weight of the shipment in grams. - **dimension** (string) - Optional - Dimensions of the package in 'LxWxH' format (e.g., '10x10x10'). ### Request Example ```bash curl --request GET \ --url "https://api.collaborator.komerce.id/tariff/api/v1/calculate?origin=123&destination=456&courier=jne&weight=1000&dimension=20x10x5" \ --header 'x-api-key: YOUR_API_KEY' ``` ### Response #### Success Response (200) - **results** (array) - A list of shipping options with their costs. - **courier_name** (string) - The name of the courier. - **service_name** (string) - The name of the shipping service. - **cost** (integer) - The shipping cost. - **estimated_delivery_time** (string) - Estimated delivery time. #### Response Example ```json { "results": [ { "courier_name": "JNE", "service_name": "OKE", "cost": 15000, "estimated_delivery_time": "3-5 days" } ] } ``` ``` -------------------------------- ### GET /tariff/api/v1/destination/ Source: https://rajaongkir.com/docs/delivery-order-api/getting_started/base-url Searches for origin or destination IDs required for tariff calculations. ```APIDOC ## GET /tariff/api/v1/destination/ ### Description This endpoint is used to search for origin or destination IDs. These IDs are necessary for subsequent tariff and shipping cost calculations. ### Method GET ### Endpoint `/tariff/api/v1/destination/` ### Parameters #### Query Parameters - **type** (string) - Required - Specifies whether to search for 'origin' or 'destination'. - **name** (string) - Optional - The name to search for. ### Request Example ```bash curl --request GET \ --url https://api.collaborator.komerce.id/tariff/api/v1/destination/?type=origin&name=jakarta \ --header 'x-api-key: YOUR_API_KEY' ``` ### Response #### Success Response (200) - **data** (array) - A list of matching locations with their IDs. - **id** (string) - The unique identifier for the location. - **name** (string) - The name of the location. #### Response Example ```json { "data": [ { "id": "123", "name": "Jakarta" } ] } ``` ``` -------------------------------- ### Search Destination by Keyword (PHP) Source: https://rajaongkir.com/docs/delivery-order-api/search-destination This PHP code snippet illustrates how to search for destinations using a keyword. It makes a GET request to the Search Destination Endpoint, passing the API key and keyword as headers and query parameters respectively. ```php ``` -------------------------------- ### Authorization Source: https://rajaongkir.com/docs/payment-api/getting-started/endpoint Explains how to authenticate requests using an API Key, including example headers and security recommendations. ```APIDOC ## Authorization Every request to the Payment API must include an **API Key** for authentication. You can find your API Key in the **Merchant Dashboard** after registration. **Example Header:** ``` -H "x-api-key: YOUR_API_KEY" -H "Content-Type: application/json" ``` > ⚠️ Never expose your API key in client-side code or public repositories. ```