Buggy API

A deliberately buggy shopping cart API for API testing practice.

The Buggy API is a small public Shopping Cart practice API mounted at /shop.

It is deliberately buggy by default. Start the app with -shopbugs=none to run the clean business rules.

Use POST /shop/register to create a cart and receive a bearer token. Product catalogue data is read-only; cart item writes happen through /shop/carts/{cartId}/items.

Model

Things

product

A safe fixed catalogue item with internally maintained stock.

Fields:
Fieldname Type Description
idAUTO_INCREMENT
  • Unique product identifier.
  • Field is an ID and should not be amended or set
Example: "33"
productCodeENUM
  • Safe catalogue code for the product.
  • Value must be an Enum (BOOK_REST, CD_HEADERS, MUG_TESTER, USB_CABLE, PEN_RED, POSTER_API, BLURAY_HTTP, DVD_BUGS, PUZZLE_CACHE, STICKER_HTTP, PUZZLE_PROXY, NOTEBOOK_LOGS, STICKER_PACK, POSTER_BUG, BOOK_API, BOOK_TESTS, MUG_CLIENT, NOTEBOOK_GRID, GAME_JSON, USB_HUB, CD_STATUS, GAME_TOKENS, PEN_BLUE, DVD_STATUS) value
  • Value is mandatory
Example: "BOOK_REST"
categoryENUM
  • Safe category for the product.
  • Value must be an Enum (cd, game, electronics, art, dvd, book, homeware, stationery, blu-ray) value
  • Value is mandatory
Example: "cd"
unitPriceFLOAT
  • Current unit price used for new cart lines.
  • Value must be a Float of min 0.010000 and max 500.000000
  • Value is mandatory
Example: "1.00"
stockINTEGER
  • Current available stock count maintained by the API.
  • Value must be an Integer of min -1000 and max 9999
  • Value is mandatory
Example: "0"

Example JSON Output from API calls


{
  "id": 33,
  "productCode": "BOOK_REST",
  "category": "cd",
  "unitPrice": 1.0,
  "stock": 0
}

Example JSON Input to API calls


{
  "id": 1,
  "productCode": "BOOK_REST",
  "category": "cd",
  "unitPrice": 1.0,
  "stock": 0
}

Example XML Input to API calls


<product>
  <unitPrice>1.0</unitPrice>
  <productCode>BOOK_REST</productCode>
  <id>1</id>
  <category>cd</category>
  <stock>0</stock>
</product>

cart

A user's shopping cart, created through registration.

Fields:
Fieldname Type Description
idAUTO_INCREMENT
  • Unique cart identifier.
  • Field is an ID and should not be amended or set
Example: "30"
tokenAUTO_GUID
  • Protected bearer token for cart mutation.
  • Field is an ID and should not be amended or set
  • Value is mandatory
Example: "d3577667-0a44-4038-96d0-314aea9d8306"
stateENUM
  • Lifecycle state of the cart.
  • Value must be an Enum (closed, abandoned, open) value
  • Value is mandatory
Example: "closed"
createdTickINTEGER
  • Internal tick when the cart was created.
  • Value must be an Integer of min 0 and max 999999
Example: "0"
updatedTickINTEGER
  • Internal tick when the cart was last changed.
  • Value must be an Integer of min 0 and max 999999
Example: "0"
checkoutTickINTEGER
  • Internal tick when checkout last completed.
  • Value must be an Integer of min 0 and max 999999
Example: "0"
Views:
View Request Fields Response Fields Input Allowed Fields
PublicCartid, state, createdTick, updatedTick, checkoutTickid, state, createdTick, updatedTick, checkoutTickid, state, createdTick, updatedTick, checkoutTick

Example JSON Output from API calls


{
  "id": 30,
  "token": "d3577667-0a44-4038-96d0-314aea9d8306",
  "state": "closed",
  "createdTick": 0,
  "updatedTick": 0,
  "checkoutTick": 0
}

Example JSON Input to API calls


{
  "id": 1,
  "state": "closed",
  "createdTick": 0,
  "updatedTick": 0,
  "checkoutTick": 0
}

Example XML Input to API calls


<cart>
  <updatedTick>0</updatedTick>
  <createdTick>0</createdTick>
  <id>1</id>
  <state>closed</state>
  <checkoutTick>0</checkoutTick>
</cart>

cartitem

A product line in a shopping cart.

Fields:
Fieldname Type Description
idAUTO_INCREMENT
  • Unique cart item identifier.
  • Field is an ID and should not be amended or set
Example: "64"
productIdINTEGER
  • Product identifier requested for this cart line.
  • Value must be an Integer of min 1 and max 24
  • Value is mandatory
Example: "1"
quantityINTEGER
  • Requested quantity for this cart line.
  • Value must be an Integer of min -1000 and max 9999
  • Value is mandatory
Example: "1"
unitPriceAtAddFLOAT
  • Product unit price captured when the line was added.
  • Value must be a Float of min 0.000000 and max 500.000000
Example: "0.00"
stockAtAddINTEGER
  • Product stock captured when the line was added.
  • Value must be an Integer of min -1000 and max 9999
Example: "0"
Views:
View Request Fields Response Fields Input Allowed Fields
AddedCartItemid, productId, quantityid, productId, quantity, unitPriceAtAdd, stockAtAddid, productId, quantity, unitPriceAtAdd, stockAtAdd

Example JSON Output from API calls


{
  "id": 64,
  "productId": 1,
  "quantity": 1,
  "unitPriceAtAdd": 0.0,
  "stockAtAdd": 0
}

Example JSON Input to API calls


{
  "id": 1,
  "productId": 1,
  "quantity": 1,
  "unitPriceAtAdd": 0.0,
  "stockAtAdd": 0
}

Example XML Input to API calls


<cartitem>
  <quantity>1</quantity>
  <stockAtAdd>0</stockAtAdd>
  <productId>1</productId>
  <unitPriceAtAdd>0.0</unitPriceAtAdd>
  <id>1</id>
</cartitem>

Relationships

erDiagram
    CART ||--o{ CARTITEM : items
    PRODUCT ||--o{ CARTITEM : cartitems

API

The API takes body with objects using the field definitions and examples shown in the model.

End Points

/shop/products

e.g. /shop/products

This endpoint can be filtered with fields as URL Query Parameters.

e.g. /shop/products?stock=0&productCode=CD_HEADERS

QUERY content uses Content-Type: application/x-www-form-urlencoded with fields such as title=Task&sortBy=-id.

/shop/products/:id

e.g. /shop/products/:id

/shop/carts

e.g. /shop/carts

This endpoint can be filtered with fields as URL Query Parameters.

e.g. /shop/carts?createdTick=0&state=closed&updatedTick=0

QUERY content uses Content-Type: application/x-www-form-urlencoded with fields such as title=Task&sortBy=-id.

/shop/carts/:id

e.g. /shop/carts/:id

/shop/carts/:id/items

e.g. /shop/carts/:id/items

QUERY content uses Content-Type: application/x-www-form-urlencoded with fields such as title=Task&sortBy=-id.

/shop/carts/:id/items/:relatedId

e.g. /shop/carts/:id/items/:relatedId

/shop/register

e.g. /shop/register

/shop/checkout/:cartId

e.g. /shop/checkout/:cartId

Open Swagger UI