API design
Principles we seek to apply inof the API design:
- some routes will have non-trivial input parameters (structured data, arbitrary strings), which are difficult and clunky to encode directly in a URL
- we can have short clear URLS for all routes
- long URLs can be problematic with some browsers etc.
- retrieve: return data for a given object
- search: return all the objects which match the set of search parameters
- create: create a new object based on the parameters provided, unless a matching object already exists and only one is allowed (we almost called this "get_or_create" instead)
- update: update the properties of a given object based on the parameters provided
- delete: delete a given object
- attach: attach the given object to a particular resource, if not yet attached
- detach: detach the given object from a particular resource, if attached
- process: process the input data with an appropriate independent tool (e.g., the CLASSLA NLP library)
- each item in the input is processed (allowing users to make just a single API call)
- the input data should be a list, with each element in the format expected by the non-batch route
- the output data hierarchy has an extra level at the top with two fields
- results: a list of output data, each corresponding to the input data at the same position in the input
- errors: a list of errors during processing, in which the position of the problematic item is also included (in which case the item will be null in the results)