GET

/api/quotes/:id

Mengambil quote spesifik berdasarkan ID.

URL

GET /api/quotes/:id

Path Parameters

ParameterTypeRequiredDescription
idintegerYesID unique dari quote yang ingin diambil

Available IDs: 1-10 (berdasarkan data saat ini)

Example Requests

Get Quote by ID

GET /api/quotes/1

Mengambil quote dengan ID 1

Different Quote IDs

GET /api/quotes/5
GET /api/quotes/10

Setiap ID memberikan quote yang unik dan konsisten

Success Response

200 OK
{
  "status": "SUCCESS",
  "message": "Quote berhasil diambil",
  "data": {
    "id": 1,
    "text": "Hidup itu seperti sepeda. Agar tetap seimbang, kamu harus terus bergerak.",
    "author": "Albert Einstein",
    "category": "motivasi"
  }
}

Error Responses

400 Bad Request
{
  "status": "ERROR",
  "message": "ID harus berupa angka"
}

Terjadi ketika ID bukan angka valid

GET /api/quotes/abc ❌
404 Not Found
{
  "status": "ERROR",
  "message": "Quote tidak ditemukan"
}

Terjadi ketika ID tidak ada dalam database

GET /api/quotes/999 ❌
429 Too Many Requests
{
  "status": "ERROR",
  "message": "Terlalu banyak permintaan. Coba lagi dalam beberapa saat."
}

Rate limit: 30 requests per minute

500 Internal Server Error
{
  "status": "ERROR",
  "message": "Gagal mengambil quote"
}

Common Use Cases

🔗 Direct Link Sharing

Share specific quote via URL

https://yourapp.com/quote/5

📱 Bookmarking System

Save favorite quotes by ID

favoriteQuotes = [1, 5, 8]

🔄 Sequential Display

Show quotes in specific order

for (let i = 1; i <= 10; i++) fetch(`/api/quotes/${i}`)

✅ Data Validation

Check if quote exists before processing

if (response.status === 'SUCCESS') processQuote(data)

Available Quote IDs

1
2
3
4
5
6
7
8
9
10

Setiap ID menghasilkan quote yang sama setiap kali dipanggil (konsisten).

Response Headers

HeaderDescription
X-RateLimit-RemainingSisa requests yang diperbolehkan
X-RateLimit-ResetWaktu reset rate limit (ISO string)