V
V
VZVZ2016-02-28 16:09:46
JSON
VZVZ, 2016-02-28 16:09:46

How to briefly name the RESTful API, which, it turns out, is not RESTful at all, because it returns JSON / XML, does not use HTTP error codes, and the URLs are not the same?

I always thought that such a familiar API that returns JSON (less often XML), does not use (or almost does not use) HTTP error codes (instead of them, again, everything is in JSON) and has a free URL format, this is the REST API , and it's also a RESTful API.
Twitter also thinks so:
https://dev.twitter.com/rest/public
And today I googled this term, read a couple of articles on Habré - and I see there about some URL patterns like /images/ and /images/1, about some PUT and DELETE, about error codes ...
It turns out that that's what was originally called REST.
And what's more: Googling "rest api json", I see some articles where they write, as if with JSON, then this is not a REST API at all!
Conclusion: let's not call it a REST API.
What about in return?
And in return... Nothing.
I saw the word "JSON-pure API", but it is rare, but what if not only JSON, but also XML? Just "Pure API"? They won't understand at all, I'm afraid ...
PS Another interesting question: if the REST API is when without JSON and XML (ie, on HTML), then what kind of API is it then ?!
This is not an API, but some kind of raw meat, designed for the browser, and not for the programmer, who will still write under it.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Makarov, 2016-02-28
@Nipheris

I see some articles where they write that if with JSON, then this is not a REST API at all!

Links to articles please. There, either the author fantasizes, or he is misunderstood. The only reason the author could say that is because most modern RESTful APIs are not hypermedia. But this does not mean that you should not use the same JSON in principle, it only means that you need to strive to include hypermedia capabilities in it (see JSON-LD , HAL , Siren ) and build the API itself on this idea, which is that you have one "entry point", and you get to all other resources available in the API by following links inside other returned resources, just like you go to a site, knowing its domain name, and then go to links.
However, in practice, no one knows how to use it yet, there are only a few hypermedia APIs now. Most APIs involve reading documentation with hard-coded resource URLs to access. Links from one resource to another are rarely used.
But mistakes are still worth using.
RESTful API and MVC - what is it?
This is already a matter of taste. People dislike XML in APIs because its model is suitable for describing hierarchical data and documents, but not for the usual object-oriented relationships between entities (it was created to represent documents, not web services). Therefore, the popularity of JSON is growing all the way. Many old APIs still use XML, and JSON-pure is a way to brag that your API is all JSON. The very idea of ​​RESTful says nothing about response formats, except that the format is desirable to be hypermedia.

A
Alexey Nikolaev, 2016-02-28
@Heian

The REST Api is based on one thing: visibility of links, and one link equals one action. PUT \ DELETE are rarely used because they are not universally supported, and for full compatibility with all servers and systems, they are replaced by POST \ GET accordingly.
And REST is not SOAP, which is thoroughly saturated with formalization and protocols (the same as the enterprise), and should only return XML in a certain format. The REST API can respond the way the programmer needs it, and json is perhaps the most convenient way to respond in 95% of cases.
The most important thing in REST is the structure of the API itself, which should be clean, descriptive and meet the "one action - one request" requirement mentioned above. That is, a structure of the form

/user/1/delete
/user/create
/user/1/getinfo

will be a REST API, regardless of what format the server will give.
Answer to the question: REST API.

S
SirotaKazansky, 2020-07-12
@SirotaKazansky

RESTful is something that complies with the restrictions of REST, no one obliges you to use HTTP, some URL formats, HTTP methods, json or XML. You can even send messages on carrier pigeons in the Russian obscene format, and make a RESTful API based on them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question