Belajar API v2
REST API latihan untuk mahasiswa yang sedang belajar frontend. Ada data toko online, blog, todo list, data mahasiswa, statistik untuk grafik, sampai endpoint khusus untuk berlatih menangani loading, error, dan upload file. Semua endpoint bisa dicoba langsung dari halaman ini.
https://belajar-api.unama.ac.id/api/v2
[email protected] / password
/api/mahasiswa, /api/login, dll.) tetap berjalan seperti biasa dan tidak berubah. v2 memakai database dan akun yang terpisah.Mulai cepat
Coba request pertama Anda. Untuk web, salin kode ke console browser (F12 → Console). Untuk aplikasi mobile, buka tab Flutter atau Kotlin: di sana ada setup awal yang dipakai oleh semua contoh kode endpoint di bawah.
# pubspec.yaml
dependencies:
http: ^1.2.2
shared_preferences: ^2.3.2 # untuk menyimpan token
# android/app/src/main/AndroidManifest.xml (wajib untuk build release)
# <uses-permission android:name="android.permission.INTERNET" />
// lib/api.dart
import 'dart:convert';
import 'package:http/http.dart' as http;
const baseUrl = 'https://belajar-api.unama.ac.id/api/v2';
String? token; // isi setelah login, simpan dengan shared_preferences
Future<List<dynamic>> getProducts() async {
final res = await http.get(
Uri.parse('$baseUrl/products?per_page=5'),
headers: {'Accept': 'application/json'},
);
final json = jsonDecode(res.body);
if (res.statusCode >= 400) throw Exception(json['message']);
return json['data'];
}
Future<void> login(String email, String password) async {
final res = await http.post(
Uri.parse('$baseUrl/auth/login'),
headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
body: jsonEncode({'email': email, 'password': password}),
);
final json = jsonDecode(res.body);
if (res.statusCode >= 400) throw Exception(json['message']);
token = json['data']['token']['access_token'];
}
// Tampilkan di UI dengan FutureBuilder:
// FutureBuilder(future: getProducts(), builder: (context, snapshot) { ... })
// build.gradle.kts (Module: app)
implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
// AndroidManifest.xml
// <uses-permission android:name="android.permission.INTERNET" />
// ApiClient.kt — dipakai oleh semua contoh Kotlin di dokumentasi ini
object ApiClient {
var token: String? = null // isi setelah login, simpan di DataStore/SharedPreferences
private val client = OkHttpClient.Builder()
.addInterceptor { chain ->
val request = chain.request().newBuilder()
.header("Accept", "application/json")
token?.let { request.header("Authorization", "Bearer $it") }
chain.proceed(request.build())
}
.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.build()
val api: ApiService = Retrofit.Builder()
.baseUrl("https://belajar-api.unama.ac.id/api/v2/") // harus diakhiri "/"
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(ApiService::class.java)
}
// Contoh login (lihat deklarasi postAuthLogin di endpoint POST /auth/login)
lifecycleScope.launch {
val res = ApiClient.api.postAuthLogin(PostAuthLoginRequest(email = "[email protected]", password = "password"))
if (res.isSuccessful) {
ApiClient.token = res.body()
?.getAsJsonObject("data")
?.getAsJsonObject("token")
?.get("access_token")?.asString
}
}
// Response memakai JsonObject (Gson) agar sederhana. Setelah paham, buat
// data class sendiri, mis. Response<ApiResponse<List<Product>>>.
fetch('https://belajar-api.unama.ac.id/api/v2/products?per_page=5')
.then(res => res.json())
.then(json => {
console.log(json.data); // array produk
console.log(json.meta.total); // total semua produk
});
// <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
const api = axios.create({ baseURL: 'https://belajar-api.unama.ac.id/api/v2' });
const { data } = await api.get('/products', { params: { per_page: 5 } });
console.log(data.data);
async function getProducts() {
try {
const res = await fetch('https://belajar-api.unama.ac.id/api/v2/products?per_page=5');
const json = await res.json();
if (!res.ok) {
// fetch TIDAK melempar error untuk status 4xx/5xx, jadi cek sendiri
throw new Error(json.message);
}
return json.data;
} catch (err) {
alert('Gagal memuat data: ' + err.message);
}
}
Format response
Semua endpoint v2 memakai bentuk response yang sama, jadi Anda cukup membuat satu fungsi untuk membacanya.
Berhasil
{"success": true, "message": "OK", "data": {"id": 1, "name": "..."}}
Berhasil + pagination
{"success": true, "message": "OK", "data": [], "meta": {"current_page": 1, "per_page": 10, "total": 42, "last_page": 5, "from": 1, "to": 10}, "links": {"first": "...", "last": "...", "prev": null, "next": "...?page=2"}}
Gagal
{"success": false, "message": "Produk tidak ditemukan"}
Gagal validasi (422)
{"success": false, "message": "Data yang dikirim tidak valid", "errors": {"email": ["Email wajib diisi."], "password": ["Password minimal berisi 6 karakter."]}}
Kode status & error
| Kode | Arti | Yang sebaiknya dilakukan di frontend |
|---|---|---|
| 200 OK | Berhasil | Tampilkan data |
| 201 Created | Data baru berhasil dibuat | Tampilkan notifikasi sukses, reset form |
| 400 Bad Request | Parameter salah (misal sort tidak dikenal) | Perbaiki request |
| 401 Unauthorized | Token tidak ada, salah, atau kedaluwarsa | Hapus token, arahkan ke halaman login |
| 403 Forbidden | Sudah login tapi tidak berhak | Tampilkan pesan "tidak diizinkan" |
| 404 Not Found | Data atau endpoint tidak ditemukan | Tampilkan halaman/komponen "tidak ditemukan" |
| 409 Conflict | Aksi bentrok dengan status data (misal bayar pesanan yang sudah dibatalkan) | Tampilkan message |
| 422 Unprocessable | Validasi gagal | Tampilkan errors[field][0] di bawah tiap input |
| 429 Too Many Requests | Melebihi batas request (120/menit; login & register 10/menit) | Tunggu sesuai header Retry-After |
| 500 Server Error | Kesalahan di server | Tampilkan pesan umum + tombol "Coba lagi" |
Ingin mencoba semua kode di atas? Gunakan GET /playground/status/{code}.
Pagination, filter & sort
Endpoint daftar (list) mendukung parameter yang sama sehingga mudah dibuat komponen tabel atau katalog yang reusable.
| Parameter | Contoh | Keterangan |
|---|---|---|
| page | ?page=2 | Halaman ke-n. Baca meta.last_page untuk jumlah halaman. |
| per_page | ?per_page=20 | 1–100 data per halaman. |
| q | ?q=laptop | Kata kunci pencarian. Gunakan debounce ±300ms saat user mengetik. |
| sort | ?sort=-price,name | Urutkan. Tanda - = menurun (descending). Bisa lebih dari satu. |
| include | ?include=category | Sertakan data relasi agar tidak perlu request tambahan. |
| filter | ?category=buku&in_stock=true | Filter khusus tiap endpoint, beberapa nilai dipisah koma. |
| paginate=cursor | /posts?paginate=cursor | Cursor pagination untuk infinite scroll (lihat GET /posts). |
Alur autentikasi
v2 memakai Bearer Token. Login sekali, simpan token, lalu kirim token di header setiap request yang membutuhkan login.
// 1. Login
const res = await fetch('https://belajar-api.unama.ac.id/api/v2/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: '[email protected]', password: 'password' })
});
const json = await res.json();
localStorage.setItem('token', json.data.token.access_token);
// 2. Request yang butuh login
const todos = await fetch('https://belajar-api.unama.ac.id/api/v2/todos', {
headers: { Authorization: 'Bearer ' + localStorage.getItem('token') }
}).then(r => r.json());
// 3. Jika dapat 401 → token tidak berlaku, minta user login ulang
// 4. Logout
await fetch('https://belajar-api.unama.ac.id/api/v2/auth/logout', { method: 'POST', headers: { Authorization: 'Bearer ' + localStorage.getItem('token') } });
localStorage.removeItem('token');
Ide proyek latihan
Pilih sesuai level. Setiap ide sudah ada endpoint-nya.
Quote Generator Dasar
Tampilkan quote acak dan tombol "Quote lain". Tambahkan tombol salin & bagikan.
Katalog Produk Dasar
Grid kartu produk dengan harga coret saat diskon, badge "Habis", dan halaman detail.
Tabel Data Mahasiswa Dasar
Tabel dengan pencarian, filter prodi/status, klik header untuk sort, dan pagination.
Todo App Dasar
Login, tambah, centang, edit, hapus todo. Tampilkan progress bar dari statistik.
Blog Infinite Scroll Menengah
Muat artikel otomatis saat scroll ke bawah, filter per tag, halaman detail + komentar.
Dashboard Admin Menengah
Kartu ringkasan, grafik garis penjualan per tahun, dan pie chart mahasiswa per prodi.
Form Registrasi + Profil Menengah
Validasi di frontend & tampilkan error 422 dari server. Upload foto profil dengan preview.
Toko Online Lengkap Lanjut
Keranjang dengan badge jumlah, checkout, simulasi bayar, riwayat & detail pesanan, wishlist.
Penanganan Error & Loading Semua level
Skeleton loading, tombol retry, batalkan request dengan AbortController, toast error.
Autentikasi Menengah
Registrasi, login, dan pengelolaan akun memakai Bearer Token. Setelah login, simpan nilai token.access_token, lalu kirim di setiap request sebagai header Authorization: Bearer {token}. Token berlaku 7 hari (30 hari jika remember: true).
Membuat akun baru dan langsung mengembalikan token, jadi user tidak perlu login lagi.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| name wajib | string | Nama lengkap (3-100 karakter) | Budi Santoso |
| email wajib | string | Email unik | [email protected] |
| password wajib | string | Minimal 6 karakter | rahasia123 |
| password_confirmation wajib | string | Harus sama dengan password | rahasia123 |
| phone | string | Nomor HP | 081234567890 |
Contoh kode
Contoh response 201
{"success":true,"message":"Registrasi berhasil","data":{"user":{"name":"Budi Santoso","email":"[email protected]","phone":"081234567890","updated_at":"2026-10-24T01:25:52.000000Z","created_at":"2026-10-24T01:25:52.000000Z","id":4,"avatar_url":"https://ui-avatars.com/api/?background=random&name=Budi+Santoso"},"token":{"access_token":"9|eUT6rax3VojeCYUgyRFvlSNfXMPzlHxhcQbkwaMETAf68t8n5Jl0b1HpTzF8","token_type":"Bearer","expires_at":"2026-10-31T08:25:52+07:00"}}}Coba langsung
Tukar email & password dengan token. Gunakan akun demo [email protected] / password untuk mencoba.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| email wajib | string | [email protected] | |
| password wajib | string | Password | password |
| device_name | string | Nama perangkat (untuk daftar sesi) | chrome-laptop |
| remember | boolean | true = token berlaku 30 hari | false |
Contoh kode
Contoh response 200
{"success":true,"message":"Login berhasil","data":{"user":{"id":4,"name":"Budi Santoso","email":"[email protected]","phone":"081234567890","bio":null,"avatar":null,"created_at":"2026-10-24T01:25:52.000000Z","updated_at":"2026-10-24T01:25:52.000000Z","avatar_url":"https://ui-avatars.com/api/?background=random&name=Budi+Santoso"},"token":{"access_token":"10|RIkx05PkGtEhJRzYWx0xHCKo7Z0FjG3mlcAzAifo20FQZEGlxnNF3MmZVtpd","token_type":"Bearer","expires_at":"2026-10-31T08:25:52+07:00"}}}Coba langsung
Mengembalikan data user pemilik token beserta jumlah todo, pesanan, favorit, dan isi keranjang.
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":4,"name":"Budi Santoso","email":"[email protected]","phone":"081234567890","bio":"Belajar frontend setiap hari.","avatar":null,"created_at":"2026-10-24T01:25:52.000000Z","updated_at":"2026-10-24T01:25:57.000000Z","todos_count":0,"orders_count":1,"favorites_count":0,"cart_items_count":0,"avatar_url":"https://ui-avatars.com/api/?background=random&name=Budi+Santoso"}}Coba langsung
Kirim hanya field yang ingin diubah. Bisa juga memakai method PATCH.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| name | string | Nama baru | Budi S. |
| string | Email baru (unik) | ||
| phone | string | Nomor HP | 089876543210 |
| bio | string | Bio singkat (maks 500) | Belajar frontend setiap hari. |
Contoh kode
Contoh response 200
{"success":true,"message":"Profil berhasil diperbarui","data":{"id":4,"name":"Budi Santoso","email":"[email protected]","phone":"081234567890","bio":"Belajar frontend setiap hari.","avatar":null,"created_at":"2026-10-24T01:25:52.000000Z","updated_at":"2026-10-24T01:25:52.000000Z","avatar_url":"https://ui-avatars.com/api/?background=random&name=Budi+Santoso"}}Coba langsung
Upload gambar dengan FormData. Jangan set header Content-Type secara manual, biarkan browser yang mengisinya.
Body (multipart/form-data)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| avatar wajib | file | Gambar jpg/png/webp, maks 2MB |
Contoh kode
Contoh response 200
{"success":true,"message":"Foto profil berhasil diunggah","data":{"id":4,"name":"Budi Santoso","email":"[email protected]","phone":"081234567890","bio":"Belajar frontend setiap hari.","avatar":"/storage/v2/avatars/Npox8qzMfDAqgnO9YUIVuwosGrockZ4RDqkLnK79.png","created_at":"2026-10-24T01:25:52.000000Z","updated_at":"2026-10-24T01:25:52.000000Z","avatar_url":"https://belajar-api.unama.ac.id/storage/v2/avatars/Npox8qzMfDAqgnO9YUIVuwosGrockZ4RDqkLnK79.png"}}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"Foto profil dihapus","data":{"id":4,"name":"Budi Santoso","email":"[email protected]","phone":"081234567890","bio":"Belajar frontend setiap hari.","avatar":null,"created_at":"2026-10-24T01:25:52.000000Z","updated_at":"2026-10-24T01:25:53.000000Z","avatar_url":"https://ui-avatars.com/api/?background=random&name=Budi+Santoso"}}Coba langsung
Setelah berhasil, semua token lain milik user dicabut (perangkat lain otomatis logout).
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| current_password wajib | string | Password saat ini | password |
| password wajib | string | Password baru (min 6, beda dari lama) | passwordbaru |
| password_confirmation wajib | string | Ulangi password baru | passwordbaru |
Contoh kode
Contoh response 200
{"success":true,"message":"Password berhasil diubah. Sesi di perangkat lain telah dikeluarkan.","data":null}Coba langsung
Membuat token baru dan langsung membatalkan token yang sedang dipakai.
Contoh kode
Contoh response 200
{"success":true,"message":"Token baru berhasil dibuat, token lama tidak berlaku lagi","data":{"token":{"access_token":"11|SVSgUVQLwClqRRNCiBdm7q063romBwgbDwBx46YjwT9BT63feNZu9g2mACTu","token_type":"Bearer","expires_at":"2026-10-31T08:25:53+07:00"}}}Coba langsung
Semua token aktif milik user. is_current menandai token yang sedang dipakai.
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":9,"name":"web","is_current":false,"last_used_at":null,"expires_at":"2026-10-31T01:25:52.000000Z","created_at":"2026-10-24T01:25:52.000000Z"},{"id":10,"name":"chrome-laptop","is_current":true,"last_used_at":"2026-10-24T01:25:52.000000Z","expires_at":"2026-10-31T01:25:52.000000Z","created_at":"2026-10-24T01:25:52.000000Z"}]}Coba langsung
Mencabut token yang sedang dipakai. Hapus juga token dari localStorage di sisi frontend.
Contoh kode
Contoh response 200
{"success":true,"message":"Logout berhasil","data":null}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"Berhasil logout dari semua perangkat","data":{"revoked":1}}Coba langsung
Menghapus akun beserta semua datanya. Akun demo tidak bisa dihapus.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| password wajib | string | Konfirmasi password |
Contoh kode
Contoh response 200
{"success":true,"message":"Akun berhasil dihapus","data":null}Coba langsung
Produk & Kategori Dasar
Katalog toko online. Cocok untuk latihan halaman daftar produk, pencarian, filter, sorting, pagination, dan halaman detail.
Semua kategori beserta jumlah produknya (products_count).
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":3,"name":"Buku","slug":"buku","description":"Buku pelajaran, novel, dan referensi","icon":"book","created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z","products_count":7},{"id":1,"name":"Elektronik","slug":"elektronik","description":"Laptop, HP, dan aksesoris gadget","icon":"laptop","created_at":"2026-10-24T01:20:51.000000Z","updated_at":"2026-10-24T01:20:51.000000Z","products_count":7}]}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| slug wajib | string | Slug atau ID kategori | elektronik |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":1,"name":"Elektronik","slug":"elektronik","description":"Laptop, HP, dan aksesoris gadget","icon":"laptop","created_at":"2026-10-24T01:20:51.000000Z","updated_at":"2026-10-24T01:20:51.000000Z","products_count":7}}Coba langsung
Mendukung pencarian, filter, sorting, pagination, dan include relasi. Semua parameter bisa digabung.
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| q | string | Cari di nama, brand, deskripsi | laptop |
| category | string | Slug/ID kategori, bisa lebih dari satu dipisah koma | elektronik,buku |
| brand | string | Filter brand (pisah koma) | Asus |
| min_price | integer | Harga minimal | 100000 |
| max_price | integer | Harga maksimal | 1000000 |
| min_rating | number | Rating minimal (0-5) | 4 |
| in_stock | boolean | true = hanya yang ada stok, false = yang habis | true |
| featured | boolean | Hanya produk unggulan | true |
| discount | boolean | Hanya produk yang sedang diskon | true |
| sort | string | id, name, price, rating, sold, stock, discount_percent, created_at. Awali "-" untuk descending | -sold |
| include | string | Sertakan relasi: category, reviews | category |
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":24,"category_id":4,"name":"Teh Kayu Aro Premium","slug":"teh-kayu-aro-premium","brand":"Kayu Aro","description":"Teh Kayu Aro Premium merupakan salah satu produk unggulan Kayu Aro yang banyak diminati. Desain modern dan ringkas, cocok untuk mahasiswa maupun pekerja. Cocok dijadikan hadiah untuk keluarga atau tem...","price":45000,"discount_percent":25,"stock":75,"rating":4.4,"sold":2459,"image":"https://picsum.photos/seed/teh-kayu-aro-premium/600/600","is_featured":true,"created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z","final_price":33750,"in_stock":true,"category":{"id":4,"name":"Makanan & Minuman","slug":"makanan-minuman","description":"Camilan, kopi, dan oleh-oleh khas","icon":"coffee","created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z"}},{"id":29,"category_id":5,"name":"Rice Cooker Digital 1.8L","slug":"rice-cooker-digital-18l","brand":"Miyako","description":"Dapatkan Rice Cooker Digital 1.8L original dari Miyako dengan kualitas terbaik. Desain modern dan ringkas, cocok untuk mahasiswa maupun pekerja. Cocok dijadikan hadiah untuk keluarga atau teman. Harga...","price":449000,"discount_percent":5,"stock":25,"rating":4.4,"sold":2423,"image":"https://picsum.photos/seed/rice-cooker-digital-18l/600/600","is_featured":false,"created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z","final_price":426550,"in_stock":true,"category":{"id":5,"name":"Rumah Tangga","slug":"rumah-tangga","description":"Perlengkapan rumah dan dapur","icon":"home","created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z"}}],"meta":{"current_page":1,"per_page":4,"total":42,"last_page":11,"from":1,"to":4},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/products?include=category&sort=-sold&per_page=4&page=1","last":"https://belajar-api.unama.ac.id/api/v2/products?include=category&sort=-sold&per_page=4&page=11","prev":null,"next":"https://belajar-api.unama.ac.id/api/v2/products?include=category&sort=-sold&per_page=4&page=2"}}Coba langsung
Untuk mengisi pilihan filter brand (checkbox/dropdown).
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"brand":"Alexandre Christie","products_count":1,"final_price":0,"in_stock":false},{"brand":"Andi Offset","products_count":1,"final_price":0,"in_stock":false}]}Coba langsung
Termasuk kategori, jumlah ulasan, rating_breakdown (jumlah per bintang), dan 4 produk related.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | string | ID atau slug produk | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":1,"category_id":1,"name":"Laptop Pro 14 inci Ryzen 7","slug":"laptop-pro-14-inci-ryzen-7","brand":"Asus","description":"Laptop Pro 14 inci Ryzen 7 merupakan salah satu produk unggulan Asus yang banyak diminati. Desain modern dan ringkas, cocok untuk mahasiswa maupun pekerja. Bergaransi resmi dan sudah melalui pengeceka...","price":12999000,"discount_percent":0,"stock":0,"rating":4.6,"sold":222,"image":"https://picsum.photos/seed/laptop-pro-14-inci-ryzen-7/600/600","is_featured":false,"created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z","reviews_count":5,"rating_breakdown":{"5":3,"4":2,"3":0,"2":0,"1":0},"related":[{"id":6,"category_id":1,"name":"Monitor 24 inci IPS 75Hz","slug":"monitor-24-inci-ips-75hz","brand":"LG","description":"Monitor 24 inci IPS 75Hz dari LG hadir untuk memenuhi kebutuhan Anda sehari-hari. Mudah digunakan bahkan untuk pemula. Desain modern dan ringkas, cocok untuk mahasiswa maupun pekerja. Dikemas dengan a...","price":1899000,"discount_percent":0,"stock":25,"rating":4,"sold":893,"image":"https://picsum.photos/seed/monitor-24-inci-ips-75hz/600/600","is_featured":true,"created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z","final_price":1899000,"in_stock":true},{"id":5,"category_id":1,"name":"Keyboard Mekanikal 75%","slug":"keyboard-mekanikal-75","brand":"Rexus","description":"Keyboard Mekanikal 75% dari Rexus hadir untuk memenuhi kebutuhan Anda sehari-hari. Bergaransi resmi dan sudah melalui pengecekan kualitas. Cocok dijadikan hadiah untuk keluarga atau teman. Harga bersa...","price":689000,"discount_percent":5,"stock":0,"rating":4.2,"sold":809,"image":"https://picsum.photos/seed/keyboard-mekanikal-75/600/600","is_featured":false,"created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z","final_price":654550,"in_stock":false}],"final_price":12999000,"in_stock":false,"category":{"id":1,"name":"Elektronik","slug":"elektronik","description":"Laptop, HP, dan aksesoris gadget","icon":"laptop","created_at":"2026-10-24T01:20:51.000000Z","updated_at":"2026-10-24T01:20:51.000000Z"}}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | string | ID atau slug produk | 1 |
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| rating | integer | Filter bintang 1-5 | 5 |
| sort | string | latest (default) atau oldest | latest |
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":1,"product_id":1,"user_id":null,"reviewer_name":"Wawan Rajasa","rating":5,"comment":"Kurang sesuai ekspektasi, tapi masih bisa dipakai.","created_at":"2026-09-21T19:58:22.000000Z","updated_at":"2026-10-24T01:20:52.000000Z"},{"id":3,"product_id":1,"user_id":null,"reviewer_name":"Paramita Riyanti","rating":4,"comment":"Lumayan, tapi pengiriman agak lama.","created_at":"2026-09-15T09:33:46.000000Z","updated_at":"2026-10-24T01:20:52.000000Z"}],"meta":{"current_page":1,"per_page":5,"total":5,"last_page":1,"from":1,"to":5,"average_rating":4.6},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/products/1/reviews?page=1","last":"https://belajar-api.unama.ac.id/api/v2/products/1/reviews?page=1","prev":null,"next":null}}Coba langsung
Satu user hanya punya satu ulasan per produk. Mengirim lagi akan memperbarui ulasan sebelumnya.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | string | ID atau slug produk | 1 |
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| rating wajib | integer | Bintang 1-5 | 5 |
| comment | string | Isi ulasan | Barang bagus, pengiriman cepat! |
Contoh kode
Contoh response 201
{"success":true,"message":"Ulasan berhasil ditambahkan","data":{"product_id":3,"user_id":4,"rating":5,"comment":"Barang bagus, pengiriman cepat!","reviewer_name":"Budi Santoso","updated_at":"2026-10-24T01:25:56.000000Z","created_at":"2026-10-24T01:25:56.000000Z","id":225}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | string | ID atau slug produk | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Ulasan dihapus","data":null}Coba langsung
Keranjang, Pesanan & Favorit Lanjut
Alur belanja lengkap: tambah ke keranjang → checkout → bayar (simulasi) → lihat riwayat pesanan. Semua endpoint di sini butuh token. Ongkir Rp15.000, gratis jika subtotal ≥ Rp500.000.
Daftar item beserta subtotal, shipping_cost, total, dan total_items (untuk badge di ikon keranjang).
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"items":[{"id":9,"user_id":4,"product_id":3,"quantity":2,"created_at":"2026-10-24T01:25:54.000000Z","updated_at":"2026-10-24T01:25:54.000000Z","subtotal":1438200,"product":{"id":3,"name":"Earbuds TWS Noise Cancelling","slug":"earbuds-tws-noise-cancelling","price":799000,"discount_percent":10,"stock":120,"image":"https://picsum.photos/seed/earbuds-tws-noise-cancelling/600/600","final_price":719100,"in_stock":true}},{"id":10,"user_id":4,"product_id":9,"quantity":2,"created_at":"2026-10-24T01:25:54.000000Z","updated_at":"2026-10-24T01:25:54.000000Z","subtotal":126400,"product":{"id":9,"name":"Kaos Polos Cotton Combed 30s","slug":"kaos-polos-cotton-combed-30s","price":79000,"discount_percent":20,"stock":75,"image":"https://picsum.photos/seed/kaos-polos-cotton-combed-30s/600/600","final_price":63200,"in_stock":true}}],"total_items":4,"subtotal":1564600,"shipping_cost":0,"total":1564600,"free_shipping_min":500000}}Coba langsung
Jika produk sudah ada di keranjang, jumlahnya ditambahkan. Gagal (422) jika melebihi stok.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| product_id wajib | integer | ID produk | 1 |
| quantity | integer | Jumlah (default 1) | 1 |
Contoh kode
Contoh response 201
{"success":true,"message":"Produk ditambahkan ke keranjang","data":{"items":[{"id":9,"user_id":4,"product_id":3,"quantity":1,"created_at":"2026-10-24T01:25:54.000000Z","updated_at":"2026-10-24T01:25:54.000000Z","subtotal":719100,"product":{"id":3,"name":"Earbuds TWS Noise Cancelling","slug":"earbuds-tws-noise-cancelling","price":799000,"discount_percent":10,"stock":120,"image":"https://picsum.photos/seed/earbuds-tws-noise-cancelling/600/600","final_price":719100,"in_stock":true}}],"total_items":1,"subtotal":719100,"shipping_cost":0,"total":719100,"free_shipping_min":500000}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID item keranjang (bukan ID produk) | 1 |
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| quantity wajib | integer | Jumlah baru | 2 |
Contoh kode
Contoh response 200
{"success":true,"message":"Jumlah item diperbarui","data":{"items":[{"id":9,"user_id":4,"product_id":3,"quantity":2,"created_at":"2026-10-24T01:25:54.000000Z","updated_at":"2026-10-24T01:25:54.000000Z","subtotal":1438200,"product":{"id":3,"name":"Earbuds TWS Noise Cancelling","slug":"earbuds-tws-noise-cancelling","price":799000,"discount_percent":10,"stock":120,"image":"https://picsum.photos/seed/earbuds-tws-noise-cancelling/600/600","final_price":719100,"in_stock":true}},{"id":10,"user_id":4,"product_id":9,"quantity":2,"created_at":"2026-10-24T01:25:54.000000Z","updated_at":"2026-10-24T01:25:54.000000Z","subtotal":126400,"product":{"id":9,"name":"Kaos Polos Cotton Combed 30s","slug":"kaos-polos-cotton-combed-30s","price":79000,"discount_percent":20,"stock":75,"image":"https://picsum.photos/seed/kaos-polos-cotton-combed-30s/600/600","final_price":63200,"in_stock":true}}],"total_items":4,"subtotal":1564600,"shipping_cost":0,"total":1564600,"free_shipping_min":500000}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID item keranjang | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Item dihapus dari keranjang","data":{"items":[{"id":10,"user_id":4,"product_id":9,"quantity":2,"created_at":"2026-10-24T01:25:54.000000Z","updated_at":"2026-10-24T01:25:54.000000Z","subtotal":126400,"product":{"id":9,"name":"Kaos Polos Cotton Combed 30s","slug":"kaos-polos-cotton-combed-30s","price":79000,"discount_percent":20,"stock":75,"image":"https://picsum.photos/seed/kaos-polos-cotton-combed-30s/600/600","final_price":63200,"in_stock":true}}],"total_items":2,"subtotal":126400,"shipping_cost":15000,"total":141400,"free_shipping_min":500000}}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"Keranjang dikosongkan","data":{"items":[],"total_items":0,"subtotal":0,"shipping_cost":0,"total":0,"free_shipping_min":500000}}Coba langsung
Mengubah seluruh isi keranjang menjadi pesanan, lalu keranjang dikosongkan. Metode cod langsung berstatus paid, lainnya pending.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| recipient_name wajib | string | Nama penerima | Budi Santoso |
| phone wajib | string | No. HP penerima | 081234567890 |
| address wajib | string | Alamat lengkap (min 10 karakter) | Jl. Sumantri Brojonegoro No. 1, Kota Jambi |
| payment_method wajib | string | transfer, cod, atau ewallet | transfer |
| note | string | Catatan untuk penjual | Tolong dibungkus rapi |
Contoh kode
Contoh response 201
{"success":true,"message":"Pesanan berhasil dibuat","data":{"recipient_name":"Budi Santoso","phone":"081234567890","address":"Jl. Sumantri Brojonegoro No. 1, Kota Jambi","payment_method":"transfer","note":"Tolong dibungkus rapi","code":"INV/20261024/B2SVH7","status":"pending","paid_at":null,"subtotal":782300,"shipping_cost":0,"total":782300,"user_id":4,"updated_at":"2026-10-24T01:25:55.000000Z","created_at":"2026-10-24T01:25:55.000000Z","id":3,"items":[{"id":5,"order_id":3,"product_id":3,"product_name":"Earbuds TWS Noise Cancelling","price":719100,"quantity":1,"subtotal":719100,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"},{"id":6,"order_id":3,"product_id":9,"product_name":"Kaos Polos Cotton Combed 30s","price":63200,"quantity":1,"subtotal":63200,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"}]}}Coba langsung
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| status | string | pending, paid, shipped, completed, cancelled (pisah koma) | pending,paid |
| sort | string | id, total, created_at | -created_at |
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":3,"user_id":4,"code":"INV/20261024/B2SVH7","status":"pending","subtotal":782300,"shipping_cost":0,"total":782300,"recipient_name":"Budi Santoso","phone":"081234567890","address":"Jl. Sumantri Brojonegoro No. 1, Kota Jambi","payment_method":"transfer","note":"Tolong dibungkus rapi","paid_at":null,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z","items_count":2}],"meta":{"current_page":1,"per_page":10,"total":1,"last_page":1,"from":1,"to":1},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/orders?page=1","last":"https://belajar-api.unama.ac.id/api/v2/orders?page=1","prev":null,"next":null}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | string | ID pesanan | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":3,"user_id":4,"code":"INV/20261024/B2SVH7","status":"pending","subtotal":782300,"shipping_cost":0,"total":782300,"recipient_name":"Budi Santoso","phone":"081234567890","address":"Jl. Sumantri Brojonegoro No. 1, Kota Jambi","payment_method":"transfer","note":"Tolong dibungkus rapi","paid_at":null,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z","items":[{"id":5,"order_id":3,"product_id":3,"product_name":"Earbuds TWS Noise Cancelling","price":719100,"quantity":1,"subtotal":719100,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"},{"id":6,"order_id":3,"product_id":9,"product_name":"Kaos Polos Cotton Combed 30s","price":63200,"quantity":1,"subtotal":63200,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"}]}}Coba langsung
Ubah status pending → paid. Status lain menghasilkan 409 Conflict.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID pesanan | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Pembayaran berhasil (simulasi)","data":{"id":3,"user_id":4,"code":"INV/20261024/B2SVH7","status":"paid","subtotal":782300,"shipping_cost":0,"total":782300,"recipient_name":"Budi Santoso","phone":"081234567890","address":"Jl. Sumantri Brojonegoro No. 1, Kota Jambi","payment_method":"transfer","note":"Tolong dibungkus rapi","paid_at":"2026-10-24T01:25:55.000000Z","created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z","items":[{"id":5,"order_id":3,"product_id":3,"product_name":"Earbuds TWS Noise Cancelling","price":719100,"quantity":1,"subtotal":719100,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"},{"id":6,"order_id":3,"product_id":9,"product_name":"Kaos Polos Cotton Combed 30s","price":63200,"quantity":1,"subtotal":63200,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"}]}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID pesanan | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Pesanan dibatalkan","data":{"id":3,"user_id":4,"code":"INV/20261024/B2SVH7","status":"cancelled","subtotal":782300,"shipping_cost":0,"total":782300,"recipient_name":"Budi Santoso","phone":"081234567890","address":"Jl. Sumantri Brojonegoro No. 1, Kota Jambi","payment_method":"transfer","note":"Tolong dibungkus rapi","paid_at":"2026-10-24T01:25:55.000000Z","created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z","items":[{"id":5,"order_id":3,"product_id":3,"product_name":"Earbuds TWS Noise Cancelling","price":719100,"quantity":1,"subtotal":719100,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"},{"id":6,"order_id":3,"product_id":9,"product_name":"Kaos Polos Cotton Combed 30s","price":63200,"quantity":1,"subtotal":63200,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"}]}}Coba langsung
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":3,"category_id":1,"name":"Earbuds TWS Noise Cancelling","slug":"earbuds-tws-noise-cancelling","brand":"Xiaomi","description":"Earbuds TWS Noise Cancelling dari Xiaomi hadir untuk memenuhi kebutuhan Anda sehari-hari. Dibuat dari material berkualitas sehingga awet dan tahan lama. Cocok dijadikan hadiah untuk keluarga atau tema...","price":799000,"discount_percent":10,"stock":120,"rating":3.5,"sold":634,"image":"https://picsum.photos/seed/earbuds-tws-noise-cancelling/600/600","is_featured":false,"created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:22:39.000000Z","final_price":719100,"in_stock":true,"category":{"id":1,"name":"Elektronik","slug":"elektronik"},"pivot":{"user_id":4,"product_id":3,"created_at":"2026-10-24T01:25:55.000000Z","updated_at":"2026-10-24T01:25:55.000000Z"}}],"meta":{"current_page":1,"per_page":12,"total":1,"last_page":1,"from":1,"to":1},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/favorites?page=1","last":"https://belajar-api.unama.ac.id/api/v2/favorites?page=1","prev":null,"next":null}}Coba langsung
Aman dipanggil berkali-kali (idempotent).
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| productId wajib | integer | ID produk | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Ditambahkan ke favorit","data":{"product_id":3,"is_favorite":true}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| productId wajib | integer | ID produk | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Dihapus dari favorit","data":{"product_id":3,"is_favorite":false}}Coba langsung
Todo List Dasar
CRUD klasik untuk latihan pertama setelah login. Setiap user hanya bisa melihat dan mengubah todo miliknya sendiri.
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| completed | boolean | true = selesai, false = belum | false |
| priority | string | low, medium, high (pisah koma) | high |
| q | string | Cari judul | belajar |
| overdue | boolean | Hanya yang lewat tenggat | true |
| sort | string | id, title, priority, due_date, completed, created_at | due_date |
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":6,"user_id":4,"title":"Membuat halaman login","description":null,"completed":false,"priority":"medium","due_date":null,"created_at":"2026-10-24T01:25:53.000000Z","updated_at":"2026-10-24T01:25:53.000000Z"},{"id":5,"user_id":4,"title":"Belajar fetch API","description":"Coba GET, POST, PUT, DELETE","completed":false,"priority":"high","due_date":"2026-10-31","created_at":"2026-10-24T01:25:53.000000Z","updated_at":"2026-10-24T01:25:53.000000Z"}],"meta":{"current_page":1,"per_page":10,"total":2,"last_page":1,"from":1,"to":2},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/todos?page=1","last":"https://belajar-api.unama.ac.id/api/v2/todos?page=1","prev":null,"next":null}}Coba langsung
Jumlah total, selesai, belum, terlambat, dan per prioritas. Cocok untuk progress bar.
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"total":2,"completed":1,"pending":1,"overdue":0,"by_priority":{"low":1,"medium":1}}}Coba langsung
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| title wajib | string | Judul (3-255 karakter) | Belajar fetch API |
| description | string | Keterangan | Coba GET, POST, PUT, DELETE |
| priority | string | low, medium (default), high | high |
| due_date | string | Tenggat, format YYYY-MM-DD | 2026-12-31 |
| completed | boolean | Default false | false |
Contoh kode
Contoh response 201
{"success":true,"message":"Todo berhasil ditambahkan","data":{"id":5,"user_id":4,"title":"Belajar fetch API","description":"Coba GET, POST, PUT, DELETE","completed":false,"priority":"high","due_date":"2026-10-31","created_at":"2026-10-24T01:25:53.000000Z","updated_at":"2026-10-24T01:25:53.000000Z"}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID todo | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":5,"user_id":4,"title":"Belajar fetch API","description":"Coba GET, POST, PUT, DELETE","completed":false,"priority":"high","due_date":"2026-10-31","created_at":"2026-10-24T01:25:53.000000Z","updated_at":"2026-10-24T01:25:53.000000Z"}}Coba langsung
PUT = kirim data lengkap (title wajib). Untuk mengubah sebagian field saja, gunakan PATCH ke URL yang sama.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID todo | 1 |
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| title wajib | string | Judul | Belajar fetch API (revisi) |
| description | string | Keterangan | |
| priority | string | low, medium, high | medium |
| due_date | string | YYYY-MM-DD | |
| completed | boolean | Status selesai | true |
Contoh kode
Contoh response 200
{"success":true,"message":"Todo berhasil diperbarui","data":{"id":5,"user_id":4,"title":"Belajar fetch API (revisi)","description":"Coba GET, POST, PUT, DELETE","completed":false,"priority":"medium","due_date":"2026-10-31","created_at":"2026-10-24T01:25:53.000000Z","updated_at":"2026-10-24T01:25:53.000000Z"}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID todo | 1 |
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| priority | string | Contoh: hanya ubah prioritas | low |
Contoh kode
Contoh response 200
{"success":true,"message":"Todo berhasil diperbarui","data":{"id":5,"user_id":4,"title":"Belajar fetch API (revisi)","description":"Coba GET, POST, PUT, DELETE","completed":false,"priority":"low","due_date":"2026-10-31","created_at":"2026-10-24T01:25:53.000000Z","updated_at":"2026-10-24T01:25:53.000000Z"}}Coba langsung
Membalik nilai completed tanpa perlu mengirim body.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID todo | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Todo ditandai selesai","data":{"id":5,"user_id":4,"title":"Belajar fetch API (revisi)","description":"Coba GET, POST, PUT, DELETE","completed":true,"priority":"low","due_date":"2026-10-31","created_at":"2026-10-24T01:25:53.000000Z","updated_at":"2026-10-24T01:25:53.000000Z"}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID todo | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Todo berhasil dihapus","data":null}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"1 todo selesai berhasil dihapus","data":{"deleted":1}}Coba langsung
Blog & Komentar Menengah
Artikel blog dengan dua jenis pagination: berbasis halaman (offset) dan berbasis cursor untuk infinite scroll.
Tambahkan paginate=cursor untuk mode infinite scroll: ambil halaman berikutnya dengan links.next atau cursor={meta.next_cursor} sampai meta.has_more bernilai false.
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| q | string | Cari judul/ringkasan | api |
| category | string | Kategori artikel | JavaScript |
| tag | string | Filter tag | react |
| paginate | string | Isi "cursor" untuk cursor pagination | cursor |
| cursor | string | Nilai meta.next_cursor dari response sebelumnya | |
| sort | string | id, title, views, likes, published_at (mode halaman saja) | -views |
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":30,"title":"Belajar Mandiri: Cara Konsisten Ngoding Setiap Hari","slug":"belajar-mandiri-cara-konsisten-ngoding-setiap-hari","excerpt":"Artikel ini membahas belajar Mandiri: Cara Konsisten Ngoding Setiap Hari. Topik ini berkaitan erat dengan karier dan sangat berguna untuk Anda yang sedang belajar menjadi developer.","cover":"https://picsum.photos/seed/post-belajar-mandiri-cara-konsisten-ngoding-setiap-hari/1200/630","author_name":"Dalima Haryanti","category":"Karier","tags":["karier"],"views":7759,"likes":33,"published_at":"2026-10-23T01:00:00.000000Z","comments_count":2},{"id":29,"title":"Deploy Website Statis Gratis","slug":"deploy-website-statis-gratis","excerpt":"Artikel ini membahas deploy Website Statis Gratis. Topik ini berkaitan erat dengan tools dan sangat berguna untuk Anda yang sedang belajar menjadi developer.","cover":"https://picsum.photos/seed/post-deploy-website-statis-gratis/1200/630","author_name":"Melinda Zahra Nasyidah","category":"Tools","tags":["tools"],"views":1335,"likes":261,"published_at":"2026-10-22T01:00:00.000000Z","comments_count":5}],"meta":{"per_page":3,"has_more":true,"next_cursor":"eyJwdWJsaXNoZWRfYXQiOiIyMDI2LTEwLTIxIDA4OjAwOjAwIiwiaWQiOjI4LCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9","prev_cursor":null},"links":{"next":"https://belajar-api.unama.ac.id/api/v2/posts?paginate=cursor&per_page=3&cursor=eyJwdWJsaXNoZWRfYXQiOiIyMDI2LTEwLTIxIDA4OjAwOjAwIiwiaWQiOjI4LCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9","prev":null}}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"category":"Backend","posts_count":5},{"category":"Frontend","posts_count":5}]}Coba langsung
Diurutkan dari yang paling banyak dipakai. Cocok untuk tag cloud.
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"tag":"api","posts_count":10},{"tag":"javascript","posts_count":7}]}Coba langsung
Isi body berupa HTML. views bertambah setiap dibuka. Ada prev dan next untuk navigasi antar artikel.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| slug wajib | string | Slug atau ID artikel | cara-mengambil-data-dari-api-dengan-fetch |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":4,"title":"Cara Mengambil Data dari API dengan Fetch","slug":"cara-mengambil-data-dari-api-dengan-fetch","excerpt":"Artikel ini membahas cara Mengambil Data dari API dengan Fetch. Topik ini berkaitan erat dengan javascript, api dan sangat berguna untuk Anda yang sedang belajar menjadi developer.","body":"<p>Artikel ini membahas cara Mengambil Data dari API dengan Fetch. Topik ini berkaitan erat dengan javascript, api dan sangat berguna untuk Anda yang sedang belajar menjadi developer.</p><p>Setelah be...","cover":"https://picsum.photos/seed/post-cara-mengambil-data-dari-api-dengan-fetch/1200/630","author_name":"Digdaya Salahudin S.Farm","category":"JavaScript","tags":["javascript","api"],"views":8503,"likes":315,"published_at":"2026-09-27T01:00:00.000000Z","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:22:28.000000Z","comments_count":2,"prev":{"id":3,"title":"Memahami Promise dan Async/Await dengan Mudah","slug":"memahami-promise-dan-asyncawait-dengan-mudah"},"next":{"id":5,"title":"Axios vs Fetch: Perbandingan Lengkap","slug":"axios-vs-fetch-perbandingan-lengkap"}}}Coba langsung
Tanpa login. Latihan optimistic update: tambah angka like di UI dulu, baru kirim request.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| slug wajib | string | Slug atau ID artikel | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Terima kasih sudah menyukai artikel ini","data":{"id":1,"likes":14}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| slug wajib | string | Slug atau ID artikel | 1 |
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":2,"post_id":1,"user_id":null,"name":"Betania Zulaika S.IP","body":"Akhirnya paham juga, makasih.","created_at":"2026-10-06T05:00:00.000000Z","updated_at":"2026-10-24T01:20:53.000000Z"},{"id":5,"post_id":1,"user_id":null,"name":"Gaiman Edi Tampubolon S.Psi","body":"Penjelasannya mudah dipahami.","created_at":"2026-10-06T00:00:00.000000Z","updated_at":"2026-10-24T01:20:53.000000Z"}],"meta":{"current_page":1,"per_page":10,"total":6,"last_page":1,"from":1,"to":6},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/posts/1/comments?page=1","last":"https://belajar-api.unama.ac.id/api/v2/posts/1/comments?page=1","prev":null,"next":null}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| slug wajib | string | Slug atau ID artikel | 1 |
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| body wajib | string | Isi komentar (2-1000 karakter) | Artikelnya sangat membantu! |
Contoh kode
Contoh response 201
{"success":true,"message":"Komentar berhasil dikirim","data":{"body":"Artikelnya sangat membantu!","user_id":4,"name":"Budi Santoso","post_id":1,"updated_at":"2026-10-24T01:25:56.000000Z","created_at":"2026-10-24T01:25:56.000000Z","id":92}}Coba langsung
Menghasilkan 403 jika komentar milik orang lain.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| id wajib | integer | ID komentar | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"Komentar dihapus","data":null}Coba langsung
Mahasiswa & Prodi Dasar
150 data mahasiswa fiktif dengan relasi ke program studi. Cocok untuk latihan tabel data (data table) dengan filter, sorting kolom, dan pagination.
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| q | string | Cari nama atau NIM | putri |
| prodi | string | Kode prodi: TI, SI, SK, MI, MN, AK (pisah koma) | TI,SI |
| status | string | aktif, cuti, lulus, non-aktif | aktif |
| gender | string | L atau P | P |
| entry_year | string | Tahun masuk (pisah koma) | 2024,2025 |
| city | string | Kota asal | Jambi |
| min_gpa | number | IPK minimal | 3.5 |
| max_gpa | number | IPK maksimal | 4 |
| sort | string | id, nim, name, gpa, entry_year, semester, birth_date | -gpa |
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":106,"nim":"20TI0106","name":"Teddy Gaduh Irawan S.Gz","email":"[email protected]","gender":"L","birth_date":"2002-11-28","city":"Jambi","study_program_id":1,"entry_year":2020,"semester":13,"gpa":3.99,"status":"lulus","photo":"https://i.pravatar.cc/300?u=20TI0106","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","study_program":{"id":1,"code":"TI","name":"Teknik Informatika","degree":"S1"}},{"id":34,"nim":"19TI0034","name":"Marsudi Suryono","email":"[email protected]","gender":"L","birth_date":"2002-10-28","city":"Kerinci","study_program_id":1,"entry_year":2019,"semester":14,"gpa":3.99,"status":"non-aktif","photo":"https://i.pravatar.cc/300?u=19TI0034","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","study_program":{"id":1,"code":"TI","name":"Teknik Informatika","degree":"S1"}}],"meta":{"current_page":1,"per_page":5,"total":45,"last_page":9,"from":1,"to":5},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/students?prodi=TI&sort=-gpa&per_page=5&page=1","last":"https://belajar-api.unama.ac.id/api/v2/students?prodi=TI&sort=-gpa&per_page=5&page=9","prev":null,"next":"https://belajar-api.unama.ac.id/api/v2/students?prodi=TI&sort=-gpa&per_page=5&page=2"}}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| nim wajib | string | NIM atau ID | 1 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":1,"nim":"19MI0001","name":"Cici Oktaviani","email":"[email protected]","gender":"P","birth_date":"2002-04-23","city":"Merangin","study_program_id":4,"entry_year":2019,"semester":14,"gpa":3.01,"status":"lulus","photo":"https://i.pravatar.cc/300?u=19MI0001","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","study_program":{"id":4,"code":"MI","name":"Manajemen Informatika","faculty":"Fakultas Ilmu Komputer","degree":"D3","accreditation":"Baik","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z"}}}Coba langsung
Termasuk jumlah mahasiswa dan rata-rata IPK tiap prodi.
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":6,"code":"AK","name":"Akuntansi","faculty":"Fakultas Ekonomi dan Bisnis","degree":"S1","accreditation":"Baik","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","students_count":23,"students_avg_gpa":"3.176087"},{"id":4,"code":"MI","name":"Manajemen Informatika","faculty":"Fakultas Ilmu Komputer","degree":"D3","accreditation":"Baik","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","students_count":13,"students_avg_gpa":"3.421538"}]}Coba langsung
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| code wajib | string | Kode prodi | TI |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":1,"code":"TI","name":"Teknik Informatika","faculty":"Fakultas Ilmu Komputer","degree":"S1","accreditation":"Baik Sekali","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","students_count":45,"students_avg_gpa":"3.312222"}}Coba langsung
Statistik & Grafik Menengah
Data agregat yang formatnya sudah siap untuk library grafik seperti Chart.js, ApexCharts, atau Recharts (labels + values).
Angka-angka untuk kartu ringkasan di dashboard.
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"products":42,"categories":6,"posts":30,"students":150,"active_students":96,"average_gpa":3.29,"total_stock":1009,"total_sold":50827}}Coba langsung
Data dummy per bulan untuk grafik garis/batang. Hasilnya selalu sama untuk tahun yang sama.
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| year | integer | Tahun 2020 s.d. sekarang | 2025 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"year":2026,"labels":["Jan","Feb"],"series":[{"month":1,"label":"Jan","orders":191,"revenue":28268000,"visitors":4584},{"month":2,"label":"Feb","orders":128,"revenue":28416000,"visitors":3712}],"total_revenue":407503000,"total_orders":2233}}Coba langsung
Cocok untuk pie/doughnut chart.
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"labels":["TI","SI"],"values":[45,41],"details":[{"id":1,"code":"TI","name":"Teknik Informatika","faculty":"Fakultas Ilmu Komputer","degree":"S1","accreditation":"Baik Sekali","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","students_count":45},{"id":2,"code":"SI","name":"Sistem Informasi","faculty":"Fakultas Ilmu Komputer","degree":"S1","accreditation":"Baik Sekali","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z","students_count":41}]}}Coba langsung
Dengan rincian laki-laki & perempuan (stacked bar chart).
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"entry_year":2019,"total":16,"male":11,"female":5},{"entry_year":2020,"total":14,"male":8,"female":6}]}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"labels":["lulus","aktif"],"values":[25,96]}}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"labels":["Buku","Elektronik"],"values":[7,7],"details":[{"id":3,"name":"Buku","slug":"buku","description":"Buku pelajaran, novel, dan referensi","icon":"book","created_at":"2026-10-24T01:20:52.000000Z","updated_at":"2026-10-24T01:20:52.000000Z","products_count":7,"products_sum_sold":"9511"},{"id":1,"name":"Elektronik","slug":"elektronik","description":"Laptop, HP, dan aksesoris gadget","icon":"laptop","created_at":"2026-10-24T01:20:51.000000Z","updated_at":"2026-10-24T01:20:51.000000Z","products_count":7,"products_sum_sold":"5566"}]}}Coba langsung
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| limit | integer | Jumlah data (1-20) | 5 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":24,"name":"Teh Kayu Aro Premium","slug":"teh-kayu-aro-premium","sold":2459,"price":45000,"discount_percent":25,"image":"https://picsum.photos/seed/teh-kayu-aro-premium/600/600","rating":4.4,"final_price":33750,"in_stock":false},{"id":29,"name":"Rice Cooker Digital 1.8L","slug":"rice-cooker-digital-18l","sold":2423,"price":449000,"discount_percent":5,"image":"https://picsum.photos/seed/rice-cooker-digital-18l/600/600","rating":4.4,"final_price":426550,"in_stock":false}]}Coba langsung
Quotes Dasar
Kutipan inspiratif. Latihan paling sederhana: satu request GET lalu tampilkan hasilnya.
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| category | string | programming, motivation, education, design, life | programming |
| author | string | Cari nama tokoh | Jobs |
| page | integer | Nomor halaman | 1 |
| per_page | integer | Jumlah data per halaman (1-100) | 10 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":[{"id":1,"text":"Talk is cheap. Show me the code.","author":"Linus Torvalds","category":"programming","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z"},{"id":2,"text":"Programs must be written for people to read, and only incidentally for machines to execute.","author":"Harold Abelson","category":"programming","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z"}],"meta":{"current_page":1,"per_page":10,"total":25,"last_page":3,"from":1,"to":10},"links":{"first":"https://belajar-api.unama.ac.id/api/v2/quotes?page=1","last":"https://belajar-api.unama.ac.id/api/v2/quotes?page=3","prev":null,"next":"https://belajar-api.unama.ac.id/api/v2/quotes?page=2"}}Coba langsung
Hasil berbeda setiap request. Cocok untuk tombol "Quote lain".
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| category | string | Filter kategori |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"id":9,"text":"Experience is the name everyone gives to their mistakes.","author":"Oscar Wilde","category":"life","created_at":"2026-10-24T01:20:53.000000Z","updated_at":"2026-10-24T01:20:53.000000Z"}}Coba langsung
Playground HTTP Semua level
Endpoint khusus untuk mempelajari perilaku HTTP di frontend: loading state, error handling, retry, upload file, dan validasi form.
Mengembalikan method, query, body, file, dan header yang Anda kirim. Menerima semua method (GET/POST/PUT/PATCH/DELETE). Sangat berguna untuk mengecek apakah request sudah terbentuk dengan benar.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| apa_saja | string | Kirim field apa pun | halo |
Contoh kode
Contoh response 200
{"success":true,"message":"Echo dari server","data":{"method":"POST","url":"https://belajar-api.unama.ac.id/api/v2/playground/echo?debug=1","query":{"debug":"1"},"body":{"nama":"Budi","hobi":["ngoding"]},"files":[],"content_type":"application/json","headers":{"authorization":"Bearer 11|SVSgUVQLwClqRRNCiBdm7q063romBwgbDwBx46YjwT9BT63feNZu9g2mACTu","accept":"application/json","content-type":"application/json","user-agent":"GuzzleHttp/7","host":"belajar-api.unama.ac.id"},"ip":"127.0.0.1"}}Coba langsung
Server menunggu sekian milidetik sebelum menjawab (maks 5000). Latihan spinner/skeleton loading dan AbortController.
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| ms wajib | integer | Lama tunggu dalam milidetik | 2000 |
Contoh kode
Contoh response 200
{"success":true,"message":"Respon tertunda 2000 ms","data":{"delay_ms":2000,"time":"2026-10-24T08:25:51+07:00"}}Coba langsung
Mengembalikan kode status pilihan (200, 201, 204, 400, 401, 403, 404, 409, 422, 429, 500, 503, dll). Ingat: fetch tidak melempar error untuk 4xx/5xx, cek response.ok!
Path parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| code wajib | integer | Kode status HTTP | 404 |
Contoh kode
Contoh response 404
{"success":false,"message":"404 Not Found","data":{"status":404}}Coba langsung
Kadang berhasil, kadang 500. Latihan membuat tombol "Coba lagi" atau retry otomatis.
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| fail_rate | integer | Peluang gagal dalam persen (0-100) | 50 |
Contoh kode
Contoh response 200
{"success":true,"message":"Berhasil!","data":{"lucky_number":744}}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"accept":"application/json","user-agent":"GuzzleHttp/7","host":"belajar-api.unama.ac.id","content-length":"","content-type":""}}Coba langsung
Query parameter
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| count | integer | Jumlah (1-50) | 3 |
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":["d4989a59-227d-4327-9fff-691eae202c0c"]}Coba langsung
Contoh kode
Contoh response 200
{"success":true,"message":"OK","data":{"iso":"2026-10-24T08:25:52+07:00","timestamp":1792805152,"date":"2026-10-24","time":"08:25:52","day":"Sabtu","timezone":"Asia/Jakarta"}}Coba langsung
Tidak menyimpan apa pun. Kirim data yang salah untuk melihat format error 422, lalu tampilkan pesan errors di bawah tiap input.
Body (JSON)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| name wajib | string | 3-50 karakter | Budi |
| email wajib | string | Format email | [email protected] |
| age wajib | integer | 17-100 | 20 |
| website | string | URL valid | https://budi.dev |
| gender wajib | string | L atau P | L |
| hobbies | array | Maks 5 item | ["ngoding","membaca"] |
| birth_date | string | YYYY-MM-DD, sebelum hari ini | 2004-05-17 |
| password wajib | string | Min 8, ada huruf besar & angka | Rahasia123 |
| password_confirmation wajib | string | Sama dengan password | Rahasia123 |
| agree wajib | boolean | Harus true (centang syarat & ketentuan) | true |
Contoh kode
Contoh response 422
{"success":false,"message":"Data yang dikirim tidak valid","errors":{"name":["Nama minimal berisi 3 karakter."],"email":["Surel harus berupa alamat surel yang valid."],"age":["Usia harus bernilai antara 17 sampai 100."],"gender":["Jenis kelamin yang dipilih tidak valid."],"password":["Kata sandi minimal berisi 8 karakter.","Password harus mengandung minimal 1 huruf besar dan 1 angka."],"agree":["Agree harus diterima."]}}Coba langsung
Kirim dengan FormData. Maks 2MB (jpg, png, gif, webp, pdf, txt). Cocok untuk latihan preview gambar & progress bar upload.
Body (multipart/form-data)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| file wajib | file | File yang diunggah | |
| description | string | Keterangan | Foto KTM |
Contoh kode
Contoh response 201
{"success":true,"message":"File berhasil diunggah","data":{"original_name":"user.png","size":43361,"mime_type":"image/png","description":"Foto KTM","url":"https://belajar-api.unama.ac.id/storage/v2/uploads/20261024/QsZHqca5j6bNfUSutCSh59lua6tku51usNHDP36J.png"}}Coba langsung
Maks 5 file. Di FormData gunakan nama field files[] untuk setiap file.
Body (multipart/form-data)
| Nama | Tipe | Keterangan | Contoh |
|---|---|---|---|
| files[] wajib | file | Beberapa file sekaligus |
Contoh kode
Contoh response 201
{"success":true,"message":"2 file berhasil diunggah","data":[{"original_name":"user.png","size":43361,"url":"https://belajar-api.unama.ac.id/storage/v2/uploads/20261024/dfhqITkVdkn8cv10b00ze5yx4yGeIh7qFxCN2DkA.png"},{"original_name":"robots.txt","size":24,"url":"https://belajar-api.unama.ac.id/storage/v2/uploads/20261024/spcE1RCUgfSZkF6PzAFuzpmHYYtlgsngriP5otBy.txt"}]}