-
Notifications
You must be signed in to change notification settings - Fork 13
RESTful Service Guide
Jasper Nalbach edited this page Sep 7, 2016
·
10 revisions
We had some inconsistencys and open questions related to RESTful API design, which lead to ugly request URLs. This is why we define some basic guidelines here. The interested reader may continue his studies in this paper where some of these information were extracted from, and this book referenced from the paper.
Criteria 1-12 are highly relevant while criteria 13-17 are related, but not highly relevant.
- Availability of Formal Description. We use Swagger for documenting APIs. However, our JAX-RS support is limited, so this can be improved.
- Links in Representations. Links to other resources are navigational help and provide follow-up actions. It allows a loose coupling between client and API since the client gets an URL where he can proceed. However, this is not possible in las2peer (yet?) since the service never knows the used endpoint (WebConnector) where he actually runs, so a service can only provide a relative link.
- Encode IDs in URIs.
- Number of Resource Types.
- Versioned service endpoint. las2peer has a versioned service endpoint to choose different service versions. This is common practise to keep multiple APIs running at the same time and to not break compatibility. However, this violates the principle of resource addressability.
- Scoping Information. Resource information should be encoded in resource URIs.
-
Parameter Sources. Parameters should be passed in the POST/PUT body to support richer semantics. Only filters are passed as GET parameter (e.g.
/list?orderBy=...
). - Meaningful HTTP Status Codes. Enhance error handling by sending reasonable HTTP status codes.
- HTTP Methods Used. Using just a single method can also point to an overloading of functionality.
- HTTP Method Override. Some browsers only accept only GET and POST.
- Representation Formats. Commonly used formats are XML, JSON, serialized PHP, ATOM, HTML and CSV
- Representation Format Selection. HTTP allows the user to specify the media type. Most common way is to pass the format as an argument.
- User Authentication. HTTP provides a general mechanism, including specific authentication protocols to be used. Other standards such as the OAuth protocol have emerged.
- Secure Connections. Support SSL-secured connections.
- Accessibility via other protocols.
- Type of Registration Required. Provide a registration method like API-Keys.
- Usage Limitations. For example allow only a certain amount of requests during a fixed time.
Copyright (c) 2020 Advanced Community Information Systems (ACIS) Group, Chair of Computer Science 5 (Databases & Information Systems), RWTH Aachen University, Germany