Dokumentasi ini menjelaskan cara mengakses layanan API GoTravelly untuk method Country.
API berfungsi untuk mendapatkan, menambahkan, mengubah, dan menghapus data Negara di GoTravelly.
Method | URL |
---|---|
GET, POST, PUT, DELETE | https://www.gotravelly.com/api/country |
GET (Request)
Method | Parameter | Tipe | Wajib | Keterangan |
---|---|---|---|---|
GET/HEADER | key | String | Tidak | Token code / key |
GET/PARAM | id | String | Tidak | ID Negara |
GET/PARAM | continent_id | String | Tidak | ID Benua |
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):
https://suksesselalu.gotravelly.com/api/country?per_page=1&page=1
https://suksesselalu.gotravelly.com/api/country?continent_id=1&per_page=1&page=1
https://suksesselalu.gotravelly.com/api/country?id=1
GET (Response)
[ { "id": "1", "short_code": "AF", "name": "Afghanistan", "timezone": "", "phone_code": "93", "continent_id": "1" } ]
{ "status": "ERROR", "message": "country 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 Negara |
POST/BODY | short_code | String | Ya | Kode Singkat Negara (contoh : Indonesia => ID) |
POST/BODY | timezone | String | Ya | Zona Waktu |
POST/BODY | phone_code | String | Ya | Kode Negara untuk Nomor Telepon |
POST/BODY | continent_id | String | Ya | ID Benua |
POST (Response)
{ "name": "AAA", "short_code": "AA", "timezone": "0", "phone_code": "02", "continent_id": "1" }
{ "status": "CONFLICT", "message": "Duplicate country name" }
{ "status": "FAILED", "message": { "name": "<p>The country name field is required.</p>", "short_code": "<p>The short code field is required.</p>", "timezone": "<p>The timezone field is required.</p>", "phone_code": "<p>The phone code field is required.</p>", "continent_id": "<p>The continent 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 Negara yang akan diubah |
PUT/BODY | name | String | Ya | Nama Negara |
PUT/BODY | short_code | String | Ya | Kode Singkat Negara (contoh : Indonesia => ID) |
PUT/BODY | timezone | String | Ya | Zona Waktu |
PUT/BODY | phone_code | String | Ya | Kode Negara untuk Nomor Telepon |
PUT/BODY | continent_id | String | Ya | ID Benua |
PUT (Response)
{ "name": "AAA", "short_code": "AA", "timezone": "0", "phone_code": "02", "continent_id": "1" }
{ "status": "CONFLICT", "message": "Duplicate country name" }
{ "status": "FAILED", "message": { "id": "<p>The country id field is required.</p>", "name": "<p>The country name field is required.</p>", "short_code": "<p>The short code field is required.</p>", "timezone": "<p>The timezone field is required.</p>", "phone_code": "<p>The phone code field is required.</p>", "continent_id": "<p>The continent id field is required.</p>" } }
Atau
{ "status": "FAILED", "message": Failed to update country." }
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 Negara yang akan dihapus |
DELETE (Response)
{ "status": SUCCESS", "message": "" }
{ "status": "FAILED", "message": "Country ID is required" }