Skip to main content
GET
/
api
/
cart
/
:userId
Get Cart
curl --request GET \
  --url https://api.example.com/api/cart/:userId
{
  "success": true,
  "data": {
    "id": 123,
    "userId": 123,
    "abandonedEmailSent": true,
    "items": [
      {
        "id": 123,
        "cartId": 123,
        "productoId": 123,
        "quantity": 123,
        "producto": {}
      }
    ]
  },
  "error": "<string>"
}

Overview

Retrieves the complete shopping cart for a user, including all cart items and their associated product details.

Authentication

This endpoint requires authentication. Ensure the user has permission to access the specified cart.

Path Parameters

userId
number
required
The unique identifier of the user whose cart you want to retrieve

Response

success
boolean
required
Indicates whether the request was successful
data
object
The cart object containing all cart details
id
number
Unique identifier for the cart
userId
number
The ID of the user who owns this cart
abandonedEmailSent
boolean
Whether an abandoned cart email has been sent
items
array
Array of cart items
id
number
Unique identifier for the cart item
cartId
number
Reference to the parent cart
productoId
number
The product ID for this cart item
quantity
number
Quantity of the product in the cart
producto
object
Complete product details including name, price, description, images, etc.
error
string
Error message if the request fails

Example Request

curl -X GET "https://api.pcfix.com/api/cart/123" \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

Success Response

{
  "success": true,
  "data": {
    "id": 1,
    "userId": 123,
    "abandonedEmailSent": false,
    "items": [
      {
        "id": 45,
        "cartId": 1,
        "productoId": 789,
        "quantity": 2,
        "producto": {
          "id": 789,
          "name": "Gaming Mouse",
          "price": 49.99,
          "description": "High-performance gaming mouse",
          "imageUrl": "https://example.com/mouse.jpg"
        }
      },
      {
        "id": 46,
        "cartId": 1,
        "productoId": 456,
        "quantity": 1,
        "producto": {
          "id": 456,
          "name": "Mechanical Keyboard",
          "price": 129.99,
          "description": "RGB mechanical keyboard",
          "imageUrl": "https://example.com/keyboard.jpg"
        }
      }
    ]
  }
}

Error Response

{
  "success": false,
  "error": "User ID required"
}

Error Codes

Status CodeDescription
200Cart retrieved successfully
400Invalid user ID
401Unauthorized access
500Server error - Failed to get cart

Notes

  • If the user has no cart, the response will return null for the data field
  • Only non-deleted products are included in the cart items
  • Product details are fully populated in the response

Build docs developers (and LLMs) love