### Create Quotation Payload Example Source: https://developers.lalamove.com/ Example of building a quotation payload using the SDK client, including pickup and dropoff details, service type, and language. ```javascript const pickupCo = { lat: "22.33547351186244", lng: "114.17615807116502", }; const dropoffCo = { lat: "22.28129462633954", lng: "114.15986100706951", }; const pickup = { coordinates: pickupCo, address: "Innocentre, 72 Tat Chee Ave, Kowloon Tong", }; const dropoff = { coordinates: dropoffCo, address: "Statue Square, Des Voeux Rd Central, Central", }; const quotationPayload = SDKClient.QuotationPayloadBuilder.quotationPayload() .withLanguage("en_HK") .withServiceType("COURIER") .withStops([stop1, stop2]) .build(); const quotation = await sdkClient.Quotation.create("HK", quotationPayload); ``` -------------------------------- ### Quotation Response Example Source: https://developers.lalamove.com/ This is an example of a successful response when retrieving quotation details. It includes information about the schedule, service type, stops, pricing, and item details. ```json { "data": { "quotationId": "1514140994227007571", "scheduleAt": "2022-04-13T07:18:38.00Z", "expiresAt": "2022-04-13T07:23:39.00Z", "serviceType": "MOTORCYCLE", "specialRequests": [ "TOLL_FEE_10", "PURCHASE_SERVICE_1" ], "language": "EN_HK", "stops": [ { "stopId": "1514140995971838016", "coordinates": { "lat": "22.3354735", "lng": "114.1761581" }, "address": "Innocentre, 72 Tat Chee Ave, Kowloon Tong" }, { "stopId": "1514140995971838017", "coordinates": { "lat": "22.2812946", "lng": "114.1598610" }, "address": "Statue Square, Des Voeux Rd Central, Central" } ], "isRouteOptimized": false, "priceBreakdown": { "base": "90", "specialRequests": "13", "vat": "21", "totalBeforeOptimization": "124", "totalExcludePriorityFee": "124", "total": "124", "currency": "HKD" }, "item": { "weight": "LESS_THAN_3_KG", "categories": [ "OFFICE_ITEM", "OTHERS" ] } } ``` -------------------------------- ### Webhook Setup Source: https://developers.lalamove.com/ Set up a webhook to automatically receive order status updates. Provide your webhook URL in the request body. ```APIDOC ## Webhook ### Description Automatically receive your order status updates using our webhook. ### Method PATCH ### Endpoint Sandbox: https://rest.sandbox.lalamove.com/v3/webhook Production: https://rest.lalamove.com/v3/webhook ### Request Body ```json { "data": { "url": "YOUR_WEBHOOK_URL" } } ``` ### Response #### Success Response (200) ```json { "data": { "url": "YOUR_WEBHOOK_URL" } } ``` ``` -------------------------------- ### Order Types: Immediate vs Scheduled Source: https://developers.lalamove.com/ Explains the difference between immediate and scheduled orders, including their respective request body examples. ```APIDOC ## Immediate vs Scheduled > Quotation for Immediate Order ```json { "data": { "serviceType": "MOTORCYCLE", "specialRequests": ["COD", "HELP_BUY", "LALABAG"], "language": "en_HK", "stops": [], "isRouteOptimized": true } } ``` > Quotation for Scheduled Order ```json { "data": { "scheduleAt": "2020-09-01T14:30:00.00Z", "serviceType": "MOTORCYCLE", "specialRequests": ["COD", "HELP_BUY", "LALABAG"], "language": "en_HK", "stops": [], "isRouteOptimized": true } } ``` Depending on your delivery needs, you can place an immediate order or a schedule order. * **Immediate order** (`scheduleAt` was skipped at the time when placing the order.) Driver will go to the pick-up point once he accepts the order. * **Scheduled order** (`scheduleAt` was specified at the time, up to **30 days** in advance, when placing the order.) Driver will arrive at the pick-up point by the time specified in `scheduleAt`. ``` -------------------------------- ### Initialize Lalamove JavaScript SDK Client Source: https://developers.lalamove.com/ Instantiate the Lalamove JavaScript SDK client with your API credentials and environment. Ensure you have the SDK installed. ```javascript const SDKClient = require("@lalamove/lalamove-js"); const sdkClient = new SDKClient.ClientModule( new SDKClient.Config( "public_key", "secret_key", "sandbox" ) ); ``` -------------------------------- ### Retrieve Driver Information Source: https://developers.lalamove.com/ Use this endpoint to get driver details for a specific order. Information is available starting 1 hour before the scheduled time or upon driver arrival, whichever is earlier, and remains accessible until the order is completed. Requests outside this window will result in a 403 Forbidden response. ```http GET /v3/orders/{orderId}/drivers/{driverId} ``` -------------------------------- ### API Headers and Authorization Source: https://developers.lalamove.com/ This section explains the required headers for API requests, including Authorization, Market, and Request-ID, with examples. ```APIDOC ## Headers > Example in JavaScript **(cont.)** ```javascript const API_KEY = 'pk_test_Lalamove' const TOKEN = `${API_KEY}:${time}:${SIGNATURE}` ``` > ``` Authorization: hmac Market: Request-ID: ``` > Example ``` Authorization: hmac 914c9e52e6414d9494e299708d176a41:1545880607433:5133946c6a0ba25932cc18fa3aa1b5c3dfa2c7f99de0f8599b28c2da88ed9d42 Market: TH Request-ID: 211b9d85-a2cc-476f-8675-b61ec923cc27 ``` ### Authorization `TOKEN = ::` | ---|--- `KEY` | Your API key `TIMESTAMP` | **MUST** be identical to `TIMESTAMP` in `SIGNATURE` `SIGNATURE` | As described in Signature in **lowercase hex (base 16)** ### Market Please specify the market you are placing orders in UN/LOCODE format. For example, Indonesia will be listed as `ID`. See Available Markets for details. ### Request-ID Provide a Nonce to be used as a unique Request ID. If you are having trouble with any request, sharing the Request ID with us will be the fastest way. ``` -------------------------------- ### Order Created Response Source: https://developers.lalamove.com/ Example of a successful order creation response, including order ID, pricing, driver information, and delivery stops. ```json { "data": { "orderId": "107900701184", "quotationId": "1471722666401517645", "priceBreakdown": { "base": "100", "extraMileage": "10", "surcharge": "20", "...": "", "totalExcludePriorityFee": "130", "total": "150", "currency": "THB", "priorityFee":"20" }, "driverId": "33522", "shareLink": "https://share.lalamove.com/?TH1234556&lang=th_TH&version=2", "status": "COMPLETED", "distance": { "value": "16200", "unit": "m" }, "stops": [ { "coordinates": { "lat": "22.3353139", "lng": "114.1758402" }, "address": "Jl. Perum Dasana", "name": "dodo", "phone": "+660923447537" }, { "stopId": "1231231231", "coordinates": { "lat": "22.3203648", "lng": "114.169773" }, "address": "Jl. Kartini, Ruko No. 1E", "name": "dodo", "phone": "+660923447537", "POD": { "status": "DELIVERED", "image": "POD_IMAGE_URL", "deliveredAt": "2022-01-20T06:26:39.721Z" } } ], "metadata": { "restaurantOrderId": "1234", "restaurantName": "Rustam's Kebab" } } } ``` -------------------------------- ### Setup Webhook URL Source: https://developers.lalamove.com/ Call this endpoint to set up your webhook URL. Ensure your Webhook URL responds with a 200 status code to Lalamove's requests. ```APIDOC ## PATCH /v3/webhook ### Description Sets up the webhook URL for receiving event notifications from Lalamove. ### Method PATCH ### Endpoint /v3/webhook ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **url** (URL) - Required - The URL for Lalamove to send Webhook responses. ### Request Example { "url": "https://your-webhook-url.com/callback" } ### Response #### Success Response (200) Indicates the webhook URL was successfully updated. #### Response Example (No specific example provided in source, but a 200 OK status is expected) #### Error Response (422) - **errors** (object) - Contains error details. - **id** (string) - Error identifier. - **message** (string) - Error message. - **detail** (string) - Specific validation failure details. ``` -------------------------------- ### Get City Info Source: https://developers.lalamove.com/ Retrieves information about supported cities for Lalamove services. ```APIDOC ## GET /v3/cities ### Description Retrieves information about supported cities for Lalamove services. ### Method GET ### Endpoint - Sandbox: https://rest.sandbox.lalamove.com/v3/cities - Production: https://rest.lalamove.com/v3/cities ``` -------------------------------- ### Create Order with SDK Source: https://developers.lalamove.com/ Use the SDK to construct and create an order. This example demonstrates setting up sender and recipient details, enabling Proof of Delivery, and adding metadata. The quotation ID is essential for creating the order. ```javascript const orderPayload = SDKClient.OrderPayloadBuilder.orderPayload() .withIsPODEnabled(true) .withQuotationID(quotation.id) .withSender({ stopId: quotation.stops[0].stopId, name: "Michal", phone: "+85256847123", }) .withRecipients([ { stopId: quotation.stops[1].stopId, name: "Rustam", phone: "+85256847456", }, ]), .withMetadata ( { "restaurantOrderId": "1234", "restaurantName": "Rustam's Kebab", } ) .build(); const order = await sdKClient.Order.create("HK", orderPayload); ``` -------------------------------- ### Example Authorization Header Source: https://developers.lalamove.com/ Demonstrates the format of the Authorization header, including the HMAC token, Market, and Request-ID. The token uses the format KEY:TIMESTAMP:SIGNATURE. ```http Authorization: hmac 914c9e52e6414d9494e299708d176a41:1545880607433:5133946c6a0ba25932cc18fa3aa1b5c3dfa2c7f99de0f8599b28c2da88ed9d42 Market: TH Request-ID: 211b9d85-a2cc-476f-8675-b61ec923cc27 ``` -------------------------------- ### Place Order cURL Request Source: https://developers.lalamove.com/ Example cURL command for placing an order. Ensure you include the correct Content-Type, Authorization, MARKET, and Request-ID headers, along with the JSON data payload. ```bash cURL --location --request POST 'https://rest.sandbox.lalamove.com/v3/orders' \ -H 'Content-Type: application/json' \ -H 'Authorization: hmac {API_KEY}:{timestamp}:{Signature}' \ -H 'MARKET: HK' \ -H 'Request-ID: cd8c5259-5719-4efc-8431-eecf02a66238' \ --data-raw '{"data"...}' ``` -------------------------------- ### Get Quotation API Endpoints Source: https://developers.lalamove.com/ Provides the sandbox and production URLs for the Lalamove Quotations API. ```text POST Sandbox: https://rest.sandbox.lalamove.com/v3/quotations Production: https://rest.lalamove.com/v3/quotations ``` -------------------------------- ### Get City Info Test Script (JavaScript) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Parses the JSON response. ```javascript let response = pm.response.json(); ``` -------------------------------- ### Get City Info Prerequest Script (JavaScript) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Generates an HMAC signature for fetching city information. Requires 'secret' to be set. ```javascript let time = new Date().getTime(); let signature = CryptoJS.HmacSHA256(`${time.toString()}\r\nGET\r\n/v3/cities\r\n\r\n`, environment['secret']); postman.setEnvironmentVariable('signature', signature.toString()); postman.setEnvironmentVariable('time', time); ``` -------------------------------- ### Order Creation Request Body Example Source: https://developers.lalamove.com/ This JSON represents the data payload for creating an order. It includes quotation ID, sender and recipient information, POD status, partner details, and optional metadata. ```json { "data": { "quotationId": "1471722666401517645", "sender": { "stopId": "112345623", "name": "Michal", "phone": "11955555555" }, "recipients": [ { "stopId": "112345678", "name": "Karen", "phone": "+660923447537", "remarks": "YYYYYY" // optional } ], "isPODEnabled": true, // optional "partner": "Lalamove Partner 1", // optional "metadata": { "restaurantOrderId": "1234", "restaurantName": "Rustam's Kebab" } } } ``` -------------------------------- ### Get Quotation Details Test Script (JavaScript) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Parses the JSON response and optionally sets the 'driverID' environment variable. ```javascript let response = pm.response.json(); //pm.environment.set("driverID", response.driverId); ``` -------------------------------- ### Get Order Details Source: https://developers.lalamove.com/ Retrieves the details of a specific order using its ID. ```APIDOC ## GET /v3/orders/{id} ### Description Retrieves the details of a specific order using its ID. ### Method GET ### Endpoint - Sandbox: https://rest.sandbox.lalamove.com/v3/orders/{id} - Production: https://rest.lalamove.com/v3/orders/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the order to retrieve. ``` -------------------------------- ### Get City and Service Configurations Source: https://developers.lalamove.com/ Use this endpoint to retrieve supported configurations for cities in a specified market. Adjust the 'Market' header to query different markets. The response includes city details, available services, and special request options for each service. ```json { "data": [ { "locode": "TH BKK", "name": "Bangkok", "services": [ { "key": "CAR", "description": "Ideal for small to medium goods requiring extra care", "dimensions": { "length": { "value": "0.9", "unit": "m" }, "width": { "value": "1", "unit": "m" }, "height": { "value": "0.7", "unit": "m" } }, "load": { "value": "100", "unit": "kg" }, "specialRequests": [ { "name": "EXTRA_LENGTH_2", "description": "Extra Length of 2.5 M (standard 1.8 M)", "parent_type": "Extra Length", "max_selection": 1, "effective_time": "2023-10-20T06:26:39.721Z", "offline_time": "" }, { "name": "EXTRA_LENGTH_1", "description": "Extra Length of 2.1 M (standard 1.8 M)", "parent_type": "Extra Length", "max_selection": 1, "effective_time": "2023-10-20T06:26:39.721Z", "offline_time": "" }, { "name": "DOOR_TO_DOOR", "description": "Door to Door by Driver", "max_selection": 1, "effective_time": "", "offline_time": "2023-10-20T06:26:39.721Z" }, }, { "name": "ROUND_TRIP", "description": "Round Trip", "max_selection": 1, "effective_time": "", "offline_time": "" } ] } ] } } ``` -------------------------------- ### Webhook Setup for Order Status Updates Source: https://developers.lalamove.com/ Configure a webhook to receive real-time order status updates. Provide your webhook URL in the request body. The response confirms the successful registration of your URL. ```http PATCH Sandbox: https://rest.sandbox.lalamove.com/v3/webhook Production: https://rest.lalamove.com/v3/webhook ``` ```json { "data": { "url": "YOUR_WEBHOOK_URL" } } ``` ```json { "data": { "url": "YOUR_WEBHOOK_URL" } } ``` -------------------------------- ### Get Order Details (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json This endpoint allows you to retrieve the details of a specific order. ```APIDOC ## GET /v3/orders/{orderId} ### Description Retrieves the details of a specific order. ### Method GET ### Endpoint https://{{hostname}}/v3/orders/{{orderId}} ### Response #### Success Response (200) - **data.driverId** (string) - The ID of the driver assigned to the order. ### Response Example ```json { "data": { "driverId": "some_driver_id" } } ``` ``` -------------------------------- ### Order Response Structure Source: https://developers.lalamove.com/ Example JSON response for a successful order retrieval. This structure includes details like order ID, status, driver information, and delivery stops. ```json { "data": { "orderId": "107900701184", "quotationId": "1471722666401517645", "priceBreakdown": {...}, "driverId": "33522", "shareLink": "https://share.lalamove.com/?TH1234556&lang=th_TH&version=2", "status": "COMPLETED", "distance": { "value": "16200", "unit": "m" }, "stops": [ { "coordinates": { "lat": "22.3353139", "lng": "114.1758402" }, "address": "Jl. Perum Dasana", "name": "dodo", "phone": "+660923447537" }, { "coordinates": { "lat": "22.3203648", "lng": "114.169773" }, "address": "Jl. Kartini, Ruko No. 1E", "name": "dodo", "phone": "+660923447537", "POD": { "status": "DELIVERED", "image": "POD_IMAGE_URL", "deliveredAt": "2022-01-20T06:26:39.721Z" } } ], "metadata": { "restaurantOrderId": "1234", "restaurantName": "Rustam's Kebab" }, "remarks": ["handle with care", "hoodie"] } } ``` -------------------------------- ### Prerequest Script for Get Quotation (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Sets environment variables for market, generates a timestamp, constructs the request body, and calculates the HMAC-SHA256 signature for the quotation request. This script must be run before sending the quotation request. ```javascript let time = new Date().getTime(); pm.environment.set("market", "HK"); let body = { "data": { // "scheduleAt": "2022-04-01T14:30:00.00Z", // optional "serviceType": "MOTORCYCLE", "specialRequests": ["TOLL_FEE_10"], // optional "language": "en_HK", "stops": [ { "coordinates": { "lat": "22.33547351186244", "lng": "114.17615807116502" }, "address": "Innocentre, 72 Tat Chee Ave, Kowloon Tong" }, { "coordinates": { "lat": "22.29553167157697", "lng": "114.16885175766998" }, "address": "Canton Rd, Tsim Sha Tsui" } ], "isRouteOptimized": false, // optional only for quotations "item":{ "quantity":"12", "weight":"LESS_THAN_3_KG", "categories":[ "FOOD_DELIVERY", "OFFICE_ITEM" ], "handlingInstructions":[ "KEEP_UPRIGHT" ] }, } }; body = JSON.stringify(body); let signature = CryptoJS.HmacSHA256(`${time.toString()}\r\nPOST\r\n/v3/quotations\r\n\r\n${body}`, environment['secret']); postman.setEnvironmentVariable('signature', signature.toString()); postman.setEnvironmentVariable('time', time); postman.setEnvironmentVariable('body', body); ``` -------------------------------- ### Test Script for Get Quotation (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Parses the JSON response and sets environment variables for total price, currency, quotation ID, and stop IDs. These variables can be used in subsequent requests. ```javascript let response = pm.response.json(); pm.environment.set("total", response.data.priceBreakdown.total); pm.environment.set("currency", response.data.priceBreakdown.currency); pm.environment.set("quotationId", response.data.quotationId); pm.environment.set("stopId-0", response.data.stops[0].stopId); pm.environment.set("stopId-1", response.data.stops[1].stopId); //pm.environment.set("stopId-2", response.data.stops[2].stopId); //should be disabled if you only have 1 drop-off point ``` -------------------------------- ### API Signature Generation Source: https://developers.lalamove.com/ This section details how to generate the HMAC SHA256 signature required for API authentication. It includes the formula and a JavaScript example. ```APIDOC ## Signature > Example in JavaScript ```javascript const SECRET = 'sk_test_Lalamove'; const time = new Date().getTime().toString(); // => `1545880607433` const method = 'POST'; const path = '/v3/quotations'; const body = JSON.stringify({...}); // => the whole body for '/v3/quotations' const rawSignature = `${time}\r\n${method}\r\n${path}\r\n\r\n${body}`; //const rawSignature = `${time}\r\n${method}\r\n${path}\r\n\r\n`; if the method is GET // => '1546222219293\r\nPOST\r\n/v3/quotations\r\n\r\n{\n"data":{...}' const SIGNATURE = CryptoJS.HmacSHA256(rawSignature, SECRET).toString(); // => '5133946c6a0ba25932cc18fa3aa1b5c3dfa2c7f99de0f8599b28c2da88ed9d42' ``` `SIGNATURE = HmacSHA256ToHex(\r\n\r\n\r\n\r\n, )` `SIGNATURE` is in **lowercase** hex (base 16) encoding. | ---|--- `SECRET` | Your API secret `TIMESTAMP` | _Unix_ timestamp in milliseconds eg. `1545880607433` `METHOD` | _Method_ (`GET`, `POST`, `PUT`, `DELETE` , `PATCH`) of the specific API call `PATH` | The _pathname_ of the specific API call including version. eg. `/v3/quotations` `BODY` | The request body in _JSON string_ Useful links * Examples of creating base64 hashes using HMAC SHA256 in different languages * SHA256 HMAC in different languages (both hex & base64 encoding) ``` -------------------------------- ### Get Cities Source: https://developers.lalamove.com/ Retrieve information on supported configuration for all cities in a specified market. Adjust the 'Market' value in your request header. This endpoint provides details on cities, available services, and special requests for each service type. ```APIDOC ## GET /v3/cities ### Description Retrieve information on supported configuration for all cities in a specified market. Adjust the 'Market' value in your request header. This endpoint provides details on cities, available services, and special requests for each service type. ### Method GET ### Endpoint /v3/cities ### Headers - **Market** (string) - Required - The market for which to retrieve city information. ### Response #### Success Response (200) - **data** (array) - An array of city objects, each containing locode, name, and services. - **locode** (string) - The location code of the city (e.g., "TH BKK"). - **name** (string) - The name of the city (e.g., "Bangkok"). - **services** (array) - An array of service objects available in the city. - **key** (string) - The key identifier for the service (e.g., "CAR"). - **description** (string) - A description of the service. - **dimensions** (object) - The dimensions of the service. - **length** (object) - The length of the service. - **value** (string) - The length value. - **unit** (string) - The unit of length (e.g., "m"). - **width** (object) - The width of the service. - **value** (string) - The width value. - **unit** (string) - The unit of width (e.g., "m"). - **height** (object) - The height of the service. - **value** (string) - The height value. - **unit** (string) - The unit of height (e.g., "m"). - **load** (object) - The load capacity of the service. - **value** (string) - The load value. - **unit** (string) - The unit of load (e.g., "kg"). - **specialRequests** (array) - An array of special request objects available for the service. - **name** (string) - The name of the special request. - **description** (string) - A description of the special request. - **parent_type** (string) - The parent type of the special request. - **max_selection** (integer) - The maximum number of selections allowed for this parent type. - **effective_time** (string) - The time when the special request becomes effective (UTC). - **offline_time** (string) - The time when the special request becomes offline (UTC). ### Response Example ```json { "data": [ { "locode": "TH BKK", "name": "Bangkok", "services": [ { "key": "CAR", "description": "Ideal for small to medium goods requiring extra care", "dimensions": { "length": { "value": "0.9", "unit": "m" }, "width": { "value": "1", "unit": "m" }, "height": { "value": "0.7", "unit": "m" } }, "load": { "value": "100", "unit": "kg" }, "specialRequests": [ { "name": "EXTRA_LENGTH_2", "description": "Extra Length of 2.5 M (standard 1.8 M)", "parent_type": "Extra Length", "max_selection": 1, "effective_time": "2023-10-20T06:26:39.721Z", "offline_time": "" }, { "name": "EXTRA_LENGTH_1", "description": "Extra Length of 2.1 M (standard 1.8 M)", "parent_type": "Extra Length", "max_selection": 1, "effective_time": "2023-10-20T06:26:39.721Z", "offline_time": "" }, { "name": "DOOR_TO_DOOR", "description": "Door to Door by Driver", "max_selection": 1, "effective_time": "", "offline_time": "2023-10-20T06:26:39.721Z" }, { "name": "ROUND_TRIP", "description": "Round Trip", "max_selection": 1, "effective_time": "", "offline_time": "" } ] } ] } ] } ``` ``` -------------------------------- ### Get City Info API Endpoints Source: https://developers.lalamove.com/ Endpoints for retrieving city information. Use the sandbox URL for testing and the production URL for live operations. ```http GET Sandbox: https://rest.sandbox.lalamove.com/v3/cities Production: https://rest.lalamove.com/v3/cities ``` -------------------------------- ### Get Order Details Request (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json This snippet generates the HMAC signature for retrieving the details of a specific order. It requires the order ID to be set in the environment. ```javascript let time = new Date().getTime(); let orderId = pm.environment.get("orderId"); let signature = CryptoJS.HmacSHA256(`${time.toString()}\r\nGET\r\n/v3/orders/${orderId}\r\n\r\n`, environment['secret']); postman.setEnvironmentVariable('signature', signature.toString()); postman.setEnvironmentVariable('time', time); postman.setEnvironmentVariable('orderId', orderId); ``` -------------------------------- ### Item Information Structure Source: https://developers.lalamove.com/ This JSON structure defines the item details for a delivery. Note that supported values for weight, categories, and handlingInstructions vary by city and vehicle type. Refer to the Get City Info endpoint for specifics. ```json { "item":{ "quantity":"12", "weight":"LESS_THAN_3_KG", "categories":[ "FOOD_DELIVERY", "OFFICE_ITEM" ], "handlingInstructions":[ "KEEP_UPRIGHT", "FRAGILE" ] } } ``` -------------------------------- ### Generate Signature for Get Driver Details (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json This script generates an HMAC-SHA256 signature for authenticating requests to retrieve driver details. It uses the current timestamp, HTTP method, request path, and request body, along with a secret key from the environment. ```javascript let time = new Date().getTime(); let orderId = pm.environment.get("orderId"); let driverId = pm.environment.get("driverId"); let signature = CryptoJS.HmacSHA256(`${time.toString()}\r\nGET\r\n/v3/orders/${orderId}/drivers/${driverId}\r\n\r\n`, environment['secret']); postman.setEnvironmentVariable('signature', signature.toString()); postman.setEnvironmentVariable('time', time); postman.setEnvironmentVariable('orderId', orderId); postman.setEnvironmentVariable('driverId', driverId); ``` -------------------------------- ### Get Driver Details (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Fetches detailed information about a specific driver associated with an order in Hong Kong. This is useful for tracking driver status or providing driver information to customers. ```APIDOC ## GET /v3/orders/:orderId/drivers/:driverId ### Description Retrieves details for a specific driver on a given order. ### Method GET ### Endpoint https://{{hostname}}/v3/orders/{{orderId}}/drivers/{{driverId}} ### Headers - **Authorization**: hmac {{apikey}}:{{time}}:{{signature}} - **Market**: {{market}} ### Path Parameters - **orderId** (string) - Required - The ID of the order. - **driverId** (string) - Required - The ID of the driver. ``` -------------------------------- ### Get Quotation (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json This endpoint allows you to get a quotation for a delivery based on service type, stops, and item details. It requires authentication and specific request body parameters. ```APIDOC ## POST /v3/quotations ### Description Retrieves a delivery quotation based on specified parameters. ### Method POST ### Endpoint https://{{hostname}}/v3/quotations ### Parameters #### Request Body - **serviceType** (string) - Required - The type of service (e.g., "MOTORCYCLE"). - **specialRequests** (array) - Optional - Special requests for the delivery (e.g., ["TOLL_FEE_10"]). - **language** (string) - Required - The language for the response (e.g., "en_HK"). - **stops** (array) - Required - An array of stop objects, each containing coordinates and address. - **coordinates** (object) - Required - Latitude and longitude of the stop. - **lat** (string) - Required - Latitude. - **lng** (string) - Required - Longitude. - **address** (string) - Required - The address of the stop. - **isRouteOptimized** (boolean) - Optional - Whether the route should be optimized (only for quotations). - **item** (object) - Required - Details about the item being delivered. - **quantity** (string) - Required - The quantity of items. - **weight** (string) - Required - The weight category (e.g., "LESS_THAN_3_KG"). - **categories** (array) - Required - Categories of the item (e.g., ["FOOD_DELIVERY", "OFFICE_ITEM"]) - **handlingInstructions** (array) - Required - Handling instructions (e.g., ["KEEP_UPRIGHT"]) ### Request Example ```json { "data": { "serviceType": "MOTORCYCLE", "specialRequests": ["TOLL_FEE_10"], "language": "en_HK", "stops": [ { "coordinates": { "lat": "22.33547351186244", "lng": "114.17615807116502" }, "address": "Innocentre, 72 Tat Chee Ave, Kowloon Tong" }, { "coordinates": { "lat": "22.29553167157697", "lng": "114.16885175766998" }, "address": "Canton Rd, Tsim Sha Tsui" } ], "isRouteOptimized": false, "item":{ "quantity":"12", "weight":"LESS_THAN_3_KG", "categories":[ "FOOD_DELIVERY", "OFFICE_ITEM" ], "handlingInstructions":[ "KEEP_UPRIGHT" ] } } } ``` ### Response #### Success Response (200) - **data** (object) - Contains quotation details. - **priceBreakdown** (object) - Price details. - **total** (string) - The total price. - **currency** (string) - The currency of the price. - **quotationId** (string) - The ID of the quotation. - **stops** (array) - Details of the stops. - **stopId** (string) - The ID of the stop. ``` -------------------------------- ### Webhook Error Response Example Source: https://developers.lalamove.com/ This JSON structure represents an error response when a webhook URL is invalid or fails validation. ```json { "errors": { "id": "ERR_INVALID_RESPONSE" "message": "Non-200 response received", "detail": "'url' validation failed: value is not a valid url" } } ``` -------------------------------- ### Get Quotation Details (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Retrieves the details of a specific quotation using its quotation ID. This endpoint is secured with HMAC authentication. ```APIDOC ## GET /v3/quotations/:quotationId ### Description Fetches the details for a given quotation ID. Requires HMAC authentication. ### Method GET ### Endpoint https://{{hostname}}/v3/quotations/{{quotationId}} ### Headers - Content-Type: application/json - Authorization: hmac {{apikey}}:{{time}}:{{signature}} - Market: {{market}} ### Response #### Success Response (200) - **driverId** (string) - The ID of the assigned driver. ``` -------------------------------- ### Order Creation Response (201 Created) Source: https://developers.lalamove.com/ This is a successful response for creating an order, detailing order information, pricing, driver assignment, and delivery status. ```json { "data": { "orderId": "152610308320", "quotationId": "1526094807863316502", "priceBreakdown": { "base": "10", "extraMileage": "10", "surcharge": "11", "specialRequests": "3", "priorityFee": "20", "totalExcludePriorityFee": "34", "total": "54", "currency": "HKD" }, "driverId": "79973", "shareLink": "https://share.sandbox.lalamove.com?HK100220516145738561910010013603412&lang=en_HK&sign=3b87850928c11309d26b6785d3e65336&source=api_wrapper", "status": "ON_GOING", "distance": { "value": "14417", "unit": "m" }, "stops": [ { "stopId": "1526094809054498905", "coordinates": { "lat": "22.3354735", "lng": "114.1761581" }, "address": "Innocentre, 72 Tat Chee Ave, Kowloon Tong", "name": "Michal", "phone": " 85238485765", "remarks": "please call when you have arrived" }, { "stopId": "1526094809054498906", "coordinates": { "lat": "22.2630804", "lng": "114.1308179" }, "address": "Telegraph Bay, Cyberport Rd, θ–„ζ‰Άζž— Cyberport 1", "name": "Michal", "phone": " 85212345679", "remarks": "please leave the package on the porch", "POD": { "status": "PENDING" } } ], "item": { "weight": "LESS_THAN_3_KG", "categories": [ "OFFICE_ITEM", "OTHERS" ] } } } ``` -------------------------------- ### Create Order Request (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json This snippet generates the HMAC signature and sets environment variables for creating a new order. It requires the current time, POST method, the order endpoint, and the request body. ```javascript let time = new Date().getTime(); let body = { "partner": "Lalamove Partner 1" // optional }; body = JSON.stringify(body); let signature = CryptoJS.HmacSHA256(`${time.toString()}\r\nPOST\r\n/v3/orders\r\n\r\n${body}`, environment['secret']); postman.setEnvironmentVariable('signature', signature.toString()); postman.setEnvironmentVariable('time', time); postman.setEnvironmentVariable('body', body); ``` -------------------------------- ### Construct Authorization Token in JavaScript Source: https://developers.lalamove.com/ Combines the API key, timestamp, and generated signature to create the final token for the Authorization header. The timestamp must match the one used for signature generation. ```javascript const API_KEY = 'pk_test_Lalamove' const TOKEN = `${API_KEY}:${time}:${SIGNATURE}` ``` -------------------------------- ### Get City Info (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Retrieves information about cities available for delivery services in Hong Kong. This operation is authenticated using HMAC. ```APIDOC ## GET /v3/cities ### Description Retrieves a list of cities available for Lalamove services in Hong Kong. Requires HMAC authentication. ### Method GET ### Endpoint https://{{hostname}}/v3/cities ### Headers - Content-Type: application/json - Authorization: hmac {{apikey}}:{{time}}:{{signature}} - Market: {{market}} ``` -------------------------------- ### Prerequest Script for Place Order (HK) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Sets the timestamp and retrieves the quotation ID and stop IDs from environment variables to construct the order placement request body. This script is executed before the order placement request. ```javascript let time = new Date().getTime(); let quotationId = pm.environment.get("quotationId"); let body = { "data": { "quotationId": pm.environment.get('quotationId'), "sender": { "stopId":pm.environment.get('stopId-0'), "name": "Michal", "phone": "+85238485765" }, "recipients": [ { "stopId":pm.environment.get('stopId-1'), "name": "Katrina", "phone": "+660923447535", "remarks": "YYYYYY" // optional } ], "isPODEnabled": true, // optional ``` -------------------------------- ### Get Quotation Details Prerequest Script (JavaScript) Source: https://developers.lalamove.com/files/HK.postman_v3.4collection.json Generates an HMAC signature for retrieving quotation details. Requires 'quotationId' and 'secret' to be set. ```javascript let time = new Date().getTime(); let quotationId = pm.environment.get("quotationId"); let signature = CryptoJS.HmacSHA256(`${time.toString()}\r\nGET\r\n/v3/quotations/${quotationId}\r\n\r\n`, environment['secret']); postman.setEnvironmentVariable('signature', signature.toString()); postman.setEnvironmentVariable('time', time); postman.setEnvironmentVariable('quotationId', quotationId); ```