Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Okay, first off I'm a compete server noob. So I apologize if I upset you with my ignorance.

I've currently set up a linode and had it installed with MySQL and apache. Right now, I'm trying to learn how to use REST to communicate from my iphone app to the server.

I want the app to send the server a set of coordinates, and for the server to do a search over its data and return back a list of other nearby coordinates. I also want to communicate with as little bandwidth usage as possible.

I heard GET is a good way to do this, but I've also heard that info (such as the coordinates) can easily be read by outside sources. Security is an issue, and I want all info sent to or received from the server to be private. Should I use POST to achieve this? Is there a better way? Can I send a request with JSON (for less bandwidth usage)?

Also is REST even a good route to do this? A lot of the tutorials I'm seeing seem to just get or manipulate data tables, and there's not much server logic going on behind the scenes. Is SOAP or something else better?

I'm really unclear on a lot of this at the moment and my google-fu is getting me slow results, so any info at all will be immensely helpful.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Nether GET nor POST are secure over HTTP, if security is important you should probably look into getting an SSL certificate, even a self signed one would do - Providing you tell your 'client' (I'm guessing it's some sort of phone/tablet?) to trust the certificate.

REST is probably a good way to go about this because it gives you a nice simple standard. You might only have one endpoint at the moment but if you build in REST you could easily add more as your app grew. REST is a standard, rather than a protocol. This means, round and about, REST APIs should conform to these standards;

  • Sending data to the server should be done using POST
  • Getting data from the server should be done using GET
  • All endpoints/method should have their own URL (I.E. api.example.com/get_something rather than api.example.com/api?method=get_something)
  • Responses should be returned based on file type (So get_something.xml should return xml, get_something.json should return JSON etc., you don't have to support all formats but the ones you do should be request-able by file type).

In regards to the JSON issue, generally JSON will use more bandwidth (Only a tiny bit), but is a lot easier to work with.

Example, here's a plain text version of a possible API response;

-25.90962,161.08639
-4.11525,-91.31969
-13.76025,147.22927

But here's a response with JSON

{
    coordinates:[
        {
            lat: -25.90962,
            long: 161.08639
        }
        {
            lat: -4.11525,
            long: -91.31.969
        }
        {
            lat: -13.76025,
            long: 147.22927
        }
    ]
}

JSON has the example of being easily machine readable, whereas plain text would have to be parsed. And remember with file types like JSON you can use GZIP compression to dramatically reduce the data needed to be transfered

share|improve this answer
    
I see, thanks a lot for all the info. –  Vadoff Jul 22 '11 at 23:19
    
Just for clarification, would GET or POST be better when sending in a set of coordinates and asking for a list of nearby coordinates? I'm unsure as it's both trying to get something, and sending something in. –  Vadoff Jul 22 '11 at 23:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.