当前位置:网站首页>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
边栏推荐
- Internet of things? Come and see Arduino on the cloud
- Hongxiang Yunteng is compatible with dragon lizard operating system, and the product runs stably
- Create a multithreaded thread class
- maptalks:数据归一化处理与分层设色图层加载
- 等保备案是等保测评吗?两者是什么关系?
- Stackoverflow annual report 2022: what are developers' favorite databases?
- The AI for emotion recognition was "harbouring evil intentions", and Microsoft decided to block it!
- Leetcode (135) - distribute candy
- Responsibility chain mode -- through interview
- Basic operation of sequence table
猜你喜欢
[performance tuning basics] performance tuning strategy
二叉树的基本性质与遍历
传统的IO存在什么问题?为什么引入零拷贝的?
主数据建设的背景
网络安全审查办公室对知网启动网络安全审查
海泰前沿技术|隐私计算技术在医疗数据保护中的应用
Handling of garbled JMeter response data - three solutions
What does virtualization mean? What technologies are included? What is the difference with private cloud?
Difference between map and object
Talking about the range of data that MySQL update will lock
随机推荐
使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value
Image panr
How to apply agile development ideas to other work
Openvino2022 dev tools installation and use
Network security review office starts network security review on HowNet
Simpledateformat thread unsafe
Basic properties and ergodicity of binary tree
CVPR 2022 remembers Sun Jian! Tongji and Ali won the best student thesis award, and hekaiming was shortlisted
JMeter response assertion
After 5 months' test, it took 15K to come for an interview. When I asked, it was not worth even 5K. It was really
Learn together and make progress together. Welcome to exchange
Leetcode(135)——分发糖果
图像PANR
Leetcode (146) - LRU cache
Responsibility chain mode -- through interview
Memo mode - game archiving
Shrimp skin test surface treated
Byte and Tencent have also come to an end. How fragrant is this business of "making 30million yuan a month"?
After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it
云计算发展的 4 个阶段,终于有人讲明白了