> For new integrations, EasyParcel recommends the NextGen API: https://developer.easyparcel.com/

# Rate Checking

> EasyParcel API · Singapore · Individual · version 1.1.0.0
> Page: https://developers.easyparcel.com/sg/individual/rate-checking · Markdown: https://developers.easyparcel.com/sg/individual/rate-checking.md · PDF: https://developers.easyparcel.com/pdf/Singapore_Individual_1.1.0.0.pdf

This enable rate checking from all courier companies in EasyParcel platform. User need to provide sender and receiver address to check the shipment rate.

## Endpoint

- Method: `POST`
- Demo URL: `https://demo.connect.easyparcel.sg/?ac=EPRateCheckingBulk`
- Live URL: `https://connect.easyparcel.sg/?ac=EPRateCheckingBulk`
- Body: `application/x-www-form-urlencoded`. Nested fields use PHP `http_build_query` names, e.g. `bulk[0][pick_code]`.
- Action: `EPRateCheckingBulk`

## Request parameters

### Request L1

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `api` | string(25) | Yes | Obtain from registered account. |
| `bulk` | array | Yes | (Refer to table L2) |
| `byoc_no_timeout` | boolean | Optional | By default the live BYOC rate lookup is bounded to 5 seconds so it can never delay the normal rates; if it does not respond within 5 seconds, BYOC rates are simply omitted. Set to true to wait for the full BYOC courier response (no 5-second limit) |
| `api_rate_on` | boolean | Optional | Some courier services, such as UPS and FedEx, may experience slower response times. To maintain overall performance, the default timeout is set to 3 seconds. Set this parameter to true to extend the timeout to 60 seconds, allowing more time for slower courier responses. Set this parameter to false if you do not require quotations from these couriers, which helps maintain overall API performance. |
| `auto_apply_coupon` | boolean | Optional | Controls whether eligible coupons are automatically applied during quotation. When enabled, the quoted shipment prices will be displayed after the applicable coupon discount is applied. If this parameter is not specified, the behavior will follow the auto-apply coupon settings configured in EasyParcel. |

### Request L2

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `pick_code` | string(10) | Yes | Sender's postcode. |
| `pick_country` | string(2) | Yes | Sender's country (“SG”). |
| `send_code` | string(10) | Yes | Receiver's postcode. |
| `send_country` | string(2) | Yes | Receiver's country (“SG”). |
| `weight` | double(8,2) | Yes | The weight of the parcel. |
| `width` | double(8,2) | Optional | The width of the parcel. |
| `length` | double(8,2) | Optional | The length of the parcel. |
| `height` | double(8,2) | Optional | The height of the parcel. |
| `date_coll` | date | Optional | Check the available pickup date. If the date is left empty, the default will be today’s date. Format : “YYYY-MM-DD” |
| `parcel_value` | double(8,2) | Optional | The value of parcel in SGD |
| `addon_tracking_whatsapp_enabled` | boolean | Optional | By enabling this feature, your price quotes will automatically include the WhatsApp tracking service fee |
| `addon_tracking_sms_enabled` | boolean | Optional | By enabling this feature, your price quotes will automatically include the tracking SMS service fee |
| `addon_tracking_email_enabled` | boolean | Optional | By enabling this feature, your price quotes will automatically include the tracking email service fee |

## Sample code

### PHP

```php
<?php
$domain = "https://demo.connect.easyparcel.sg/?ac=";

$action = "EPRateCheckingBulk";
$postparam = array(
    'api' => 'xxxxxx',
    'bulk' => array(
        array(
            'pick_code' => '059893',
            'pick_country' => 'SG',
            'send_code' => '059897',
            'send_country' => 'SG',
            'weight' => '10',
            'width' => '0',
            'length' => '0',
            'height' => '0',
            'date_coll' => '2017-11-10',
        ),
        array(
            'pick_code' => '059893',
            'pick_country' => 'SG',
            'send_code' => '059897',
            'send_country' => 'SG',
            'weight' => '10',
            'width' => '0',
            'length' => '0',
            'height' => '0',
            'date_coll' => '2017-11-10',
        ),
    ),
);

$url = $domain.$action;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postparam));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

ob_start();
$return = curl_exec($ch);
ob_end_clean();
curl_close($ch);

$json = json_decode($return);
echo "<pre>"; print_r($json); echo "</pre>";
?>
```

### cURL

```bash
curl -X POST 'https://demo.connect.easyparcel.sg/?ac=EPRateCheckingBulk' \
  --data-urlencode 'api=xxxxxx' \
  --data-urlencode 'bulk[0][pick_code]=059893' \
  --data-urlencode 'bulk[0][pick_country]=SG' \
  --data-urlencode 'bulk[0][send_code]=059897' \
  --data-urlencode 'bulk[0][send_country]=SG' \
  --data-urlencode 'bulk[0][weight]=10' \
  --data-urlencode 'bulk[0][width]=0' \
  --data-urlencode 'bulk[0][length]=0' \
  --data-urlencode 'bulk[0][height]=0' \
  --data-urlencode 'bulk[0][date_coll]=2017-11-10' \
  --data-urlencode 'bulk[1][pick_code]=059893' \
  --data-urlencode 'bulk[1][pick_country]=SG' \
  --data-urlencode 'bulk[1][send_code]=059897' \
  --data-urlencode 'bulk[1][send_country]=SG' \
  --data-urlencode 'bulk[1][weight]=10' \
  --data-urlencode 'bulk[1][width]=0' \
  --data-urlencode 'bulk[1][length]=0' \
  --data-urlencode 'bulk[1][height]=0' \
  --data-urlencode 'bulk[1][date_coll]=2017-11-10'
```

## Response

### Response L1

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `api_status` | string(10) | Validation result | (Refer to [Appendix I](https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md)) |
| `error_code` | int(5) | Error code | (Refer to [Appendix I](https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md)) |
| `error_remark` | string(100) | Error message | (Refer to [Appendix I](https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md)) |
| `result` | array | The response of the rate checking | (Refer to table L2) |

### Response L2

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `status` | string(10) | The status of the rate checking. | Fail / Success |
| `remarks` | string(100) | The error message for rate checking. |  |
| `rates` | array | The result of the rate checking | (Refer to table L3) |

### Response L3

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `service_id` | string (15) | Service ID |  |
| `service_name` | string (100) | Service name |  |
| `service_type` | string (10) | Type of service | parcel/ document |
| `courier_id` | string (10) | Courier ID |  |
| `courier_name` | string (100) | Courier name |  |
| `courier_logo` | string (300) | Courier logo |  |
| `scheduled_start_date` | string (50) | Scheduled pickup for parcel. |  |
| `pickup_date` | date | The date to pickup the parcel. | Same day pickup only available before 12pm. |
| `delivery` | string (100) | The day(s) to deliver the parcel. |  |
| `price` | double(8,2) | Booking price. |  |
| `whatsapp_tracking_available` | boolean | Identifies if there is whatsapp tracking service available | True if supported / False if not supported. Addon insurance can only be purchased for parcels which value exceed the basic_insurance_max_value. |
| `whatsapp_tracking_price` | double(8,2) | Whatsapp Tracking charges/price |  |
| `import_tax_charges` | double(8,2) | DDP Tax Charges (For International Shipment) |  |
| `import_duty_charges` | double(8,2) | DDP Duty Charges (For International Shipment) |  |
| `handling_charges` | double(8,2) | DDP Handling Charges (For International Shipment) |  |
| `byoc_charges` | double(8,2) | EasyParcel's BYOC platform charge for this shipment | BYOC rates only |
| `byoc_charges_tax` | double(8,2) | Tax on the BYOC platform charge | BYOC rates only |
| `seller_payable_amount` | double(8,2) | The amount that is actually payable to EasyParcel. For a normal courier this equals the price. For a BYOC courier it is the BYOC platform charge plus its tax (byoc_charges + byoc_charges_tax + add-on price if enabled) |  |
| `ddp_available` | boolean | Whether this service support DDP |  |
| `ddp_only` | boolean | Whether this service only support DDP, not support DDU |  |
| `handling_charges_tax` | double(8,2) | DDP Handling Charges Tax |  |
| `coupon_discount` | double(8,2) | Amount of discount if coupon auto apply is on |  |
| `coupon_codes` | array | List of coupon codes used if coupon auto apply is on |  |
| `coupons` | array | List of coupon used with the details if coupon auto apply is on |  |
| `price_before_coupon` | double(8,2) | Total price before apply coupon |  |
| `auto_apply_coupon` | boolean | Whether auto apply coupon during quotation is on |  |
| `auto_apply_coupon_payment` | boolean | Whether auto apply coupon during payment is on |  |

## Response samples

### Success

```json
{
  "api_status":"Success",
  "error_code":"0",
  "error_remark":"",
  "result":[
    {
      "status":"Success",
      "remarks":"",
      "rates":[
        {
          "service_id":"EP-CS0D",
          "service_name":"Next Day Pick Up Service",
          "service_type":"parcel",
          "courier_id":"EP-CR0A",
          "courier_name":"Nationwide",
          "courier_logo":"http:\/\/source.easyparcel.sg\/img\/logo\/Nationwide-Express-logo.jpg",
          "scheduled_start_date":"2017-11-11 Saturday",
          "pickup_date":"2017-11-11",
          "delivery":"Estimated 1 working day(s)",
          "price":"20.90"
        }
      ]
    },
    {
      "status":"Success",
      "remarks":"",
      "rates":[
        {
          "service_id":"EP-CS0D",
          "service_name":"Next Day Pick Up Service",
          "service_type":"parcel",
          "courier_id":"EP-CR0A",
          "courier_name":"Nationwide",
          "courier_logo":"http:\/\/source.easyparcel.sg\/img\/logo\/Nationwide-Express-logo.jpg",
          "scheduled_start_date":"2017-11-11 Saturday",
          "pickup_date":"2017-11-11",
          "delivery":"Estimated 1 working day(s)",
          "price":"20.90"
        }
      ]
    }
  ]
}
```

### Fail

```json
{
  "api_status":"Error",
  "error_code":"3",
  "error_remark":"Required api key",
  "result":[
    
  ]
}
```

## Referenced appendices

Copied from the appendix pages linked above.

### Appendix I: API Return Status

Source: https://developers.easyparcel.com/sg/individual/appendix/api-return-status.md

| api_status | error_code | error_remark |
| --- | --- | --- |
| Error | 3 | Required api key |
| Error | 4 | Invalid api key |
| Error | 5 | Unauthorized user |
| Success | 0 |  |

Support: WhatsApp EasyParcel API Support — https://api.whatsapp.com/send/?phone=6042023160

Published by EasyParcel Singapore Pte Ltd (201605202W). GST No: 201605202W.
