0

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.

Ritesh Prajapati
  • 953
  • 2
  • 13
  • 22

1 Answers1

0

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.

Alexander Perechnev
  • 2,797
  • 3
  • 21
  • 35
  • That is good for providing information. Do you have basic flow about how mobile application will communicate with any Linux Custom embedded board through JSON-RPC call? – Ritesh Prajapati Feb 11 '15 at 09:49
  • @RiteshPrajapati Usually I use Python+Flask to implement the server side. But it is up to you how to implement your own application. – Alexander Perechnev Feb 11 '15 at 09:53