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

Additional response Accept headers are supported.

Accept: text/csv
Accept: text/plain
Accept: text/html
Accept: application/x-ndjson
Accept: application/jsonl
Accept: application/json-seq
Accept: text/tab-separated-values

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

Filter conditions can use field=value for equals, field!=value or field!value for not equals, field<value, field>value, field<=value, and field>=value for comparisons, field~=regex for regular expression matches, and field*=wildcard for wildcard matches where * matches many characters and ? matches one character. Multiple query params are combined as AND conditions.

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

Some requests can be sorted by adding the _sortBy query param with a field name. Use _sortBy=+field or _sortBy=field for ascending order, and _sortBy=-field for descending order. Multiple fields can be combined with commas, e.g. _sortBy=+field,-other.

Model

Things

item

Fields:
Fieldname Type Description
idAUTO_INCREMENT
  • Field is an ID and should not be amended or set
Example: "38"
typeENUM
  • Value must be an Enum (cd, dvd, book, blu-ray) value
  • Value is mandatory
Example: "cd"
isbn13STRING
  • Value is mandatory
  • 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
Example: "123-4-56-789012-3"
priceFLOAT
  • Value must be a Float of min 0.000000 and max 50000.000000
  • Value is mandatory
Example: "97.99"
numberinstockINTEGER
  • Value must be an Integer of min 0 and max 100
Example: "0"

Example JSON Output from API calls


{
  "id": 38,
  "type": "cd",
  "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>38</id>
  <type>cd</type>
</item>

Example JSON Input to API calls


{
  "id": 1,
  "type": "cd",
  "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>
  <id>1</id>
  <type>cd</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?isbn13=123-4-56-789012-3&type=blu-ray

This endpoint can be sorted with the _sortBy URL Query Parameter. Use _sortBy=+field or _sortBy=field for ascending order, and _sortBy=-field for descending order. Multiple fields can be combined with commas, e.g. _sortBy=+field,-other.

e.g. /simpleapi/items?_sortBy=+id

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

/simpleapi/items/:id

e.g. /simpleapi/items/:id

/simpleapi/randomisbn

e.g. /simpleapi/randomisbn

Open Swagger UI