Panduan API Tugas Software Quality Assurance

Dokumentasi sederhana untuk penggunaan API User berbasis file JSON

1. Struktur API

API ini terdiri dari 5 endpoint utama yang digunakan untuk melakukan operasi CRUD pada data user.

/api/
   users.json
   get_users.php        (GET semua user)
   get_user.php         (GET 1 user)
   create_user.php      (POST user baru)
   update_user.php      (PUT update user)
   delete_user.php      (DELETE user)
            

2. Data Sample (users.json)

[
  { "id": 1, "name": "Novant Nanda Pradana", "no_hp": "081200000001", "email": "novant@example.com", "role": "admin", "password": "$2y$10$aa11bb22cc33dd44ee55", "created_at": "2025-01-01 10:00:00" },
  { "id": 2, "name": "Amar Subekti", "no_hp": "081200000002", "email": "amar@example.com", "role": "user", "password": "$2y$10$ff66gg77hh88ii99jj00", "created_at": "2025-01-02 11:15:00" },
  { "id": 3, "name": "Indra Prakoso", "no_hp": "081200000003", "email": "indra@example.com", "role": "staff", "password": "$2y$10$kk11ll22mm33nn44oo55", "created_at": "2025-01-03 09:45:00" },
  { "id": 4, "name": "Ica", "no_hp": "081200000004", "email": "ica@example.com", "role": "user", "password": "$2y$10$pp66qq77rr88ss99tt00", "created_at": "2025-01-04 14:10:00" },
  { "id": 5, "name": "Rani", "no_hp": "081200000005", "email": "rani@example.com", "role": "manager", "password": "$2y$10$uu11vv22ww33xx44yy55", "created_at": "2025-01-05 16:35:00" },
  { "id": 6, "name": "Mahendra Jecob", "no_hp": "081200000006", "email": "mahendra@example.com", "role": "staff", "password": "$2y$10$zz66aa77bb88cc99dd00", "created_at": "2025-01-06 13:20:00" },
  { "id": 7, "name": "Andika", "no_hp": "081200000007", "email": "andika@example.com", "role": "user", "password": "$2y$10$ee11ff22gg33hh44ii55", "created_at": "2025-01-07 12:40:00" },
  { "id": 8, "name": "Catur", "no_hp": "081200000008", "email": "catur@example.com", "role": "admin", "password": "$2y$10$jj66kk77ll88mm99nn00", "created_at": "2025-01-08 17:55:00" },
  { "id": 9, "name": "Alift", "no_hp": "081200000009", "email": "alift@example.com", "role": "user", "password": "$2y$10$oo11pp22qq33rr44ss55", "created_at": "2025-01-09 08:25:00" },
  { "id": 10, "name": "Absi", "no_hp": "081200000010", "email": "absi@example.com", "role": "staff", "password": "$2y$10$tt66uu77vv88ww99xx00", "created_at": "2025-01-10 11:50:00" }
]
            

3. Endpoint API

🔹 GET Semua User
GET: https://sqa-tugas.qodeid.com/api/get_users.php
🔹 GET User Berdasarkan ID
GET: https://sqa-tugas.qodeid.com/api/get_user.php?id=1
🔹 POST Tambah User
POST: https://sqa-tugas.qodeid.com/api/create_user.php
Body JSON:
  { 
    "id": 1, 
    "name": "Novant Nanda Pradana",
    "no_hp": "081200000001",
    "email": "novant@example.com",
    "role": "admin",
    "password": "$2y$10$aa11bb22cc33dd44ee55",
    "created_at": "2025-01-01 10:00:00"
 },
 { 
    "id": 2,
    "name": "Amar Subekti",
    "no_hp": "081200000002",
    "email": "amar@example.com",
    "role": "user",
    "password": "$2y$10$ff66gg77hh88ii99jj00",
    "created_at": "2025-01-02 11:15:00"
 },
 ----
            
🔹 PUT Update User
PUT: https://sqa-tugas.qodeid.com/api/update_user.php?id=1
Body JSON:
  { 
    "id": 1, 
    "name": "Novant Nanda Pradana",
    "no_hp": "081200000001",
    "email": "novant@example.com",
    "role": "admin",
    "password": "$2y$10$aa11bb22cc33dd44ee55",
    "created_at": "2025-01-01 10:00:00"
 },
            
🔹 DELETE User
DELETE: https://sqa-tugas.qodeid.com/api/delete_user.php?id=4

4. Cara Menguji API di Postman

  1. Buka Postman.
  2. Buat Collection baru.
  3. Tambah request sesuai endpoint API di atas.
  4. Set method (GET/POST/PUT/DELETE).
  5. Masukkan URL API sesuai endpoint.
  6. Jika POST/PUT, masukkan JSON pada tab Body → raw → JSON.
  7. Klik Send.
  8. Cek hasil response di panel bawah Postman.

© 2025 Dokumentasi API User — Tugas Software Quality Assurance