Simple API Mode

A simple API, no auth protection so you can add and delete what you want in a multi-user mode.

Use the Content-Type header to define the payload content e.g.

Content-Type: application/json

Set Content-Type header to application/xml if you want to send in XML.

Content-Type: application/xml

You can control the returned data format by setting the Accept header

You can request XML response by setting the Accept header.

i.e. for XML use

Accept: application/xml

You can request JSON response by setting the Accept header.

i.e. for JSON use

Accept: application/json

Some requests can be filtered by adding query params of fieldname=value. Where only matching items will be returned.

e.g. /thing?size=2&status=true

Model

Things

item

Fields:
Fieldname Type Validation
idAUTO_INCREMENT
  • Mandatory?: true
Example: "60"
typeENUM
  • Mandatory?: true
  • Allowed Values: cd, dvd, book, blu-ray
Example: "book"
isbn13STRING
  • Value must match the regex [0-9]{3}[-]?[0-9]{1}[-]?[0-9]{2}[-]?[0-9]{6}[-]?[0-9]{1}
  • Maximum length allowed is 17
  • Mandatory?: true
Example: "123-4-56-789012-3"
priceFLOAT
  • Mandatory?: true
  • Allowed Values Between: "0.000000" to "50000.000000"
Example: "97.99"
numberinstockINTEGER
  • Mandatory?: false
  • Allowed Values Between: "0" to "100"
Example: "0"

Example JSON Output from API calls


{
  "id": 60,
  "type": "book",
  "isbn13": "123-4-56-789012-3",
  "price": 97.99,
  "numberinstock": 0
}

Example XML Output from API calls


<item>
  <price>97.99</price>
  <numberinstock>0</numberinstock>
  <isbn13>123-4-56-789012-3</isbn13>
  <id>60</id>
  <type>book</type>
</item>

Example JSON Input to API calls


{
  "type": "book",
  "isbn13": "123-4-56-789012-3",
  "price": 97.99,
  "numberinstock": 0
}

Example XML Input to API calls


<item>
  <price>97.99</price>
  <numberinstock>0</numberinstock>
  <isbn13>123-4-56-789012-3</isbn13>
  <type>book</type>
</item>

API

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

End Points

/simpleapi/items

e.g. /simpleapi/items

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

e.g. /simpleapi/items?type=blu-ray

/simpleapi/items/:id

e.g. /simpleapi/items/:id

[download swagger file]