News for hackers. Stuff that matters.
Re:Show HN: Deck of Cards – A playing card API by geon on Monday May 11, 2015 @04:32AM (#9523355)
I like my REST interfaces, but they only really fit CRUD-like situations. Sometimes, you will want to be less restful to optimize for some real world issue, most likely latency.

I suppose it is a bit like de-normalizing your database for performance.

For a situation like this, I would keep it as restful as practically possible. Since the shuffle mutates the state, it should be a post/put. Since it doesn't create a new resource,you could argue it should be put, but you don't have new data anyway, so the point is kind of moot.

I'd probably collect my custom verbs behind a common path to make it more clear, like

    /api/decks/mydeckid/verbs/shuffle
Or to make it stand out more:

    /api/decks/mydeckid?verb=shuffle
The response would use http error/success codes like any rest interface.
Re:Show HN: Deck of Cards – A playing card API by vladharbuz on Monday May 11, 2015 @04:38AM (#9523368)
If you do this, you are basically doing RPC, so in reality you've given up any RESTfulness.
Re:Show HN: Deck of Cards – A playing card API by geon on Monday May 11, 2015 @06:37AM (#9523702)
Hence, "a bit like de-normalizing your database".
Re:Show HN: Deck of Cards – A playing card API by lmm on Monday May 11, 2015 @05:36AM (#9523544)
You've gained the useful parts of REST - lower transport overhead than SOAP, and being able to call it from a browser.
Re:Show HN: Deck of Cards – A playing card API by michaelmior on Monday May 11, 2015 @06:58AM (#9523771)
What's stopping you from calling SOAP APIs from a browser? Most use HTTP as the transport mechanism.
Re:Show HN: Deck of Cards – A playing card API by lmm on Monday May 11, 2015 @11:55AM (#9525628)
SOAP APIs tend to use POST even for readonly methods, and tend to use aggressively validated XML that's much harder to write by hand than typical "REST" JSON.
Re:Show HN: Deck of Cards – A playing card API by michaelmior on Monday May 11, 2015 @03:05PM (#9527115)
I'm sure why using POST for readonly methods is a problem in the browser. It potentially messes with caching, but it should still function correctly. (Granted, this is probably a poor design design decision, but has nothing to do with correct functionality.)

As far as constructing the XML, you should be able to use something like xmlbuilderjs[0]. That said, I completely agree that dealing with REST APIs in the browser is far more practical.

[0] https://github.com/oozcitak/xmlbuilder-js/

Re:Show HN: Deck of Cards – A playing card API by geon on Monday May 11, 2015 @06:36AM (#9523695)
Plus, for the CRUD parts, it's still REST.