Implementing The API | REST | JSON-RPC | XML-RPC | SOAP
In this article we discuss API and Implementing The API with most common standard that we used. I already publish a post about API (Application Programming Interface).
What is API ?API stands for Application Programming Interface. According to Wikipedia, the definition of API or Application Programming Interface is as follows:“In computer programming, an Application Programming Interface (API) is a set of subroutine definitions, protocols, and tools for building application software.”Read this article for more information- What is an API?
You may also like : Difference between Data and Information
Implementing the API
We know that An API defines the messages that are sent from client to server and from server to client. Ultimately, we can send data in whatever format you want, but it is almost always better to use an existing standard because convenient libraries will exist for both client and server to produce and understand the required messages.
Now i am going to explain few most common standards that you should consider:
REST (Representational State Transfer) :
Access a set of web URLs like http://temp.iotbyhvm.ooo/temp1 or http://temp.iotbyhvm.ooo/temp1/1234 using HTTP methods such as GET and POST, but also PUT and DELETE. The result is often XML or JSON but can often depend on the HTTP content-type negotiation mechanism.
JSON-RPC :
Access a single web URL like http://temp.iotbyhvm.ooo/api , passing a JSON string such as {‘method’ : update, ‘temp’ : [ { ‘ temp-id’ : 1234 } , ‘ description ‘ : ‘ writing API for temp device ‘ ] , ‘ id ‘ : 12 }. The return value would also be in JSON, like { ‘ result ‘ : ‘OK’ , ‘error’ : null , ‘id’ : 12 }.
XML-RPC :
This standard is just like JSON-RPC but uses XML instead of JSON .
SOAP (Simple Object Access Protocol) :
This standard uses XML for transport like XML-RPC but provides additional layers of functionality, which may be useful for very complicated systems.
So these are few most common standards. You can use any one according to your requirements. I recommend using REST, but you may have reasons to use another common standard. For example, if you are trying to replicate the interface of another XML-RPC service, or you are already familiar with SOAP from other projects, that may all trump the other factors.
Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.
Recommended :