Confused about REST APIs

I am trying to understand what a REST based API is. As far as I understand, this is just an agreement on writing functions inside the API? Should all functions be in the form GET / POST / DELETE / PUT? So, for example, a function in the REST API may be

public string getLastName(User x)
{
    return x.lastName;
}

Am I mostly confused about how JSON / XML play a role in this?

+4
source share
3 answers

This is more than just an agreement. The concept of the REST API is that you access it using HTTP verbs and that the functions of these verbs have been displayed to perform the described action.

For instance:

GET will return data to the caller / sender

DELETE will delete the record

, HTTP . , RESTful Accept HTTP JSON XML, application/json application/xml, . , , API , HTTP.

JSON/XML?

JSON XML, . JSON (JavaScript Object Notation) ( GET) - , JavaScript, JS JSON , XML. , XML , . , / , . , JSON/XML REST API - , .

, MSDN : http://msdn.microsoft.com/en-us/library/dd203052.aspx

+3

REST . , , , REST, RESTful, REST.

, API?

, REST - API, SOAP HTTP, . REST - , , . , REST API -.

-, , , HTML , . - - , . , StackOverflow, , , , . , , -, - . - , .

REST API. - , , . , , , , . API , REST. .

API "street-REST", , , API, REST, , REST.

GET/POST/DELETE/PUT?

, , , CRUD-, REST .. .

REST - , , HTTP. REST , , , , . REST HTTP, , API HTTP -, HTTP, , HTTP. , API .

, REST. REST - , .

, JSON/XML ?

. REST , , . API - . REST . URI, , , , , . JSON/XML REST. -, , , text/html, .

, StackOverflow. , ? . ? , , , , .., . -, , URI, . , , URI http://stackoverflow.com/questions/24092517. , , URI, Accept, text/html, , HTML- . , , , , , , , , JSON XML.

, API- Street-REST, , , -. -, API . , JSON application/json, , , . , application/vnd.stackoverflow.question.v1+json StackOverflow, JSON. , , , , - . , , , .

, , REST. , - . , URI , , . , API, , , , , . -, URI, , API, .

+2

, JSON/XML ?

JSON/XMLcalled streaming data formats. There are others, but over the years these two have become so popular because of the low latency that they provide. XML is probably a little more popular than JSON, but JSON is more compact.

Another main reason for their use is that they are supported by almost all languages ​​and their structures.

-1
source

Source: https://habr.com/ru/post/1543633/


All Articles