D
D
driverx182017-06-25 02:39:03
API
driverx18, 2017-06-25 02:39:03

They say social media API is RESTful, why?

It’s difficult for me to understand REST in principle, plus I read an article on Habré that restful api is a lie, in general, the concepts are blurred. But on the toaster I found a question where the answer was in short this:


All interaction with the server is reduced to 4 operations (4 is a necessary and sufficient minimum, in a specific implementation of the types of operations there may be more):
1. receiving data from the server (usually in JSON or XML format)
2. adding new data to the server
3 . modification of existing data on the server
4. deletion of data on the server

and I also saw interesting words:
Social networking APIs are quite typical examples of REST API implementations.

Well, from this, I basically understood that if the api can be accessed via POST, GET, PUT, DELETE - this is boldly called rest api. (Please clarify if I misunderstood).
But looking at the VK API, there is no work with PUT and DELETE, you can only work with POST and GET requests, why is it then REST?
How to define generally REST API from non-REST API?
I read a lot of articles, nifiga did not understand properly. What is worth reading in general in order to develop your own API (PHP)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2017-06-25
@nazarpc

https://ru.wikipedia.org/wiki/REST
I use not only POST, GET, PUT, DELETE methods in my APIs, but also additional custom ones, for example, if some component is installed in the system, I send a request using the INSTALL method, if I delete it then UNINSTALL, when I need to register a user, the method will be REGISTRATION , and when to get user access rights then GET_PERMISSIONS.
The result is a similar monotonous API structure that is very easy and natural to work with:

GET api/users/1
UPDATE api/users/1
CHANGE_PASSWORD api/users/1
GET api/users/1/persmissions
DELETE api/users/1
REGISTRATION api/users
SEARCH api/users

There is also a standardized format for responses when errors occur during processing of a request.
The wiki writes about this more formally (points 1-5), but since the requirements are quite general, the implementations differ significantly and nothing can be done about it.

S
Saboteur, 2017-06-25
@saboteur_kiev

The API allows you to basically work with anything.
And one of the important nuances of restful is that each request is independent and self-sufficient.
That is, if you know how to request data, you do it in one request, not a sequence.
The request itself is intuitive, well, something like this
get www.site.com/server/players/online
get www.site.com/server/players/registered
get www.site.com/character/rogue/stat
get www. site.com/character/rogue/classes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question