RESTful API design style

Common HTTP verbs

  • GET (SELECT): Remove the resource from the server (one or more).
  • POST (CREATE): a new resource on the server.
  • PUT (UPDATE): update the resource (after the complete resources provided by the client to change) in the server.
  • PATCH (UPDATE): Updating Resource (provided by the client to change the properties) in the server.
  • DELETE (DELETE): Delete the resource from the server

RESTful architecture design specifications:

URL is best not to appear verb, to make use of the plural noun

The URL can be the version number, the version number may be carried in the request header, but not as directly into the URL

Filtering parameters can be placed in the query string

For different operations, the server returns response data

To make use of the response data format JSON

Response status code: 1 ** (received, the need to continue treatment), 2 ** (request successful), 3 * (redirect requests), 4 * (Request error), 5 ** (Server Error)

The API should try to be deployed in the private domain name, if the API is very simple, and do not have further expanded on the main domain name can be considered under

RESTful API is best to do Hypermedia (ie the returned results provide links to other API methods), so that the user does not check the documents, but also know what to do next.

Guess you like

Origin www.cnblogs.com/Gdavid/p/11925000.html