Aturan Dan Saran Menggunakan API Provinsi

Kebijakan penggunaan Api-Ongkir.com.

  • Dengan menggunakan API Ongkir maka anda sepakat dan setuju dengan term yang telah di tentukan
  • Kami tidak mensarankan anda untuk melakukan cache pada responce API, karena akan mempengaruhi data yang akan ditayangkan, kita akan memberikan support khusus bila anda melakukan hal ini.
  • Cache disaranakan untuk province, city, subdistrict yang akan di gunakan untuk membuat auto-complete form
  • Kami melarang menggunakan bot, scaraping atau mesin otomatis untuk mengambil data API. Kondisi ini membuat server akan bekerja terlalu tinggi dan menggangu kepada user lainnya. Bila hal ini di lakukan, maka kami berhak untuk menutup akun akses ke API.

Saran penggunaan Api-Ongkir.com.

  • Untuk alur standart yang disarankan adalah dengan mendapatkan nilai province, dari nilai province gunakan untuk mendapatkan nilai dari city dan berikutnya anda bisa mendapatkan nilai dari subdistrict_id.
  • Dengan memperoleh nilai diatas maka anda baru bisa menggunakan untuk mengambil dari harga biaya kirim kurir.
  • Saran di atas tidak meliputi kebutuhan dan kustomisasi lainnya, kebutuhan di kembalikan kepada developer.

API Provinsi

API Provinsi digunakan untuk mendapatkan data provinsi.

Request

Method URL
GET https://apps.api-ongkir.com/api/province/[id]
Method Parameter Wajib Tipe Description
GET/HEAD api-key YES String API Key
GET id YES Int Tambahkan id provinsi

Contoh Request

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://apps.api-ongkir.com/api/province/13',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'api-key: _Your_API_Key_'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'apps.api-ongkir.com',
  'path': '/api/province/13',
  'headers': {
    'api-key': '_Your_API_Key_'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
                                            
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://apps.api-ongkir.com/api/province/13"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("api-key", "_Your_API_Key_")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
                                            

Response Success

{
    "api-ongkir": {
        "query": {
            "id": "13"
        },
        "status": {
            "code": 200,
            "description": "OK"
        },
        "results": {
            "province_id": "13",
            "province": "Kalimantan Selatan"
        }
    }
}

API Kota

API Kota digunakan untuk mendapatkan data kota.

Request

Method URL
GET https://apps.api-ongkir.com/city/[province_id]/[id]
Method Parameter Wajib Tipe Description
GET/HEAD api-key YES String API Key
GET [province_id] YES Int Tambahkan id provinsi
GET id YES Int Tambahkan id kota

Contoh Request

Response Success

{
    "api-ongkir": {
        "query": {
            "province": "5",
            "id": "39"
        },
        "status": {
            "code": 200,
            "description": "OK"
        },
        "results": {
            "city_id": "39",
            "province_id": "5",
            "province": "DI Yogyakarta",
            "type": "Kabupaten",
            "city_name": "Bantul",
            "postal_code": "55715"
        }
    }
}

API Kecamatan

API Kecamatan digunakan untuk mendapatkan data kecamatan.

Request

Method URL
GET https://apps.api-ongkir.com/api/subdistrict/[id]
Method Parameter Wajib Tipe Description
GET/HEAD api-key YES String API Key
GET id YES Int Tambahkan id kota (city)

Contoh Request

Response Success

{
    "api-ongkir": {
        "query": {
            "city": "156"
        },
        "status": {
            "code": 200,
            "description": "OK"
        },
        "results": [
            {
                "subdistrict_id": "2129",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Danau Teluk",
                "postal_code": "36263"
            },
            {
                "subdistrict_id": "2130",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Jambi Selatan",
                "postal_code": "36158"
            },
            {
                "subdistrict_id": "2131",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Jambi Timur",
                "postal_code": "36144"
            },
            {
                "subdistrict_id": "2132",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Jelutung",
                "postal_code": "36137"
            },
            {
                "subdistrict_id": "2133",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Kota Baru",
                "postal_code": "36127"
            },
            {
                "subdistrict_id": "2134",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Pasar Jambi",
                "postal_code": "36114"
            },
            {
                "subdistrict_id": "2135",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Pelayangan",
                "postal_code": "36255"
            },
            {
                "subdistrict_id": "2136",
                "province_id": "8",
                "province": "Jambi",
                "city_id": "156",
                "city": "Jambi",
                "type": "Kota",
                "subdistrict_name": "Telanaipura",
                "postal_code": "36122"
            }
        ]
    }
}

API Tarif

API untuk mendapatkan harga ongkos kirim dari setiap kurir.

Request

Method URL
POST https://apps.api-ongkir.com/api/rate
Method Parameter Wajib Tipe Description
POST/HEAD api-key YES String API Key
POST origin YES Int id kota (city) pengirim
POST originType YES String subdistrict, city
POST destination YES Int id kota (city), kecamatan (subdistrict) tujuan
POST destinationType YES String subdistrict, city
POST weight YES String berat barang (gram)
POST courier YES String gunakan code: tiki, slis, sap, jnt, pos, idl, star, dse, sicepat, anteraja, wahana, rex, dse, jet, ncs, rpx, ninja, sentral, indah, lion, pahala, ide, jne, first, jtl
Bila menggunakan postman gunakan x-www-form-urlencoded dibagian BODY

Contoh Request

Response Success

{
    "api-ongkir": {
        "query": {
            "origin": "501",
            "originType": "city",
            "destination": "574",
            "destinationType": "subdistrict",
            "weight": "1700",
            "courier": "lion"
        },
        "status": {
            "code": 200,
            "description": "OK"
        },
        "origin_details": {
            "city_id": "501",
            "province_id": "5",
            "province": "DI Yogyakarta",
            "type": "Kota",
            "city_name": "Yogyakarta",
            "postal_code": "55111"
        },
        "destination_details": {
            "subdistrict_id": "574",
            "province_id": "10",
            "province": "Jawa Tengah",
            "city_id": "41",
            "city": "Banyumas",
            "type": "Kabupaten",
            "subdistrict_name": "Banyumas"
        },
        "results": [
            {
                "code": "lion",
                "name": "Lion Parcel",
                "costs": [
                    {
                        "service": "REGPACK",
                        "description": "Regular Service",
                        "cost": [
                            {
                                "value": 22000,
                                "etd": "2-3",
                                "note": ""
                            }
                        ]
                    },
                    {
                        "service": "JAGOPACK",
                        "description": "Economy Service",
                        "cost": [
                            {
                                "value": 21000,
                                "etd": "2-6",
                                "note": ""
                            }
                        ]
                    },
                    {
                        "service": "OTOPACK150",
                        "description": "Otomotive Shipping Service",
                        "cost": [
                            {
                                "value": 790000,
                                "etd": "5-9",
                                "note": ""
                            }
                        ]
                    },
                    {
                        "service": "OTOPACK250",
                        "description": "Otomotive Shipping Service",
                        "cost": [
                            {
                                "value": 945000,
                                "etd": "5-9",
                                "note": ""
                            }
                        ]
                    },
                    {
                        "service": "BOSSPACK",
                        "description": "Priority Service",
                        "cost": [
                            {
                                "value": 28000,
                                "etd": "1-2",
                                "note": ""
                            }
                        ]
                    },
                    {
                        "service": "BIGPACK",
                        "description": "Big Package Service",
                        "cost": [
                            {
                                "value": 58400,
                                "etd": "4-8",
                                "note": ""
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

Tracking RESI 1

Api-Ongkir menggunakan 2 server API RESI tracking yang berbeda. Sehingga anda perlu menyesuaikan endpoin dan responce dari masing masing API. API 1 digunakan untuk melakukan tracking resi dari: pos, wahana, tiki, jnt, sap, sicepat, jet, dse, first, ninja, lion, idl, rex, ide, sentral, anteraja, jtl, star.

Request

Method URL
POST https://apps.api-ongkir.com/api/resi
Method Parameter Wajib Tipe Description
POST/HEAD api-key YES String API Key
POST waybill YES String kode awb dari kurir
POST courier YES String gunakan code: pos, wahana, tiki, jnt, sap, sicepat, jet, dse, first, ninja, lion, idl, rex, ide, sentral, anteraja, jtl, star

Contoh Request

Response Success

{
    "api-ongkir": {
        "query": {
            "waybill": "TLJR353RR1YTYGPH",
            "courier": "jne"
        },
        "status": {
            "code": 200,
            "description": "OK"
        },
        "result": {
            "delivered": true,
            "summary": {
                "courier_code": "jne",
                "courier_name": "Jalur Nugraha Ekakurir (JNE)",
                "waybill_number": "TLJR353RR1YTXXXX",
                "service_code": "CTC",
                "waybill_date": "2024-08-28",
                "shipper_name": "Anonymous Store",
                "receiver_name": "Anonymous",
                "origin": "SIDOARJO,SIDOARJO",
                "destination": "KRIAN,SIDOARJO",
                "status": "DELIVERED"
            },
            "details": {
                "waybill_number": "TLJR353RR1YTXXXX",
                "waybill_date": "2024-08-28",
                "waybill_time": "19:11",
                "weight": "1",
                "origin": "SIDOARJO,SIDOARJO",
                "destination": "KRIAN,SIDOARJO",
                "shipper_address1": "Anonymous Store (08565623XXXX) ",
                "shipper_address2": "EC. SIDOARJO, KABUPATEN SIDOA",
                "shipper_address3": "",
                "shipper_city": "KAB. SIDOARJO",
                "receiver_name": "TIYO AVIANTO",
                "receiver_address1": "PERUM REGENCY BLOK",
                "receiver_address2": "",
                "receiver_address3": "",
                "receiver_city": "KRIAN,SIDOARJO"
            },
            "delivery_status": {
                "status": "DELIVERED",
                "pod_receiver": "Anonymous",
                "pod_date": "2024-08-29",
                "pod_time": "10:18"
            },
            "manifest": [
                {
                    "manifest_code": "",
                    "manifest_description": "SHIPMENT RECEIVED BY JNE COUNTER OFFICER AT [SIDOARJO,SIDOARJO]",
                    "manifest_date": "2024-08-28",
                    "manifest_time": "19:11",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "PICKED UP BY COURIER [SIDOARJO,SIDOARJO]",
                    "manifest_date": "2024-08-28",
                    "manifest_time": "21:02",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "RECEIVED AT SORTING CENTER [SIDOARJO,SIDOARJO]",
                    "manifest_date": "2024-08-28",
                    "manifest_time": "21:43",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "SHIPMENT FORWARDED FROM TRANSIT CITY TO DESTINATION CITY [SDA, HUB SIDOARJO INBOUND]",
                    "manifest_date": "2024-08-28",
                    "manifest_time": "22:36",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "RECEIVED AT INBOUND STATION [SDA, HUB SIDOARJO INBOUND]",
                    "manifest_date": "2024-08-29",
                    "manifest_time": "06:23",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "SHIPMENT FORWARDED FROM TRANSIT CITY TO DESTINATION CITY [SIDOARJO, OPR KRIAN]",
                    "manifest_date": "2024-08-29",
                    "manifest_time": "06:38",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "RECEIVED AT INBOUND STATION [SIDOARJO, OPR KRIAN]",
                    "manifest_date": "2024-08-29",
                    "manifest_time": "07:52",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "WITH DELIVERY COURIER  [SIDOARJO,SIDOARJO]",
                    "manifest_date": "2024-08-29",
                    "manifest_time": "09:16",
                    "city_name": ""
                },
                {
                    "manifest_code": "",
                    "manifest_description": "DELIVERED TO [TYO | 29-08-2024 10:18 | KRIAN,SIDOARJO ]",
                    "manifest_date": "2024-08-29",
                    "manifest_time": "10:18",
                    "city_name": ""
                }
            ]
        }
    }
}

Tracking RESI 2

Api-Ongkir menggunakan 2 server API RESI tracking yang berbeda. Sehingga anda perlu menyesuaikan endpoin dan responce dari masing masing API. Khusus untuk API RESI 2 akan di kenakan biaya API Call. API2 digunakan untuk melakukan tracking resi dari: PCP Express (pcp), Kurir Rekomendasi (kurir_tokopedia), Dakota Cargo (dakota_cargo), Indah Cargo (indah_cargo), Lazada Express (lex), Shopee Express (spx), KGXpress (kgx). Pelajari disini.

Request

Method URL
POST https://apps.api-ongkir.com/api/resi2
Method Parameter Wajib Tipe Description
POST/HEAD api-key YES String API Key
POST waybill YES String kode awb dari kurir
POST courier YES String gunakan code: jnt_cargo, pcp, spx, kgx, lex, jet, indah_cargo, dakota, kurir_tokopedia

Contoh Request

Response Success

{
    "status": 200,
    "message": "Successfully tracked package",
    "data": {
        "summary": {
            "awb": "TKP01-XXXXXXXX",
            "courier": "Kurir Rekomendasi",
            "service": "Regular",
            "status": "DELIVERED",
            "date": "",
            "desc": "",
            "amount": "",
            "weight": ""
        },
        "detail": {
            "origin": "Genteng, Kota Surabaya, Jawa Timur",
            "destination": "Krian, Kab. Sidoarjo, Jawa Timur",
            "shipper": "Anonymous Store",
            "receiver": "Anonymous"
        },
        "history": [
            {
                "date": "22 Agu 16:10 WIB",
                "desc": "Yay, pesanan sudah sampai dan diterima oleh Anonymous; Yang bersangkutan. [KURIR: ID EXPRESS]",
                "location": "SIDOARJO"
            },
            {
                "date": "22 Agu 13:13 WIB",
                "desc": "Kurir Airlangga Giri Nugroho sudah ditugaskan dan pesanan akan segera diantar ke pembeli. [KURIR: ID EXPRESS]",
                "location": "SIDOARJO"
            },
            {
                "date": "22 Agu 08:42 WIB",
                "desc": "Kurir SUMARSONO sudah ditugaskan dan pesanan akan segera diantar ke pembeli. [KURIR: ID EXPRESS]",
                "location": "SIDOARJO"
            },
            {
                "date": "22 Agu 06:32 WIB",
                "desc": "Pesanan sampai di sorting center SIDOARJO (TH WONOAYU). [KURIR: ID EXPRESS]",
                "location": "SIDOARJO"
            },
            {
                "date": "21 Agu 22:56 WIB",
                "desc": "Pesanan sampai di sorting center SIDOARJO (MH SURABAYA). [KURIR: ID EXPRESS]",
                "location": "SIDOARJO"
            },
            {
                "date": "21 Agu 17:24 WIB",
                "desc": "Pesanan sudah di-pickup oleh kurir Astuti Wulandari. [KURIR: ID EXPRESS]",
                "location": "SURABAYA"
            },
            {
                "date": "21 Agu 17:24 WIB",
                "desc": "Paket telah drop off di TH BUBUTAN. [KURIR: ID EXPRESS]",
                "location": "SURABAYA"
            }
        ]
    }
}