Gen-Endpoint
Back to API List

Free Shopping Cart API — REST Endpoint for Testing & Development

E-commerce
7 Endpoints

Manage shopping cart operations with session handling, item management, and checkout preparation. This endpoint provides realistic mock data and behaviors, making it perfect for frontend testing, QA, software demos, and programming tutorials.

Internal API - Hosted by this App
API Endpoints & Usage
Explore and interact with the available endpoints for the Shopping Cart API. These API routes are live!
GET

/api/cart/{sessionId}

Get cart contents for session. Creates a new cart if sessionId is new or cart expired. Replace {sessionId} with an ID (e.g., sess_123).

Try it out

Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).

POST

/api/cart/{sessionId}/items

Add an item to the cart. Replace {sessionId} with a session ID.

Try it out

Replace placeholders (e.g., {userId}) with actual values in the path above.

GET

/api/cart/{sessionId}/items

List all items in the specified cart. Replace {sessionId} with a session ID.

Try it out

Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).

PUT

/api/cart/{sessionId}/items

Update quantity of an item in the cart. Expects itemId and new quantity. Replace {sessionId} with a session ID.

Try it out

Replace placeholders (e.g., {userId}) with actual values in the path above.

DELETE

/api/cart/{sessionId}/items

Remove an item from the cart. Expects itemId. Replace {sessionId} with a session ID.

Try it out

Replace placeholders (e.g., {userId}) with actual values in the path above.

PUT

/api/cart/{sessionId}

Update cart metadata, e.g., apply a coupon code. Replace {sessionId} with a session ID.

Try it out

Replace placeholders (e.g., {userId}) with actual values in the path above.

DELETE

/api/cart/{sessionId}

Clear all items from the cart (cart session persists but is empty). Replace {sessionId} with a session ID.

Try it out

Replace placeholders (e.g., {userId}) with actual values in the path above.

Example Usage

cURL Request

curl -X GET https://gen-endpoint.com/api/cart/{sessionId}

Sample JSON Response

{
  "id": "sess_123",
  "userId": null,
  "items": [
    {
      "id": "item_abc",
      "productId": "prod_123",
      "name": "Wireless Headphones",
      "priceAtTimeOfAddition": 99.99,
      "quantity": 1,
      "imageUrl": "https://placehold.co/100x100.png",
      "options": {
        "color": "black"
      },
      "subtotal": 99.99
    }
  ],
  "subtotal": 99.99,
  "tax": 8,
  "shipping": 0,
  "discount": 0,
  "total": 107.99,
  "createdAt": "2024-08-20T10:00:00Z",
  "updatedAt": "2024-08-20T10:05:00Z",
  "expiresAt": "2024-08-21T10:00:00Z"
}
Frequently Asked Questions (FAQ)

Is this API free?

Yes! This API is completely free to use for personal, learning, and development purposes. There are no strict usage limits for standard personal use.

Does it require authentication?

Most of our endpoints are public and do not require any API keys or authentication. You can start sending requests immediately.

What does the response look like?

Our APIs return standardized JSON responses mimicking real-world data structures, ensuring easy parsing and integration for your frontend or tools.

Can I use this in production?

No. These endpoints are designed solely for testing, development, and demonstration purposes. They provide mock data and do not guarantee uptime or data persistence required for production applications.

    Shopping Cart API - Free Public API | Gen-Endpoint