当前位置:网站首页>An example illustrates restful API
An example illustrates restful API
2022-06-24 21:03:00 【Messenger Xiaolin】
1.Restful API
In a word, it means comply with REST Style API, It's through HTTP It's a simple verb (GET\POST\PUT\DELETE) To execute resources . So what is REST Style , When I saw the words (REpresentational State Trasfer, Presentation layer state transition ) The meaning is very obscure , I will remember the following with examples .
When Xiaochong wants to see the salary comparison of other colleagues , Do the following .
1. A web page for entering company employee information , Search element keywords “ Xiaozhi ”
2. Click on the personal information page of Xiaozhi's colleagues
3. Click salary details to view specific salary information
2.RESTful API Design style of
Let's talk about it with examples RESTful API Design style of :
1. resources It is the salary information of Xiaozhi's colleagues , Jump out of the example itself , Resources are anything , Such as images , data , Songs, etc . Resources can be represented by vectors , For example, pictures can be used JPG Format , The text can be used TXT Format , At present, the most popular expression vector is JSON.
2.URI Uniform Resourse identifier, Unified resource location . Through one URI You can only apply to resources . The first step for the above example is to enter a web page to find the information of the entire company's employees .
3. Unified interface style The operation of data is inseparable from CRUD (create,read,update,delete), Corresponding to HTTP Method :GET Access to resources ,POST New resources ( Or update resources ),PUT Update resources ,DELETE Delete resources . Through the above HTTP Method unifies the operation of data .
4. No state That is, all resources can be accessed through URL Direct positioning , Not dependent on other resources or states . It can be seen that , Each step of the above example depends on the previous step , That is, you can't reach it directly and skip to the 3 Step , This is it. A stateful ; If you can do it in one step , Enter... On the website URI Then we go directly to the third step , This is the case No state .
6. route (Endpoint) Express API The specific website of , For example, the path to information about colleagues can be :https://api.example.com/v1/tongshi
https Is a communication protocol ,api.example.com Is the domain name ,v1 It's the version number ,tongshi Representing the resources of colleague information
7. Filtering information (Filtering) Information is huge , To limit the amount of information or specific information , The server in the background (server) The returned results will be filtered according to the front-end parameters .https://api.example.com/v1/tongshi?limit=100
?limit=100: On behalf of the specified return 100 Bar record
3. Why use this style API Well ?
First of all, let's explain API:(APplicantion interface ) Application program interface , It can be understood as a bridge between the front and the back , The front end calls API Make a request to the background , Backstage server After processing the completion request , Can respond to the front end ;
Use RESTful API Why : backstage server While processing data , Can be through a variety of media ( The android mobile phone ,PC The computer , Apple tablet, etc ) Front end incoming of . In order to enable a background to process many different types of front-end data , Then we need to follow a unified style of interaction .
4.Google about Rest API The explanation of
Said so much , Now it is not difficult to understand the following “ official ” Explained
A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer and was created by computer scientist Roy Fielding.
REST API( Also known as RESTful API) Is an application programming interface (API or web API), It conforms to REST Architectural style constraints , Allow and RESTful web Services interact .REST Represents the transfer of a concrete state , By computer scientists Roy Fielding establish .
REST is a set of architectural constraints, not a protocol or a standard. API developers can implement REST in a variety of ways.
REST Is a set of architectural constraints , Not an agreement or standard .API Developers can implement... In many ways REST.
https://www.redhat.com/en/topics/api/what-is-a-rest-api
边栏推荐
- After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
- 伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI
- Responsibility chain mode -- through interview
- [performance tuning basics] performance tuning standards
- How to enhance influence
- JMeter response assertion
- Visitor model -- generation gap between young and middle-aged people
- Postman assertion
- Prototype mode -- clone monster Army
- Intermediary model -- collaboration among departments
猜你喜欢

伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI

Basic concepts and definitions of Graphs

Sequential stack traversal binary tree

Image panr

Background of master data construction

yeb_ Back first day

Design of routing service for multi Activity Architecture Design

图像PANR

JMeter response assertion

Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year
随机推荐
C language to realize mine sweeping (simple version)
Mr. Hu Bo, CIO of weiduomei, a scientific innovator: digitalization is a bloodless revolution, and the correct answer lies in the field of business
情绪识别AI竟「心怀鬼胎」,微软决定封杀它!
Haitai Advanced Technology | application of privacy computing technology in medical data protection
Vxlan and MPLS: from data center to Metro Ethernet
Packaging_ Conversion between basic type and string type
Summary of idea practical skills: how to rename a project or module to completely solve all the problems you encounter that do not work. It is suggested that the five-star collection be your daughter
"Ningwang" was sold and bought at the same time, and Hillhouse capital has cashed in billions by "selling high and absorbing low"
JMeter parameterization
顺序表的基本操作
Stackoverflow annual report 2022: what are developers' favorite databases?
主数据建设的背景
Can the OPDS SQL component pass process parameters to the next component through context
I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
Agency mode -- Jiangnan leather shoes factory
Dongyuhui is not enough to bring goods to "rescue" live broadcast
Tool composition in JMeter
基于SSM的物料管理系统(源码+文档+数据库)
Batch capitalization of MySQL table names
Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO