State

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

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

Method & URL

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

Request & Response


GET (Request)

Method Parameter Tipe Wajib Keterangan
GET/HEADER key String Tidak Token code / key
GET/PARAM 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 per halaman
GET/PARAM page Integer Tidak Halaman / offset data yang ditampilkan

Contoh GET (Request):

  • untuk mendapatkan semua data provinsi
  • https://suksesselalu.gotravelly.com/api/state?per_page=1&page=1
  • untuk mendapatkan semua data provinsi berdasarkan ID Negara
  • https://suksesselalu.gotravelly.com/api/state?country_id=64&per_page=1&page=1
  • untuk mendapatkan detail provinsi
  • https://suksesselalu.gotravelly.com/api/state?id=17


    GET (Response)


    Success Response (200)
    [
        {
            "id": "82",
            "name": "Aklan",
            "country_id": "48"
        }
    ]
    

    Failed Response (404)
    {
        "status": "ERROR",
        "message": "State 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 Provinsi
    POST/BODY country_id String Ya ID Negara

    POST (Response)


    Success Response (201)
    {
        "name": "AA",
        "country_id": "64"
    }
    

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

    Failed Response (400)
    {
        "status": "FAILED",
        "message": {
            "name": <p>The state name field is required.</p>,
            "country_id": "<p>The country 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 Provinsi yang akan diubah
    PUT/BODY name String Ya Nama Provinsi
    PUT/BODY country_id String Ya ID Negara

    PUT (Response)


    Success Response (200)
    {
        "name": "AAAA",
        "country_id": "64"
    }
    

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

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

    Atau

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

    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 Provinsi yang akan dihapus

    DELETE (Response)


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

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