V
V
Vasya Surname2017-07-06 17:05:15
API
Vasya Surname, 2017-07-06 17:05:15

Is it worth it to start developing a site right away with the API?

The idea is to write an API for the site right away. Well, for example, select 10 news items in the required format:
for this, we make a GET request and format get=news&limit=10&type=jsonit as we please.
As a result, we get 10 news in the json array with the necessary information. I see some advantages from such a development - for example, you can change the framework or even the language without touching the frontend.
Is this design approach applicable? And maybe there are ready-made solutions that you can read about. Or are there some significant downsides that I'm not aware of?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy Volf, 2017-07-06
@bazilio2010

for example, you can change the framework or even the language without touching the frontend.
In most cases, you can change the framework without touching the frontend. For example, if your framework uses the "Twig" template engine. In some cases, it is also possible to change the language by subjecting the templates to minimal modification, which can be done via "Find/Change". But, if I were you, I would not flatter myself too much on this "opportunity".
Well, for example, select 10 news in the desired format,
make a GET request
Usually a POST request is made, and not in the format of the address bar (GET parameters), but is sent in the same way, a request in JSON format. Notice the keyword "usually", ie. not always .
Is this design approach applicable?
It's more of a development approach, client-server level, and/or REST API.
And maybe there are ready-made solutions that you can read about.
It is not entirely clear what kind of ready-made solution you want to receive. HTTP clients and JSON data processing built into many languages, or implemented as ready-made libraries.
Or are there some significant downsides that I'm not aware of?
If you want to develop, for example, a desktop or phone (as an example) client application, then this is one of the best options. If you want to build a normal site according to this principle, then you will simply introduce a new level of abstraction and a new link in the chain, which will complicate the work for yourself, as well as potentially slow down the project.
As I understand it, you want to wrap an RDBMS (SQL-DB) running over a (unix-)socket into more primitive APIs that return JSON responses? Why didn't you like the answer in the "SQL result resource" format? :) When using RDBMS (and not only), you can also change the template engine, the framework, the language and everything else, and write the necessary functionality at the level of the database itself, in the form of stored functions / procedures, without additional, unnecessarydata transmission chains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question