logoalt Hacker News

ChocolateGodlast Thursday at 5:13 PM5 repliesview on HN

Using JSON over the wire means you can re-use your backend between multiple frontends (like with mobile apps).


Replies

mrinterweblast Thursday at 9:40 PM

I have lost track of the number of times I have heard that argument, and implemented the API only to never have other API clients, or the API clients that do come later have very different needs and I need to create another API for that. I don't think API re-use is a strong argument unless the other client will be consuming the API imminently. I've heard the of "course we will have a native mobile app" argument enough times to often identify it as wishful thinking. Many clients are often satisfied with with a good web app.

yawaraminlast Thursday at 6:38 PM

You can also reuse your backend if you server HTML, thanks to content negotiation. The frontend sends a header that indicates what type of content it accepts, and the backend serves the according type.

Also, mobile apps often have different API needs than webapps, so they end up getting different APIs anyway.

array_key_firstyesterday at 1:55 AM

You can certainly try, but a lot of times the applications are different applications with different semantics so this doesn't work and you create a bunch more endpoints.

Liolast Thursday at 9:32 PM

You could use Hotwire Native for that. Also backends like Rails give you JSON APIs for free if you want them.

show 1 reply
mrinterweblast Thursday at 5:26 PM

Not all web applications need to be have an API that serves other clients. Often web apps are enough.