SevyDevy

Design the REST API for Twitter

PremiumAPI designMedium

  • REST API
  • Cursor pagination
  • Rate limiting

Quick answer

This API design interview question asks you to design the REST API for Twitter. Aim for a design that exposes a clear, consistent and safe interface, then explain the resources, requests, responses and error handling. Interviewers want to see how you name resources, version the interface and handle failure cases.

The problem

Design the public REST API for Twitter: the contract the official apps and third-party apps use to post tweets, reply, like, retweet, follow people and read timelines. The hard parts are stable cursor pagination on fast-moving timelines, rate limits per app and per user, and keeping old apps working.

The interviewer wants a contract a developer could code against today: resources, paths, methods, bodies, status codes, pagination, authentication and rate limits.

What must the REST API for Twitter do?

  • Tweets: Create a tweet of up to 280 characters with up to 4 media IDs; delete your own tweet; read any public tweet.
  • Timelines: Home timeline (ranked), user timeline (chronological), mentions timeline; all pageable and refreshable from the top.
5 more requirementsUnlock to see all

How well must it do it?

  • Pagination: Stable pages while new tweets arrive at the top; a client can fetch only newer than what it has.
  • Fairness: Rate limits per app and per user, with headers that tell a client when it may call again.
3 more requirementsUnlock to see all

What scale should you design for?

Use these numbers in your estimates.

The scale numbers unlock with this questionUnlock

Key concepts

  • REST API
  • Cursor pagination
  • Rate limiting
  • Oauth 2.0 scopes
  • Resource modeling
  • Field selection

How you’ll practise

6 short steps · save and come back any time
  1. Use cases
  2. Resources
  3. Endpoints
  4. Errors, auth and limits
  5. Versioning
  6. Wrap-up

Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.

What do interviewers look for?

In any API design round.

  • Starts from the clients and the use cases
  • Names resources and operations consistently
  • Defines request and response shapes and status codes
  • Covers authentication, rate limits and idempotency
  • Plans pagination, filtering and versioning
  • Explains how clients learn about and recover from errors

Questions people ask about this interview question

Which design type is this question?
It is an API design question. You design the REST API for Twitter and explain your choices the way you would in an interview.
Is this question asked at entry level?
It is marked Medium. Entry-level engineers can practise it, but it expects you to reason about requirements and trade-offs, not only list components.
What should I cover first?
Start with the clients, the main use cases and the resources they need. Agree on scope with the interviewer before you design anything.
Can I practise it for free?
It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.

Related questions

Updated · Written by the SevyDevy team

Premium questionSign up free, then unlock it