All answers
How to design a web API?
Anonymous · Around March 2014
When designing a web API, there are two major dimensions you need to take care of,
The first dimension is common for any API (whether it is a Web or not)
- The API needs to do One thing ONLY.
- Backward compatibility is vital.
- Don't add too many API's, you can always add later, but you can never take API's back once released.
- Naming is very important, so make sure you use very clear names of your API's, and don't burn all the good names very early.
- Developers rarely read documentation, so make sure you assert your assumptions clearly in the API implementation, and throw clear errors that are actionable by the developer and helps him\her to fix the problem
- Long running API's need to support multiple ways for calling for example Synchronous\Asynchronous\Call with Callback .. etc
- Authentication \ Authorization in some cases is very important, some API's might not be possible to use unless you have some level of permissions
The second dimension comes from the Web nature of the API
- Which style you want to use REST \ SOAP or something else
- The input & output format(s) needs to be clear and schematized if possible for example (XML Payload, or JSON payloads)
- Versioning needs to be well thought out early in the process, and how you would expect to provide newer versions of this API, for example if the version of the API will be part of the URI or part of the input payload or something else
- Authentication \ Authorization is much more complicated on the Web, you need to think about it
- HTTP is plain text, so if you have problems with that you need to provide either an SSL certificate or encrypt the payloads yourself
- Make sure you don't send too much data in the response, more data will take longer to transmit.
These are just few things, there are many more considerations you can look them up.