Lesson 4 of 15
31. Design a URL Shortener

31.3 What are the doors?

3 min read+10 XP

Step 3: API and data model (10 minutes)

POST /api/links body: { "long_url": "https://example.com/some/very/long/page" } returns: 201 Created { "code": "aB3x9Qz", "short_url": "https://sho.rt/aB3x9Qz" } errors: 400 if long_url is not a valid http(s) URL 429 if this client is creating too many links (Chapter 25) GET /{code} returns: 302 Found, Location: https://example.com/some/very/long/page errors: 404 if the code doesn't exist GET /api/links/{code}/stats returns: { "code": "aB3x9Qz", "clicks": 18213, "updated_at": "..." }