service market / Shipping fee API development documentation
Sea express freight collection API · v1

Shipping fee API development documentation

China → Taiwan sea express freight real-time calculation API. Pricing is in RMB, supporting actual weight and volume (volume weight) billing, with a single request returning complete billing details. Specially designed for front-end freight quotations of cross-border e-commerce platforms such as 0337.tw.

Sea express

Shipping method (Sea Express)

¥10/kg

Rate per kilogram (RMB)

+¥20

Surcharge for billable weight less than 10kg

<50ms

average response time

1 Overview

The freight API allows your platform to instantly display "China → Taiwan Sea Express Collection Fee" on the front desk, eliminating the burden of maintaining your own rate table.

what can be done

  • Freight Calculation - Enter the weight of the package (or length, width and volume), and return the package's sea express shipping fee (RMB).
  • Get rate - Query the current per kilogram rate, surcharge threshold and volume conversion coefficient, which is convenient for you to calculate or cache on the front end.

All responses are in JSON, in a unified envelope format: when successful, success: true with data; when failed, success: false with error code and message.

pricing currency: RMB (CNY / ¥). The rate of this API is the cross-border e-commerce cooperation project rate, which is maintained separately from the 0523.tw official website (NTD) shipping trial calculation. If you need a quotation in New Taiwan Dollars or other shipping methods, please contact us to activate.

2 Certification and basic information

All requests must bring API Key. Can be placed in the Authorization header (recommended) or the X-API-Key header.

Base URL

https://0523.tw/api/v1/freight

Authentication header (choose one)

Method A — Bearer Token (recommended)

Authorization: Bearer lk_live_xxxxxxxxxxxxxxxxxxxxxxxx

Method B — X-API-Key

X-API-Key: lk_live_xxxxxxxxxxxxxxxxxxxxxxxx

The API Key starts with lk_live_. Please keep safe and never put into front-end JavaScript or public Git repositories; all calls should be made from your server side.

Rate Limit

Each key has a request limit per minute, and the response header will report the remaining limit:

headerillustrate
X-RateLimit-LimitNumber of requests allowed per minute
X-RateLimit-RemainingNumber of requests remaining this minute
Retry-AfterNumber of seconds to wait for time limit exceeded (HTTP 429)

For the best front-end experience, it is recommended to cache the /rates results for a few minutes and calculate them with the same formula on your own server. Only call /quote for verification during the critical steps of placing an order.

3 Endpoint: get rate

GET /api/v1/freight/rates

Lists all currently enabled shipping methods and rates. No parameters are required.

ask

curl https://0523.tw/api/v1/freight/rates \
  -H "Authorization: Bearer lk_live_xxxxxxxxxxxxxxxxxxxxxxxx"

Response 200

{
  "success": true,
  "currency": "CNY",
  "data": [
    {
      "method": "sea",
      "name_zh": "海快",
      "name_en": "Sea Express",
      "rate_per_kg": 10,
      "surcharge": 20,
      "min_threshold": 15,
      "volume_divisor": 10000,
      "currency": "CNY"
    }
  ]
}

4 Endpoint: Freight Calculation

GETPOST /api/v1/freight/quote

The sea express shipping fee is calculated based on the weight/volume size of the package. Both GET (query string) and POST (JSON or form) are acceptable.

Request parameters

parameterTypeRequiredillustrate
weightnumberOptional*Actual weight in kilograms (kg).
lengthnumberOptional*Length, unit is centimeters (cm).
widthnumberOptional*Width in centimeters (cm).
heightnumberOptional*Height, unit is centimeters (cm).
methodstringOptionalThe shipping method is currently sea (sea express). When omitted, sea is assumed.
* weight and "complete length/width/height" choose at least one . When both are provided, the system takes the larger of "actual weight" and "volumetric weight" as the billing weight.

Request example (GET)

curl "https://0523.tw/api/v1/freight/quote?weight=8&method=sea" \
  -H "Authorization: Bearer lk_live_xxxxxxxxxxxxxxxxxxxxxxxx"

Request example (POST JSON)

curl -X POST https://0523.tw/api/v1/freight/quote \
  -H "Authorization: Bearer lk_live_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"weight": 5, "length": 40, "width": 30, "height": 30}'

Response 200

{
  "success": true,
  "data": {
    "method": "sea",
    "method_name_zh": "海快",
    "method_name_en": "Sea Express",
    "currency": "CNY",
    "currency_symbol": "¥",
    "actual_weight": 5,
    "volume_weight": 3.6,
    "volume_divisor": 10000,
    "billable_weight": 5,
    "billable_basis": "actual",
    "rate_per_kg": 10,
    "freight": 50,
    "surcharge": 20,
    "surcharge_applied": true,
    "min_threshold": 15,
    "total_fee": 70
  }
}

Response field description

fieldillustrate
actual_weightActual weight (kg). 0 if not provided.
volume_weightVolume (volume) weight (kg) = length × width × height ÷ 10000. 0 if no size is provided.
billable_weightBillable weight (kg) = max (actual weight, volumetric weight).
billable_basisBilling is based on :actual (based on actual weight) or volumetric (based on volume).
freightBasic freight = billing weight × rate per kilogram (excluding surcharges).
surchargeThe actual surcharge for this transaction (0 if not triggered).
surcharge_appliedWhether to trigger surcharge (billing weight < threshold).
total_feeThe final freight receivable is (RMB, rounded to the nearest whole number).

5 Billing formulas and examples

The calculation logic of this API is consistent with the 0523.tw official website Sea express calculator, only the rate is changed to the cooperation project rate. You can precalculate it using the same formula in your own system.

① Volume weight = length × width × height (cm) ÷ 10000
② Billing weight = max (actual weight, volumetric weight)
③ Basic freight = Billing weight × ¥10/kg
④ Surcharge = Billing weight < 10kg ? +¥20 : ¥0
⑤ Freight receivable = round(③ + ④)

Practical examples

¥1008 kg Package → Billing weight 8kg < 10kg → 8×10 + 20 = 100
¥20020 kg Package → Billing weight 20kg ≥ 10kg → 20×10 = 200 (No surcharge)
¥705 kg + box 40×30×30cm → volume weight 3.6kg, billable weight 5kg → 5×10 + 20 = 70
¥1203 kg + box 60×50×40cm → volume weight 12kg > actual weight, billable weight 12kg ≥ 10kg → 12×10 = 120 (no surcharge)
¥150 Box 50×50×60cm (size only) → Volume weight 15kg, billing weight 15kg ≥ 10kg → 15×10 = 150

6 error code

The error response is always { "success": false, "error": "...", "message": "..." }.

HTTPerrorillustrate
401missing_api_keyNo API Key is provided. Please add Authorization or X-API-Key header.
401invalid_api_keyAPI Key is invalid.
403key_suspended / key_revoked / key_expiredKey has been deactivated/revoked/expired.
403insufficient_scopeThe key does not have the freight:read permission.
422validation_failedParameter format error (type, range).
422missing_parametersNo weight or full length/width/height provided.
422unsupported_methodmethod is not in the available list.
429rate_limit_exceededExceeding the request limit per minute, see Retry-After.

7 Program example

Server-side call example. Please replace lk_live_... with your key and store it in the environment variable.

// composer require guzzlehttp/guzzle
use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'https://0523.tw']);

$res = $client->post('/api/v1/freight/quote', [
    'headers' => [
        'Authorization' => 'Bearer ' . env('LUCKY_FREIGHT_KEY'),
        'Accept'        => 'application/json',
    ],
    'json' => [
        'weight' => 8,
        'method' => 'sea',
    ],
]);

$data = json_decode($res->getBody(), true);
echo '運費 ¥' . $data['data']['total_fee'];  // 運費 ¥100
// Node.js / 伺服器端 — 請勿在瀏覽器暴露金鑰
const res = await fetch('https://0523.tw/api/v1/freight/quote', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.LUCKY_FREIGHT_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ weight: 8, method: 'sea' }),
});
const { data } = await res.json();
console.log(`運費 ¥${data.total_fee}`);  // 運費 ¥100
curl -X POST https://0523.tw/api/v1/freight/quote \
  -H "Authorization: Bearer $LUCKY_FREIGHT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"weight": 8, "method": "sea"}'

8 Laravel mall integration suggestions

0337.tw is the Laravel mall. It is recommended to package the shipping fee API into a backend Service and call: during the checkout process:

  • After getting the total weight (kg)/volume of the shopping cart at checkout, call /api/v1/freight/quote on the backend , and set the returned total_fee as the shipping fee.
  • The key is placed in .env (for example, LUCKY_FREIGHT_KEY) and read with config(). Do not hard-code it in your code or front end.
  • When the call fails (timeout / 429), the rate cached in /rates is calculated locally using the same formula as a backup to ensure uninterrupted checkout.
  • The amount is in RMB; if the mall settles the bill in New Taiwan Dollars, please apply the exchange rate conversion yourself.

Laravel Example (Http facade)

// app/Services/LuckyFreightService.php
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Cache;

class LuckyFreightService
{
    public function quote(float $weight): int
    {
        $res = Http::withToken(config('services.lucky.freight_key'))  // 讀 .env
            ->acceptJson()
            ->timeout(8)
            ->get('https://0523.tw/api/v1/freight/quote', [
                'weight' => $weight,
                'method' => 'sea',
            ]);

        if ($res->successful()) {
            return (int) $res->json('data.total_fee');  // 人民幣
        }

        // 後備:用快取費率本地計算,結帳不中斷
        return $this->fallbackQuote($weight);
    }
}

Add 'lucky' => ['freight_key' => env('LUCKY_FREIGHT_KEY')] in config/services.php, and then inject LuckyFreightService into the checkout Controller to obtain the freight.

The single source of truth : rate centralization is maintained by HowBridge. After we adjust the rate, the API will reflect it immediately, and your mall will be updated simultaneously without any revision.

9 Support and versions

technical support: howyunqisoftware@gmail.com

API version: v1 (stable). Any breaking changes will be released with a new version number (v2), v1 will remain compatible.

Change history: 2026-06-01 — Freight API v1 is online (Hai Express, priced in RMB).

Apply for an API key