Bird
0
0

You want to design a REST API rate limit error response that clearly informs clients about the wait time and reason. Which of the following is the best practice?

hard📝 Application Q15 of 15
Rest API - Error Handling
You want to design a REST API rate limit error response that clearly informs clients about the wait time and reason. Which of the following is the best practice?
AReturn status 200 with a JSON error field indicating rate limit
BReturn status 403 with a plain text message 'Rate limit exceeded'
CReturn status 429 with a Retry-After header and a JSON message explaining the limit
DReturn status 500 with a Retry-After header
Step-by-Step Solution
Solution:
  1. Step 1: Choose correct status code for rate limiting

    Status 429 is the standard code for rate limit errors, signaling client to slow down.
  2. Step 2: Include Retry-After header and clear message

    Retry-After header tells client how long to wait. JSON message improves clarity and user experience.
  3. Step 3: Evaluate other options

    403 is forbidden, not rate limit. 200 means success, which is misleading. 500 is server error, not client rate limit.
  4. Final Answer:

    Return status 429 with a Retry-After header and a JSON message explaining the limit -> Option C
  5. Quick Check:

    429 + Retry-After + clear message = best practice [OK]
Quick Trick: Use 429 + Retry-After + clear JSON message for best rate limit response [OK]
Common Mistakes:
  • Using wrong status codes like 403 or 500
  • Returning 200 status for errors
  • Omitting Retry-After header

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes