City

Dokumentasi ini menjelaskan cara mengakses layanan API GoTravelly untuk method City.

API berfungsi untuk mendapatkan, menambahkan, mengubah, dan menghapus data kota di GoTravelly.

Method & URL

Method URL
GET, POST, PUT, DELETE https://www.gotravelly.com/api/city

Request & Response


GET (Request)

Method Parameter Tipe Wajib Keterangan
GET/HEADER key String Tidak Token code / key
GET/PARAM id String Tidak ID Kota
GET/PARAM state_id String Tidak ID Provinsi
GET/PARAM country_id String Tidak ID Negara
GET/PARAM fields String Tidak Atribut yang ingin didapat (atribut yang tersedia : id, name)
GET/PARAM sorts String Tidak Atribut yang ingin diurutkan (atribut yang tersedia : id atau name)
GET/PARAM sort_type String Tidak Jenis pengurutan yang diinginkan (nilai : ASC atau DESC)
GET/PARAM per_page Integer Ya Jumlah tampilan history balance di per halaman
GET/PARAM page Integer Tidak Halaman / offset data yang ditampilkan (biasanya digenerate otomatis)

Contoh GET (Request):

  • untuk mendapatkan semua data kota
  • https://suksesselalu.gotravelly.com/api/city?per_page=1&page=1(1)
  • untuk mendapatkan semua data kota berdasarkan ID Provinsi
  • https://suksesselalu.gotravelly.com/api/city?state_id=1&per_page=1&page=1(1)
  • untuk mendapatkan semua data kota berdasarkan ID Negara
  • https://suksesselalu.gotravelly.com/api/city?country_id=64&per_page=1&page=1(2)
  • untuk mendapatkan detail kota
  • https://suksesselalu.gotravelly.com/api/city?id=5(1)


    GET (Response)


    Success Response (200)
    [
        {
            "id": "5",
            "name": "Aceh Barat",
            "state_id": "1",
            "lat": "3.74311900",
            "lng": "96.84711500"
        }
    ]
    
    [
        {
            "city_id": "420",
            "city_name": " Maluku Tengah "
        }
    ]
    

    Failed Response (404)
    {
        "status": "ERROR",
        "message": "City could not be found"
    }
    

    POST (Request)

    Method Parameter Tipe Wajib Keterangan
    POST/HEADER key String Ya Token code / key
    POST/BODY name String Ya Nama Kota
    POST/BODY state_id String Ya ID Provinsi

    POST (Response)


    Success Response (201)
    {
        "name": "AA",
        "state_id": "1"
    }
    

    Failed Response (409)
    {
        "status": "CONFLICT",
        "message": "Duplicate city name"
    }
    

    Failed Response (400)
    {
        "status": "FAILED",
        "message": {
            "name": <p>The city name field is required.</p>,
            "state_id": "<p>The state id field is required.</p>"
        }
    }
    

    Atau

    {
        "status": "FAILED",
        "message": {error_message}
    }
    

    PUT (Request)

    Method Parameter Tipe Wajib Keterangan
    PUT/HEADER key String Ya Token code / key
    PUT/BODY id Integer Ya ID Kota yang akan diubah
    PUT/BODY name String Ya Nama Kota
    PUT/BODY state_id String Ya ID Provinsi

    PUT (Response)


    Success Response (200)
    {
        "name": "AAAA",
        "state_id": "1"
    }
    

    Failed Response (409)
    {
        "status": "CONFLICT",
        "message": "Duplicate city name"
    }
    

    Failed Response (400)
    {
        "status": "FAILED",
        "message": {
            "id": "<p>The city id field is required.</p>",
            "name": "<p>The city name field is required.</p>",
            "state_id": "<p>The state id field is required.</p>"
        }
    }
    

    Atau

    {
        "status": "FAILED",
        "message": Failed to update city."
    }
    

    Atau

    {
        "status": "FAILED",
        "message": {error_message}
    }
    

    DELETE (Request)

    Method Parameter Tipe Wajib Keterangan
    DELETE/HEADER key String Ya Token code / key
    DELETE/BODY id String Ya ID Kota yang akan dihapus

    DELETE (Response)


    Success Response (200)
    {
        "status": SUCCESS",
        "message": ""
    }
    

    Failed Response (400)
    {
        "status": "FAILED",
        "message": "City ID is required"
    }