Dokumentasi API
Users
Users Endpoint
info: Mendapatkan informasi terkait pengguna.
- Base URL
- Get All Users
- Get User By Id
- Get Profile
- Update Profile
- Change Photo Profile
- Change Password
Base URL
https://open-api.delcom.org/api/v1
Get All Users
Mengambil daftar seluruh pengguna yang terdaftar di sistem.
- URL
/users
- Method
- GET
- Headers
Authorization:Bearer <token>
- Contoh Request
GET {{BaseURL}}/users Accept: application/json Authorization: Bearer <token> - Response Berhasil
{ "status": "success", "message": "Berhasil mengambil data", "data": { "users": [ { "id": 3, "name": "Abdullah Ubaid", "email": "ifs18004@delcom.org", "email_verified_at": null, "photo": "http://127.0.0.1:8000/default/img/user.png", "created_at": "2024-10-05T03:26:57.000000Z", "updated_at": "2024-10-05T03:26:57.000000Z" }, { "id": 2, "name": "Abdullah Ubaid", "email": "ifs18005@delcom.org", "email_verified_at": null, "photo": "http://127.0.0.1:8000/img/profile/2_1728103215.jpeg", "created_at": "2024-10-05T03:18:14.000000Z", "updated_at": "2024-10-05T04:40:15.000000Z" }, { "id": 1, "name": "Delcom Testing", "email": "testing@delcom.org", "email_verified_at": null, "photo": "http://127.0.0.1:8000/default/img/user.png", "created_at": "2024-10-05T02:53:38.000000Z", "updated_at": "2024-10-05T02:53:38.000000Z" } ] } } - Response Gagal
{ "status": "fail", "message": "Data tidak valid", "data": { "field": [ "Pesan validasi" ] } }
Get User By Id
Mendapatkan informasi detail data pengguna berdasarkan ID spesifik.
- URL
/users/:id
- Method
- GET
- Headers
Authorization:Bearer <token>
- Contoh Request
GET {{BaseURL}}/users/1 Accept: application/json Authorization: Bearer <token> - Response Berhasil
{ "status": "success", "message": "Berhasil mengambil data", "data": { "user": { "id": 2, "name": "Abdullah Ubaid", "email": "ifs18005@delcom.org", "email_verified_at": null, "photo": "http://127.0.0.1:8000/default/img/user.png", "created_at": "2024-10-05T03:18:14.000000Z", "updated_at": "2024-10-05T03:18:14.000000Z" } } } - Response Gagal
{ "status": "fail", "message": "Data tidak valid", "data": { "field": [ "Pesan validasi" ] } }
Get Profile
Mengambil informasi profil dari pengguna yang sedang login.
- URL
/users/me
- Method
- GET
- Headers
Authorization:Bearer <token>
- Contoh Request
GET {{BaseURL}}/users/me Accept: application/json Authorization: Bearer <token> - Response Berhasil
{ "status": "success", "message": "Berhasil mengambil data", "data": { "user": { "id": 3, "name": "Abdullah Ubaid", "email": "ifs18005@del.ac.id", "email_verified_at": null, "photo": "img/profile/3_1709251633.png", "created_at": "2024-02-29T23:46:32.000000Z", "updated_at": "2024-03-01T00:07:13.000000Z" } } } - Response Gagal
{ "status": "fail", "message": "Data tidak valid", "data": { "field": [ "Pesan validasi" ] } }
Update Profile
Memperbarui informasi profil pengguna yang sedang login (seperti nama).
- URL
/users/me
- Method
- PUT
- Headers
Content-Type:application/jsonAuthorization:Bearer <token>
- Request Body
nameasstringemailasstring
- Contoh Request
PUT {{BaseURL}}/users/me Accept: application/json Authorization: Bearer <token> Content-Type: application/json { "name": "Delcom Testing", "email": "testing@delcom.org" } - Response Berhasil
{ "status": "success", "message": "Berhasil mengubah data", "data": { "user": { "id": 1, "name": "Abdullah", "email": "ifs18005@del.ac.id", "email_verified_at": null, "photo": "img/profile/1_1709107233.png", "created_at": "2024-02-28T04:11:30.000000Z", "updated_at": "2024-10-05T01:21:09.000000Z" } } } - Response Gagal
{ "status": "fail", "message": "Data tidak valid", "data": { "field": [ "Pesan validasi" ] } }
Change Photo Profile
Mengunggah dan memperbarui foto profil pengguna yang sedang login.
- URL
/users/me/photo
- Method
- POST
- Headers
Content-Type:multipart/form-dataAuthorization:Bearer <token>
- Request Body
photoasfile
- Contoh Request
POST {{BaseURL}}/users/me/photo Accept: application/json Authorization: Bearer <token> Content-Type: multipart/form-data; boundary=----DelcomFormBoundary ------DelcomFormBoundary Content-Disposition: form-data; name="photo"; filename="photo.png" Content-Type: image/png < ./photo.png ------DelcomFormBoundary-- - Catatan: gunakan POST (bukan PUT) agar file ter-parse di PHP. Alias lama:
POST /users/photo.
Change Password
Mengubah kata sandi akun pengguna yang sedang login.
- URL
/users/password
- Method
- PUT
- Headers
Content-Type:application/jsonAuthorization:Bearer <token>
- Request Body
passwordasstringnew_passwordasstringnew_password_confirmationasstring
- Contoh Request
PUT {{BaseURL}}/users/password Accept: application/json Authorization: Bearer <token> Content-Type: application/json { "password": "123456", "new_password": "654321", "new_password_confirmation": "654321" } - Response Berhasil
{ "status": "success", "message": "Berhasil mengubah kata sandi" } - Response Gagal
{ "status": "fail", "message": "Data tidak valid", "data": { "field": [ "Pesan validasi" ] } }