مرجع لـ HTTP وREST مع أمثلة cURL جاهزة للنسخ.
رموز حالة شائعة
- 2xx نجاح: 200 OK، 201 Created، 204 No Content
- 3xx إعادة توجيه: 301 دائم، 302/307 مؤقت
- 4xx خطأ العميل: 400 Bad Request، 401 Unauthorized، 403 Forbidden، 404 Not Found، 422 Unprocessable Entity
- 5xx خطأ الخادم: 500 Internal Server Error، 502 Bad Gateway، 503 Service Unavailable
GET مع رؤوس
curl -sS -D - https://api.example.com/v1/items \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_TOKEN"
POST بصيغة JSON
curl -sS -X POST https://api.example.com/v1/items \
-H "Content-Type: application/json" \
-d '{"title":"hello","done":false}'
رفع ملف (multipart)
curl -sS -X POST https://api.example.com/upload \
-F "file=@./photo.png"
اتباع التحويلات وحفظ ملف
curl -L -o out.bin https://example.com/file
في REST غالباً: GET يقرأ، POST ينشئ، PUT/PATCH يحدّث، DELETE يحذف — حسب تصميم الـ API.