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: "74"
typeENUM
  • Mandatory?: true
  • Allowed Values: cd, dvd, book, blu-ray
Example: "dvd"
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": 74,
  "type": "dvd",
  "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>74</id>
  <type>dvd</type>
</item>

Example JSON Input to API calls


{
  "type": "dvd",
  "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>dvd</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?numberinstock=0&type=book

/simpleapi/items/:id

e.g. /simpleapi/items/:id

[download swagger file]