api_class
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| api_class [2020/11/22 15:21] – sahl | api_class [2021/02/11 13:35] (current) – API query and handling files sahl | ||
|---|---|---|---|
| Line 90: | Line 90: | ||
| } | } | ||
| </ | </ | ||
| - | | + | |
| + | |||
| + | ===== Handling file fields in the API ===== | ||
| + | During normal operation the API will just return the ID of the file in file fields, but by passing the // | ||
| + | |||
| + | ^filename|The filename of the file| | ||
| + | ^mimetype|The mime type of the file| | ||
| + | ^binary|The file binary data as base64| | ||
| + | |||
| + | Please be aware that this can produce substantial output in some cases, and is therefore only recommended for using when querying for a specific object. | ||
| + | |||
| + | A similar JSON structure can be used when posting to the API to update files. Just add another field to the JSON structure: | ||
| + | |||
| + | ^action|add to add a file and remove to remove the file currently in place.| | ||
| + | |||
| + | If //remove// is passed the other fields are not necessary. | ||
| + | |||
| + | ===== Querying the API ===== | ||
| + | The API endpoints can be queried by passing a JSON-structure in the //query// GET parameter. The query can consist of either a comparison statement or logical statement. | ||
| + | |||
| + | ==== Comparison statement ==== | ||
| + | |||
| + | A comparison statement always consists of three fields: //type//, // | ||
| + | |||
| + | The following comparison types exists: | ||
| + | |||
| + | ^Type^Meaning^ | ||
| + | |Greater|Return everything where // | ||
| + | |GreaterEqual|Return everything where // | ||
| + | |Lesser|Return everything where // | ||
| + | |LesserEqual|Return everything where // | ||
| + | |Like|Return everything where //value// is contained in // | ||
| + | |Match|Return everything where // | ||
| + | |OneOf|Return everything where // | ||
| + | |||
| + | ==== Logical statement ==== | ||
| + | |||
| + | Logical statements are used to combine or negate other statements. They consists of the field: //type// and some additional fields depending on the type. | ||
| + | |||
| + | ^type^additional fields^Meaning^ | ||
| + | |AND|// | ||
| + | |OR|// | ||
| + | |NOT|// | ||
| + | |||
| + | ==== Examples ==== | ||
| + | Find all data where age is equal or greater than 18 | ||
| + | <code javascript> | ||
| + | {" | ||
| + | </ | ||
| + | |||
| + | Find all data where age is less than 40 and gender is male | ||
| + | <code javascript> | ||
| + | {" | ||
| + | </ | ||
| + | |||
| + | Find all data where firstname contains the letter a | ||
| + | <code javascript> | ||
| + | {" | ||
| + | </ | ||
| + | |||
| + | Find all data changed since a specific time stamp | ||
| + | <code javascript> | ||
| + | {" | ||
| + | </ | ||
api_class.1606058474.txt.gz · Last modified: 2020/11/22 15:21 by sahl