Catalog108 / challenges / api/rest/rate-limited

Rate-limited API

intermediate Matching curriculum →

What this challenge teaches

Teaches: 429 + Retry-After header. Read the header and wait.

Expected output: Successfully call ?json=1 5 times; next returns 429 with Retry-After.

Submit your scraper's JSON output to /challenges/api/rest/rate-limited/grade (grader endpoint is part of a later phase; URL is reserved now).

Request 1 / 5 in this 60-second window.

# Respect Retry-After
import requests, time
for i in range(20):
    r = requests.get("https://practice.scrapingcentral.com/challenges/api/rest/rate-limited?json=1")
    if r.status_code == 429:
        wait = int(r.headers.get("Retry-After", "60"))
        time.sleep(wait + 1); continue
    print(r.json())