Design a Newsfeed API
Design the API endpoints needed to render a social media newsfeed (like Facebook, Instagram, or TikTok), focusing on API structure, response formats, and pagination rather than backend system architecture.
Asked at:
Meta
A Newsfeed API is a set of HTTP endpoints that power the scrolling feed in apps like Facebook, Instagram, or TikTok. It delivers a sequence of posts with author info, media, engagement counts, and viewer-specific state, and supports fetching more items as the user scrolls. Interviewers ask this to see how you model product-facing APIs: endpoint shapes, pagination strategy, response normalization, batching to avoid N+1 calls, versioning, permissions, and real-time or delta update patterns. Expect to focus on request/response contracts, not backend storage or ranking, and to justify trade-offs that keep latency low and the client simple.
Common Functional Requirements
Most candidates end up covering this set of core functionalities
Users should be able to fetch a personalized, paginated newsfeed that returns posts with enough data to render each card (author, media, caption, timestamps, engagement counts, and viewer state).
Users should be able to continuously scroll and load the next page of feed items with a clear continuation token or next URL for pagination.
Users should be able to see key engagement and social context on each post (like counts, comment counts, whether they have liked/saved/followed).
Users should be able to perform basic interactions from the feed (like/unlike, save/unsave, follow/unfollow) with immediate UI feedback and robust error handling.
Common Deep Dives
Common follow-up questions interviewers like to ask for this question
Pagination is the first place newsfeed APIs go wrong. Offset-based approaches create duplication, missed items, and poor performance under updates. In a system design interview at Meta, you’re expected to use opaque, cursor-based pagination and think through dedupe. - Prefer opaque, cursor-based pagination tied to a stable sort key (e.g., time-decayed rank or (score, post_id)) and return has_more plus next_cursor or next_url. - Include a stable client_dedupe_key per item and let the server support a seen_ids/last_cursor parameter to avoid duplicates across refreshes. - Consider prefetching the next page when the user is ~70–80% into the current one and include a page_expiration or cursor_ttl to manage staleness.
A strong feed API balances completeness and size. You want one call to render the screen, but you don’t want to overfetch. Interviewers look for patterns like embedding commonly needed fields and normalizing shared objects. - Return a primary list of item references plus an includes map (users, media, pages) keyed by IDs to dedupe repeats across posts; embed the minimal per-card fields directly on each post. - Support field selection (e.g., fields=post(id,caption,media),user(id,name,avatar)) or lightweight response variants (feed?view=compact) to tailor payloads. - Use stable media URLs, thumbnails, aspect ratios, and dimensions in-line; keep large blobs out of the payload and rely on a CDN for delivery.
Real-time or near-real-time updates keep feeds feeling alive. Even if the backend is complex, the API can expose simple mechanisms like deltas, polling with cursors, or server-pushed notifications. - Provide a lightweight /feed/updates?since_cursor=… endpoint returning inserts, deletes/hides, and counter deltas; keep payloads small and idempotent. - Consider ETags/If-None-Match or last_modified to enable conditional requests; fall back to frequent short polling if WebSockets/SSE are out of scope. - For live counters, add a /engagements/bulk?ids=… endpoint so you can refresh like/comment counts for many posts at once.
Mutation APIs in a newsfeed must be fast and resilient, because users tap quickly and networks are flaky. Interviewers look for idempotency, consistent viewer state, and predictable error semantics that support optimistic UI updates. - Make mutations idempotent (PUT /posts/{id}/like and DELETE /posts/{id}/like) or support an Idempotency-Key header on POST; return the new viewer state and updated counts. - Define clear error codes (e.g., 409 for already liked, 403 for privacy violations) and include retry-after or guidance for rate-limited actions (429). - Support optimistic UI by returning a minimal engagement object {liked_by_viewer, like_count, version} and allow clients to reconcile on conflict with a follow-up bulk fetch.
Relevant Patterns
Relevant patterns that you should know for this question
Feeds are read-heavy and latency-sensitive. You must design APIs and response shapes that minimize round trips, leverage caching, and support bulk retrieval (e.g., includes maps and field selection) to keep p95 under control.
Users expect fresh content and live counters. Even without deep backend detail, the API should expose delta endpoints, conditional requests, or push mechanisms so the UI can update without re-fetching full pages.
Posts often include images and video. The API should return references, thumbnails, and metadata rather than embedding large media, and rely on pre-signed URLs/CDNs to deliver bytes efficiently.
Relevant Technologies
Relevant technologies that could be used to solve this question
An API Gateway centralizes authentication, rate limiting, request/response transformation, and versioning—key concerns in a public-facing feed API that multiple clients (iOS, Android, Web) call at high volume.
Similar Problems to Practice
Related problems to practice for this question
Identical core: paginated personalized feed, engagement counters, viewer state, and real-time refresh. The same API concerns—cursor design, includes maps, and mutation endpoints—apply directly.
Media-heavy posts with thumbnails, aspect ratios, and CDNs. The API must avoid large payloads, support field selection, and handle continuous scroll with low-latency pagination.
Real-time updates and engagement deltas mirror how a feed updates like/comment counts and inserts new items. Patterns like bulk engagement endpoints and delta fetches are shared.
Red Flags to Avoid
Common mistakes that can sink candidates in an interview
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late August, 2025
Meta
Manager
Early August, 2025
Meta
Senior
Mid July, 2025
Meta
Staff
Design the API to fetch NewsFeed content to render on the webpage. For example, a news-feed can contain multiple posts where each post can have user-thumbnail, timestamp, post-text, images, number of likes and comments on a post etc. The goal is to design an API or multiple APIs to render each post on the news-feed.
Your account is free and you can post anonymously if you choose.