Carts API

Shopping cart management system for e-commerce applications with user associations and product quantities.

List Carts

Get all shopping carts, optionally filtered by user ID.

GET https://responserift.dev/api/carts?userId=1

Query Parameters

  • userId - Filter carts by user ID (optional)

Response

{
  "total": 5,
  "results": [
    {
      "id": 1,
      "userId": 1,
      "products": [
        { "productId": 10, "quantity": 2 },
        { "productId": 15, "quantity": 1 }
      ]
    }
  ]
}

Get Cart

Retrieve a specific shopping cart by ID.

GET https://responserift.dev/api/carts/1

Create Cart

Create a new shopping cart for a user.

POST https://responserift.dev/api/carts
Content-Type: application/json

{
  "userId": 1,
  "products": [
    { "productId": 10, "quantity": 2 },
    { "productId": 15, "quantity": 1 }
  ]
}

Required fields: userId, products
Products array: Each product must have productId (number) and quantity (positive number)

Update Cart

Modify an existing shopping cart (e.g., change quantities, add/remove products).

PUT https://responserift.dev/api/carts/1
Content-Type: application/json

{ 
  "products": [
    { "productId": 10, "quantity": 3 },
    { "productId": 20, "quantity": 1 }
  ] 
}

Delete Cart

Remove a shopping cart from the system.

DELETE https://responserift.dev/api/carts/1

Cart Structure

Fields

  • id - Unique cart identifier
  • userId - ID of the user who owns the cart
  • products - Array of cart items with productId and quantity

Product Item Structure

  • productId - ID of the product in the cart
  • quantity - Number of items (must be positive)

Warning: All mutations are in-memory only and reset on server restart.

ResponseRift JSON API • Production-Ready, Zero-Config