SevyDevy

Design a shopping cart and checkout API

PremiumAPI designMedium

  • Checkout flow
  • Idempotency keys
  • Optimistic concurrency

Quick answer

This API design interview question asks you to design a shopping cart and checkout API. 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 a shopping cart and checkout API for an online store like Amazon, used by its web and mobile apps. The hard parts are recalculating prices while a cart sits open, stopping two devices from overwriting each other's edits, and placing the order exactly once even when the call is retried.

Shoppers add items as guests, sign in later and keep the cart, edit quantities from two devices, apply coupons, pick a shipping method, see taxes and totals, and place the order. Prices and stock change while the cart sits open, and every total must be explained.

What must a shopping cart and checkout API do?

  • Cart: Create a cart, add a product variant with a quantity, change a quantity, remove a line, clear the cart; up to 100 lines.
  • Checkout: Set addresses, select shipping, confirm the priced cart, pay, and receive an order; the shopper must see the final total before paying.
6 more requirementsUnlock to see all

How well must it do it?

  • Exactly one order: A retried place-order call never creates a second order or charge.
  • Latency: Cart reads with pricing under 300 ms at p95; place order under 2 s.
2 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

  • Checkout flow
  • Idempotency keys
  • Optimistic concurrency
  • Guest cart merge
  • Price recalculation
  • State machine

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 a shopping cart and checkout API 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