Autocomplete - POST or GET?

166 views
Skip to first unread message

Alejandro Mantecón Guillén

unread,
Mar 8, 2013, 4:43:44 AM3/8/13
to api-...@googlegroups.com
Hello all,

This is my first post in this group :)  I was wondering what the best practice would be for an auto-complete response from an API. It is one of those weird cases in which the response doesn't really involve a resource. 

So for example, if we were talking about names, the client-side would send a string (such as "jon") and wold receive an array of suggestions ("Jonatan, Jonas, Jones...").

Would it be better to have it as a GET request with the parameter on the URL?  URL?str=jon

OR

Would a POST/PUT be more appropriate with the string on the payload? {"str": "jon"}

Thanks for your help!

Mike Kelly

unread,
Mar 8, 2013, 5:35:16 AM3/8/13
to api-...@googlegroups.com
The client's retrieving a list of stuff from the server - which means
it's a safe, idempotent request. You should just use GET, as this will
allow you to use web caching. Not sure why don't consider it a
resource.

Cheers,
M
> --
> You received this message because you are subscribed to the Google Groups
> "API Craft" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to api-craft+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/api-craft?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Mike

http://twitter.com/mikekelly85
http://github.com/mikekelly
http://linkedin.com/in/mikekelly123

Kris Kleva

unread,
Mar 25, 2013, 10:57:58 PM3/25/13
to api-...@googlegroups.com
I used GETs.  However, be sure to use heavy caching (browser, cdn, app server, etc) and even consider holding keyword lists in application server memory space verses reading from disk.  IMHO, a response from an autocomplete should be no more than 200 ms before it begins annoying the end user so do what ever you can do to make it fast while having a large number of possible keywords.

Daniel Roop

unread,
Mar 27, 2013, 10:01:28 AM3/27/13
to api-...@googlegroups.com

+1 GET

The RESTFul WEb Services Cookbook refers to this as a Compute/Processing Function (Recipe 2.5).

Reply all
Reply to author
Forward
0 new messages