One, REST Frame work
Rest is not technology-related, it represents a software architecture style, rest is the abbreviation for representational state transfer, and Chinese translates as "representational states transfer"
Rest looks at the entire network from the resource's perspective, which identifies the resources distributed across a node in the network through URLs, and the client application uses URLs to obtain representations of the resources, resulting in these applications transforming state
Rest is not technology-related, it represents a software architecture style, rest is the abbreviation for representational state transfer, and Chinese translates as "representational states transfer"
All the data, but the data obtained through the network or operation (increase and deletion), are resources, all the data as a resource is the most essential attribute of rest difference and other architectural style
For the resource-oriented architectural style of rest, a new architectural concept is proposed, namely: resource-oriented architecture (Roa:resource oriented Architecture)
?
Second, RESTful standard interface design
?
The API communicates with the user protocol, always using the HTTPS protocol. (Landlord Poor HTTP protocol)
Domain name
Https://api.example.com try to deploy the API to a dedicated domain name (cross-domain issues, two requests are sent)
Https://yuan.cn/api/recommends the use of such a cost-saving, simple API design
Version
URLs, such as: https://api.example.com/v1/
Raises multiple requests when a request header crosses a domain
The path, depending on what is on the network is a resource, is used to denote (plural)
Https://api.example.com/v1/zoos
Https://api.example.com/v1/animals
Https://api.example.com/v1/employees
Method
GET: Fetching resources from the server (one or more items)
POST: Create a new resource on the server
PUT: Update the resource on the server (the full resource after the client provides the change) (all changes)
PATCH: Update resources on the server (client provides changed properties) (the user may only need to change some of them, such as passwords, security issues, mailboxes, no need to change all)
Delete: Remove resources from the server
filtering, passing search conditions in the form of URL upload parameters
HTTPS://API.EXAMPLE.COM/V1/ZOOS?LIMIT=10: Specifies the number of records returned
HTTPS://API.EXAMPLE.COM/V1/ZOOS?OFFSET=10: Specifies the start position of the returned record
HTTPS://API.EXAMPLE.COM/V1/ZOOS?PAGE=2&PER_PAGE=100: Specify pages, and the number of records per page
HTTPS://API.EXAMPLE.COM/V1/ZOOS?SORTBY=NAME&ORDER=ASC: Specifies which attribute the returned result is sorted by, and the sort order
Https://api.example.com/v1/zoos?animal_type_id=1: Specifying filter criteria
Django RESTful specification