Free Cart Mock REST API Documentation

The MockX Cart API provides a robust solution for e-commerce platforms, enabling developers to interact with shopping cart data. This API facilitates a range of actions, including retrieving cart information, creating new carts, updating existing carts, and deleting carts.
Endpoints Overview
The MockX Cart API includes several endpoints to address different shopping cart management needs:
- GET /: Fetches all shopping carts.
- GET /user/:userId: Retrieves carts associated with a specific user.
- GET /:id: Fetches a specific cart by its unique ID.
- POST /add: Creates a new shopping cart.
- PUT /:id: Updates an entire shopping cart by ID.
- PATCH /:id: Partially updates a shopping cart by ID.
- DELETE /:id: Deletes a shopping cart by ID.
Get All Carts
Retrieve a list of all shopping carts in the system.
GET https://api.mockx.net/cart
Parameters:
limit: Limits the number of carts returned. skip: Skips a specified number of carts. Example Response:
{
"carts": [
{
"id": 1,
"products": [
{
"id": 59,
"title": "Eco-Friendly Reusable Water Bottle",
"price": 80,
"quantity": 3,
"total": 240,
"discountPercentage": 12.16,
"discountedPrice": 211,
"thumbnail": "https://via.placeholder.com/150?text=Product59"
},
{
"id": 39,
"title": "Smart Fitness Tracker",
"price": 169,
"quantity": 5,
"total": 845,
"discountPercentage": 27.26,
"discountedPrice": 615,
"thumbnail": "https://via.placeholder.com/150?text=Product39"
}
],
"total": 2328,
"discountedTotal": 1941,
"userId": 97,
"totalProducts": 5,
"totalQuantity": 10
},
...
],
"total": 100,
"skip": 0,
"limit": 10
}
Get Carts by User ID
Fetch carts associated with a specific user.
GET https://api.mockx.net/cart/user/{userId}
Parameters:
userId: The unique identifier of the user. limit and skip: Same as above. Example Response:
{
"carts": [ {
"id": 1,
"products": [
{
"id": 59,
"title": "Eco-Friendly Reusable Water Bottle",
"price": 80,
"quantity": 3,
"total": 240,
"discountPercentage": 12.16,
"discountedPrice": 211,
"thumbnail": "https://via.placeholder.com/150?text=Product59"
},
{
"id": 39,
"title": "Smart Fitness Tracker",
"price": 169,
"quantity": 5,
"total": 845,
"discountPercentage": 27.26,
"discountedPrice": 615,
"thumbnail": "https://via.placeholder.com/150?text=Product39"
}
],
"total": 2328,
"discountedTotal": 1941,
"userId": 97,
"totalProducts": 5,
"totalQuantity": 10
}...],
"total": 5,
"skip": 0,
"limit": 5
}
Get Cart by ID
Retrieve detailed information about a specific cart.
GET https://api.mockx.net/cart/{id}
Parameters:
id: The unique identifier of the cart. Example Response:
"cart": {
"id": 1,
"products": [
{
"id": 59,
"title": "Eco-Friendly Reusable Water Bottle",
"price": 80,
"quantity": 3,
"total": 240,
"discountPercentage": 12.16,
"discountedPrice": 211,
"thumbnail": "https://via.placeholder.com/150?text=Product59"
},
{
"id": 39,
"title": "Smart Fitness Tracker",
"price": 169,
"quantity": 5,
"total": 845,
"discountPercentage": 27.26,
"discountedPrice": 615,
"thumbnail": "https://via.placeholder.com/150?text=Product39"
}
],
"total": 2328,
"discountedTotal": 1941,
"userId": 97,
"totalProducts": 5,
"totalQuantity": 10
}
}
Add New Cart
Create a new cart with specified products.
POST https://api.mockx.net/cart/add
Body: Include details such as user ID and products in the request body.
Example Response:
{
"id": 2,
"products": [
{
"id": 59,
"title": "Eco-Friendly Reusable Water Bottle",
"price": 80,
"quantity": 3,
"total": 240,
"discountPercentage": 12.16,
"discountedPrice": 211,
"thumbnail": "https://via.placeholder.com/150?text=Product59"
},
{
"id": 39,
"title": "Smart Fitness Tracker",
"price": 169,
"quantity": 5,
"total": 845,
"discountPercentage": 27.26,
"discountedPrice": 615,
"thumbnail": "https://via.placeholder.com/150?text=Product39"
}
]
}
Update Cart by ID
Modify the details of an existing cart.
PUT https://api.mockx.net/cart/{id}
Example :
PUT https://api.mockx.net/cart/1
Request Body :
{
"products": [
{
"id": 59,
"title": "Eco-Friendly Reusable Water Bottle",
"price": 80,
"quantity": 3,
"total": 240,
"discountPercentage": 12.16,
"discountedPrice": 211,
"thumbnail": "https://via.placeholder.com/150?text=Product59"
},
{
"id": 88,
"title": "LED Desk Lamp with Wireless Charging",
"price": 134,
"quantity": 5,
"total": 670,
"discountPercentage": 24.03,
"discountedPrice": 509,
"thumbnail": "https://via.placeholder.com/150?text=Product88"
},
{
"id": 18,
"title": "Organic Cotton Bed Sheets",
"price": 94,
"quantity": 3,
"total": 282,
"discountPercentage": 13.94,
"discountedPrice": 243,
"thumbnail": "https://via.placeholder.com/150?text=Product18"
},
{
"id": 95,
"title": "Organic Bamboo Cutting Board",
"price": 51,
"quantity": 2,
"total": 102,
"discountPercentage": 14.98,
"discountedPrice": 87,
"thumbnail": "https://via.placeholder.com/150?text=Product95"
},
{
"id": 39,
"title": "Smart Fitness Tracker",
"price": 169,
"quantity": 5,
"total": 845,
"discountPercentage": 27.26,
"discountedPrice": 615,
"thumbnail": "https://via.placeholder.com/150?text=Product39"
}
],
"total": 2328,
"discountedTotal": 1941,
"userId": 97,
"totalProducts": 5,
"totalQuantity": 10
}
Parameters:
id: The unique identifier of the cart to be updated. Body: Include the updated cart details in the request body.
Example Response:
{
"id": 1,
"products": [
{
"id": 59,
"title": "Eco-Friendly Reusable Water Bottle",
"price": 80,
"quantity": 3,
"total": 240,
"discountPercentage": 12.16,
"discountedPrice": 211,
"thumbnail": "https://via.placeholder.com/150?text=Product59"
},
{
"id": 88,
"title": "LED Desk Lamp with Wireless Charging",
"price": 134,
"quantity": 5,
"total": 670,
"discountPercentage": 24.03,
"discountedPrice": 509,
"thumbnail": "https://via.placeholder.com/150?text=Product88"
},
{
"id": 18,
"title": "Organic Cotton Bed Sheets",
"price": 94,
"quantity": 3,
"total": 282,
"discountPercentage": 13.94,
"discountedPrice": 243,
"thumbnail": "https://via.placeholder.com/150?text=Product18"
},
{
"id": 95,
"title": "Organic Bamboo Cutting Board",
"price": 51,
"quantity": 2,
"total": 102,
"discountPercentage": 14.98,
"discountedPrice": 87,
"thumbnail": "https://via.placeholder.com/150?text=Product95"
},
{
"id": 39,
"title": "Smart Fitness Tracker",
"price": 169,
"quantity": 5,
"total": 845,
"discountPercentage": 27.26,
"discountedPrice": 615,
"thumbnail": "https://via.placeholder.com/150?text=Product39"
}
],
"total": 2139,
"discountedTotal": 1665,
"userId": 97,
"totalProducts": 5,
"totalQuantity": 18
}
Delete Cart by ID
Remove a cart from the database.
DELETE https://api.mockx.net/cart/{id}
Parameters:
id: The unique identifier of the cart to be deleted. Example Response:
{
"message": "Cart with id '{id}' successfully deleted."
}