Z
Z
ZaxapKramer2016-05-02 15:28:25
API
ZaxapKramer, 2016-05-02 15:28:25

Does it make sense to use a REST(ful) API to run the website itself?

Does it make sense? Create and use api for the operation of the website itself: drive all data through api (get a list of users, for example, delete, update, etc.).
Or make the API separate? What would be better and/or easier?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2016-05-02
@ZaxapKramer

It has.
For example, you have a backend site on WordPress, and the face of the site is made as an application on the backbone or some react thread.
In this case, it will be easier to use the ready-made rest api and not write your own code.
Well, or you may not have the entire site as a js application, but only some section.
Or you can implement the same loading of records when scrolling through the rest api, or something else.
In general, wherever you need to send an ajax request to the site and get data back, you can use the rest api. Note - not necessarily necessary, but possible. What is better, it is worth looking at a specific site / example.

V
VZVZ, 2016-05-02
@VZVZ

What does "drive all data through api" mean? Or rather, how can you NOT do it?
What do you understand by REST API? It is often understood differently.
As I understand it: REST API actually means neither AJAX nor JSON , but just a convenient form of URLs (CRUD, etc.), but it does not dictate any rules about AJAX and format (JSON, HTML or whatever).
But:
1) JSON creates brakes on the client in the browser (the client will be thick - JSON must be parsed and rendered in the DOM). Well, let the API be able to return both JSON and ready-made HTML, let's leave the first one to mobile desktop clients, and the second one in the browser - and everyone will be fine. Something like this is done by VK, Facebook and many others. others
2) brakes appear when there are simply a lot of heavy requests and a lot of logic on the client. Example: the entire Google portal. But it doesn’t smell of any API and architecture at all, as for me.
3) brakes appear when, for the sake of garbage, they reload the entire page, and not partially. But you can do AJAX. And the Ajax logic (HTML version of the API) will not differ much from the JSON version, one can be easily converted to another.

H
He11ion, 2016-05-02
@He11ion

the problem is that rest implies http requests in any case, inside the project it can give unnecessary overhead, however, this makes it easy to organize a microservice architecture / give out part of the api, so there is a choice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question