I am new for RESTful API Protocol and want to create that protocol for generic mobile application under Linux System with help of http server.
Does any one has idea or document to start RESTful API Protocol development for mobile application?
Please provide me or help me to develop protocol as soon as possible.
First of all, you have to know that RESTfull is not a protocol. It is just a few recomendations which describe how you have to implement your protocol.
Next, you have to make sure that you need to follow RESTfull rules. In most cases simple JSON-RPC is enough for mobile applications.
Here is a simple example. Let's say that you want to implement a chat in you iOS/Android app. In this case you need just few methods:
GET /chat/list # list existing chats
params: {}
GET /chat/134/messages # get messages from chat 134
params: {
page: 0
}
POST /chat/134/send # send message
params: {
text: "Hello everyone!"
}
This is just very simple API which is enough for mobile application. But if you want to follow the RESTfull concept, you have to implement your API like:
GET /chat/ # list existing chats
GET /chat/134/messages/ # get messages from chat 134
POST /chat/134/messages/ # send message to chat
It is still too clear, but in this case chat
and messages
are different entities, and in more complicated application you will have to add entities.
For example, if you want to update the title of your chat, in RESTfull you have to do something like:
UPDATE /chat/134/
and send new title in HTTP-header.
But in simple JSON-RPC it looks more easy:
POST /chat/134/changeTitle
params: {
title: "we are talking about cats"
}
Okay, it's still a simple example, but if we want to ban some user in chat, how we should implement it following the RESTfull paradigm? It will be looking like:
DELETE /chat/134/users/23/
Okay, we can to it. But DELETE
method is not a BAN
method. There is no BAN
method in HTTP-protocol. So we have to use DELETE
or extend HTTP-protocol with new method. So complicated solution for such simple operation, isn't it?
But in case of simple JSON-RPC, we can just add new method:
POST /chat/134/banUser
params: {
userId: 23
}
So I suggest you to think more before you bind your implementation to RESTfull paradigm. In most cases simple JSON-RPC is more than enough for mobile applications and it is more easy to understand and implement.