Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a rate limit error response in REST APIs?
A rate limit error response is a message from the server telling the client it has sent too many requests in a short time and must wait before sending more.
Click to reveal answer
beginner
Which HTTP status code is commonly used for rate limit errors?
The HTTP status code 429 means "Too Many Requests" and is used to indicate rate limit errors.
Click to reveal answer
intermediate
What header can servers include to tell clients when to retry after a rate limit error?
Servers often include the "Retry-After" header with a time in seconds or a date to tell clients when they can try again.
Click to reveal answer
beginner
Why do APIs use rate limiting?
APIs use rate limiting to protect the server from too many requests, avoid overload, and ensure fair use for all clients.
Click to reveal answer
beginner
What should a client do after receiving a 429 rate limit error?
The client should stop sending requests temporarily and wait for the time specified in the "Retry-After" header before trying again.
Click to reveal answer
What HTTP status code indicates a rate limit error?
A404
B429
C500
D200
✗ Incorrect
429 means "Too Many Requests" and signals a rate limit error.
Which header tells you when to retry after hitting a rate limit?
ARetry-After
BContent-Type
CAuthorization
DUser-Agent
✗ Incorrect
The "Retry-After" header tells the client how long to wait before retrying.
Why do APIs limit the number of requests from clients?
ATo protect the server from overload
BTo block all users
CTo slow down users
DTo increase server costs
✗ Incorrect
Rate limiting protects the server from too many requests and keeps it stable.
What should a client do after receiving a 429 error?
AChange the API endpoint
BIgnore the error
CKeep sending requests immediately
DWait and retry after the specified time
✗ Incorrect
Clients should wait as instructed before sending more requests.
Which of these is NOT a reason for rate limiting?
APrevent server overload
BEnsure fair use
CIncrease server response time
DImprove server security by blocking hackers
✗ Incorrect
Rate limiting aims to reduce server load and improve response time, not increase it.
Explain what a rate limit error response is and how a client should handle it.
Think about what happens when you send too many requests too fast.
You got /4 concepts.
Why do APIs implement rate limiting and what benefits does it bring?
Consider how a busy server stays healthy and fair.
You got /4 concepts.
Practice
(1/5)
1. What HTTP status code is commonly used to indicate a rate limit error in REST APIs?
easy
A. 404
B. 429
C. 500
D. 401
Solution
Step 1: Understand HTTP status codes for errors
HTTP status codes in the 400 range indicate client errors. Among them, 429 specifically means too many requests.
Step 2: Identify the code for rate limiting
The 429 status code is defined to signal that the user has sent too many requests in a given time.
Final Answer:
429 -> Option B
Quick Check:
Rate limit error = 429 [OK]
Hint: Remember 429 means too many requests, a rate limit error [OK]
Common Mistakes:
Confusing 429 with 404 (not found)
Using 500 which is server error
Choosing 401 which means unauthorized
2. Which HTTP header is used to tell the client when to retry after hitting a rate limit?
easy
A. Retry-After
B. Authorization
C. Content-Type
D. User-Agent
Solution
Step 1: Identify headers related to retry timing
The Retry-After header is designed to tell clients how long to wait before retrying a request.
Step 2: Confirm the correct header for rate limit retry
Other headers like Content-Type or Authorization do not indicate retry timing.
Final Answer:
Retry-After -> Option A
Quick Check:
Retry timing header = Retry-After [OK]
Hint: Retry-After header tells when to retry after rate limit [OK]
Common Mistakes:
Choosing Content-Type which describes data format
Confusing Authorization with retry info
Selecting User-Agent which identifies client software
3. What will the following HTTP response indicate?
HTTP/1.1 429 Too Many Requests
Retry-After: 120
Content-Type: application/json
{"error": "Rate limit exceeded. Try again later."}
medium
A. The client should retry immediately
B. The client is unauthorized
C. The server encountered an internal error
D. The client sent too many requests and should wait 120 seconds before retrying
Solution
Step 1: Analyze the status code and headers
Status 429 means too many requests. The Retry-After header with value 120 means wait 120 seconds before retrying.
Step 2: Interpret the JSON error message
The message confirms the rate limit was exceeded and advises to try again later.
Final Answer:
The client sent too many requests and should wait 120 seconds before retrying -> Option D
Quick Check:
429 + Retry-After = wait before retry [OK]
Hint: 429 plus Retry-After means wait specified seconds before retry [OK]
Common Mistakes:
Thinking client can retry immediately
Confusing 429 with unauthorized error
Assuming server error from 429
4. A REST API returns this response when rate limit is exceeded:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
{"error": "Too many requests"}
What is missing to improve client handling?
medium
A. A Retry-After header indicating when to retry
B. Changing status code to 500
C. Adding Authorization header
D. Removing the error message
Solution
Step 1: Identify missing headers for rate limit response
The response lacks the Retry-After header, which helps clients know when to retry.
Step 2: Understand why Retry-After is important
Without Retry-After, clients may retry too soon, causing more errors or confusion.
Final Answer:
A Retry-After header indicating when to retry -> Option A
Quick Check:
Retry-After header missing = add it [OK]
Hint: Add Retry-After header to guide client retry timing [OK]
Common Mistakes:
Changing status code to 500 which is wrong
Adding Authorization header unrelated to rate limit
Removing error message reduces clarity
5. 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
A. Return status 200 with a JSON error field indicating rate limit
B. Return status 403 with a plain text message 'Rate limit exceeded'
C. Return status 429 with a Retry-After header and a JSON message explaining the limit
D. Return status 500 with a Retry-After header
Solution
Step 1: Choose correct status code for rate limiting
Status 429 is the standard code for rate limit errors, signaling client to slow down.
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.
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.
Final Answer:
Return status 429 with a Retry-After header and a JSON message explaining the limit -> Option C
Quick Check:
429 + Retry-After + clear message = best practice [OK]
Hint: Use 429 + Retry-After + clear JSON message for best rate limit response [OK]