API Shipping

Dokumentasi lengkap penggunaan API untuk cek ongkir dan lokasi.

1. Pencarian Lokasi (Area ID)

Digunakan untuk mendapatkan area_id yang diperlukan untuk proses hitung ongkir.

GET /api/search-lokasi

Query Parameters

Parameter Tipe Wajib Deskripsi
input String Ya Nama daerah, kota, atau kode pos (min. 3 karakter).
type String Tidak Default: single. Gunakan double untuk pencarian lebih luas.

Contoh Request (cURL)

curl -X GET "https://api-ongkir.pages.dev/api/search-lokasi?input=umbulharjo"

Contoh Respon Success

{
  "success": true,
  "areas": [
    {
      "id": "IDNP5IDNC488IDND6359IDZ55161",
      "name": "Umbulharjo, Yogyakarta, DI Yogyakarta. 55161",
      "postal_code": 55161,
      ...
    }
  ]
}

2. Cek Ongkos Kirim

Menghitung biaya pengiriman berdasarkan kurir yang tersedia.

POST /api/cek-ongkir

Request Body (JSON)

{
  "origin_postal_code": 55161,
  "destination_postal_code": 12420,
  "couriers": "jne,sicepat,anteraja,jnt",
  "items": [
    {
      "weight": 1000,
      "length": 1,
      "width": 1,
      "height": 1
    }
  ]
}

Paramater Penjelasan

Field Deskripsi
origin_postal_code Kode pos asal (Integer).
destination_postal_code Kode pos tujuan (Integer).
couriers Daftar kurir dipisah koma.
items Array objek berisi detail berat (gram) dan dimensi (cm).
Kurir yang Didukung:
jne, sicepat, anteraja, wahana, rpx, idexpress, jdl, lion, tiki, jnt, ninja, sap, pos

Contoh Request (cURL)

curl -X POST "https://api-ongkir.pages.dev/api/cek-ongkir" \
     -H "Content-Type: application/json" \
     -d '{
           "origin_postal_code": 55161,
           "destination_postal_code": 12420,
           "couriers": "jne,sicepat",
           "items": [{ "weight": 1000, "length": 10, "width": 10, "height": 10 }]
         }'

3. Pencarian Lokasi Instant (Maps)

Proxy ke Google Places Autocomplete untuk pencarian lokasi (Instant Courier).

Demo Tersedia: Coba Demo Instant Courier
GET /api/search-lokasi-instant

Query Parameters

Parameter Tipe Wajib Deskripsi
q String Ya Kata kunci pencarian lokasi (min. 3 karakter).

Contoh Request (cURL)

curl -X GET "https://api-ongkir.pages.dev/api/search-lokasi-instant?q=Monas"

Contoh Respon Success

{
  "results": [
    {
      "id": "ChIJMwPfYKfxaS4R1xww8mD-jkw",
      "text": "Monas, Gambir, Central Jakarta City, Jakarta, Indonesia",
      "structured_formatting": {
        "main_text": "Monas",
        "secondary_text": "Gambir, Central Jakarta City, Jakarta, Indonesia"
      }
    }
  ]
}

4. Detail Lokasi Instant

Proxy ke Google Places Details untuk mendapatkan koordinat (latitude/longitude).

GET /api/detail-lokasi-instant

Query Parameters

Parameter Tipe Wajib Deskripsi
place_id String Ya ID lokasi dari hasil autocomplete.

Contoh Request (cURL)

curl -X GET "https://api-ongkir.pages.dev/api/detail-lokasi-instant?place_id=ChIJMwPfYKfxaS4R1xww8mD-jkw"

Contoh Respon Success

{
  "result": {
    "geometry": {
      "location": {
        "lat": -6.1753924,
        "lng": 106.8271528
      }
    },
    "name": "Monas",
    "formatted_address": "Gambir, Central Jakarta City, Jakarta, Indonesia"
  },
  "status": "OK"
}

5. Cek Ongkir Instant

Cek tarif khusus kurir instan (Gojek/Grab) via Biteship.

POST /api/cek-ongkir-instant

Request Body (JSON)

{
  "origin_latitude": -6.175392,
  "origin_longitude": 106.827153,
  "destination_latitude": -6.208763,
  "destination_longitude": 106.845599,
  "couriers": "gojek,grab",
  "items": [{
    "length": 10,
    "width": 10,
    "height": 10,
    "weight": 1000
  }]
}

Paramater Penjelasan

Field Deskripsi
origin_latitude Latitude lokasi asal.
origin_longitude Longitude lokasi asal.
destination_latitude Latitude lokasi tujuan.
destination_longitude Longitude lokasi tujuan.
couriers Kurir: gojek,grab.
items Array dimensi dan berat barang.

Contoh Request (cURL)

curl -X POST "https://api-ongkir.pages.dev/api/cek-ongkir-instant" \
     -H "Content-Type: application/json" \
     -d '{
           "origin_latitude": -6.175392,
           "origin_longitude": 106.827153,
           "destination_latitude": -6.208763,
           "destination_longitude": 106.845599,
           "couriers": "gojek,grab",
           "items": [{ "length": 10, "width": 10, "height": 10, "weight": 1000 }]
         }'

Contoh Respon Success

{
  "success": true,
  "object": "courier_pricing",
  "pricing": [
    {
      "company": "gojek",
      "courier_name": "GoSend",
      "courier_service_name": "Instant",
      "duration": "1-2 jam",
      "price": 20000,
      ...
    }
  ]
}