"REST in a Shopping Cart"
An API (Application Programming Interface) allows two programs to talk to each other, like your shopping app communicating with a server to save or get data.
In a shopping app, the cart can use REST principles.
Each request (like adding an item) must be stateless — meaning the server doesn’t remember past actions.
So every time you add, view, or remove an item, the app sends all the needed info (like user ID, product ID, and quantity).
Hint:
Use standard HTTP methods —
POST (add item), GET (view cart), PUT (update quantity), DELETE (remove item).
🧩 Example:
POST /api/cart
{"user_id": "123",
"product_id": "A45",
"quantity": 2}
Top comments (0)