Support this site by joining our Patreon. For as little as $1 a month you receive exclusive ad-free content, ebooks and online training courses. - Learn more
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 |
| id | AUTO_INCREMENT |
|
| Example: "33" | ||
| productCode | ENUM |
|
| Example: "BOOK_REST" | ||
| category | ENUM |
|
| Example: "cd" | ||
| unitPrice | FLOAT |
|
| Example: "1.00" | ||
| stock | INTEGER |
|
| 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 |
| id | AUTO_INCREMENT |
|
| Example: "30" | ||
| token | AUTO_GUID |
|
| Example: "d3577667-0a44-4038-96d0-314aea9d8306" | ||
| state | ENUM |
|
| Example: "closed" | ||
| createdTick | INTEGER |
|
| Example: "0" | ||
| updatedTick | INTEGER |
|
| Example: "0" | ||
| checkoutTick | INTEGER |
|
| Example: "0" | ||
| View | Request Fields | Response Fields | Input Allowed Fields |
| PublicCart | id, state, createdTick, updatedTick, checkoutTick | id, state, createdTick, updatedTick, checkoutTick | id, 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 |
| id | AUTO_INCREMENT |
|
| Example: "64" | ||
| productId | INTEGER |
|
| Example: "1" | ||
| quantity | INTEGER |
|
| Example: "1" | ||
| unitPriceAtAdd | FLOAT |
|
| Example: "0.00" | ||
| stockAtAdd | INTEGER |
|
| Example: "0" | ||
| View | Request Fields | Response Fields | Input Allowed Fields |
| AddedCartItem | id, productId, quantity | id, productId, quantity, unitPriceAtAdd, stockAtAdd | id, 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
- items : cart =(items, max *)=> cartitem
- cart : cartitem =(cart, max 1)=> cart
- cartitems : product =(cartitems, max *)=> cartitem
- product : cartitem =(product, max 1)=> product
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
-
GET /shop/products
- return all the instances of product
-
QUERY /shop/products
- query all the instances of product using application/x-www-form-urlencoded query content
QUERY content uses Content-Type: application/x-www-form-urlencoded with fields such as title=Task&sortBy=-id.
-
HEAD /shop/products
- headers for all the instances of product
-
OPTIONS /shop/products
- show all Options for endpoint of /shop/products
/shop/products/:id
e.g. /shop/products/:id
-
GET /shop/products/:id
- return a specific instances of product using a id
-
HEAD /shop/products/:id
- headers for a specific instances of product using a id
-
OPTIONS /shop/products/:id
- show all Options for endpoint of /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
-
GET /shop/carts
- return all the instances of cart
-
QUERY /shop/carts
- query all the instances of cart using application/x-www-form-urlencoded query content
QUERY content uses Content-Type: application/x-www-form-urlencoded with fields such as title=Task&sortBy=-id.
-
HEAD /shop/carts
- headers for all the instances of cart
-
OPTIONS /shop/carts
- show all Options for endpoint of /shop/carts
/shop/carts/:id
e.g. /shop/carts/:id
-
GET /shop/carts/:id
- return a specific instances of cart using a id
-
HEAD /shop/carts/:id
- headers for a specific instances of cart using a id
-
DELETE /shop/carts/:id
- delete or abandon a cart using the cart bearer token
-
OPTIONS /shop/carts/:id
- show all Options for endpoint of /shop/carts/:id
/shop/carts/:id/items
e.g. /shop/carts/:id/items
-
GET /shop/carts/:id/items
- return all the cartitem items related to cart, with given id, by the relationship named items
-
QUERY /shop/carts/:id/items
- query all the cartitem items related to cart, with given id, by the relationship named items using application/x-www-form-urlencoded query content
QUERY content uses Content-Type: application/x-www-form-urlencoded with fields such as title=Task&sortBy=-id.
-
HEAD /shop/carts/:id/items
- headers for the cartitem items related to cart, with given id, by the relationship named items
-
OPTIONS /shop/carts/:id/items
- show all Options for endpoint of /shop/carts/:id/items
-
POST /shop/carts/:id/items
- add a product line to a cart using the cart bearer token
/shop/carts/:id/items/:relatedId
e.g. /shop/carts/:id/items/:relatedId
-
DELETE /shop/carts/:id/items/:relatedId
- delete a product line from a cart using the cart bearer token
-
OPTIONS /shop/carts/:id/items/:relatedId
- show all Options for endpoint of /shop/carts/:id/items/:relatedId
/shop/register
e.g. /shop/register
-
POST /shop/register
- create a new open cart and return its bearer token
/shop/checkout/:cartId
e.g. /shop/checkout/:cartId
-
POST /shop/checkout/:cartId
- checkout a cart using its bearer token in the Authorization header
- OpenAPI v 3.0 JSON [standard validation] [download] - [less validation] [download]
- OpenAPI v 3.1 JSON [standard validation] [download] - [less validation] [download]
- OpenAPI v 3.2 JSON [standard validation] [download] - [less validation] [download]
Support this site by joining our Patreon. For as little as $1 a month you receive exclusive ad-free content, ebooks and online training courses. - Learn more