API Trend 现状
GraphQL
2012年 facebook内部开发,2015年公开公布,2018年 GraphQL项目转移到新成立的GraphQL基金会。
有利有弊, 对于简单的API并不是好的选择。
- 避免服务器大量冗余数据的返回
- 不能有效利用查询结构的web缓存
- 带来的灵活性和丰富性的同时 增加了复杂度
The GitHub GraphQL API 采用GraphQL API解决两大问题:
- scalability, 一次性同时提供客户端需要的信息,而不是像RESTFul API那样重复的请求几次获取需要的数据
- Collect some meta-information about our endpoint 给不同endpoint不同的OAuth权限范围,更灵活的分页,只获取用户需要的数据.
OPEN API(Swagger API)
OPEN API 从Swagger API 2.0发展而来
What’s the difference between Swagger and REST
the net result is that OAS(OPEN API Spec) is considered to be a standard specification for describing REST APIS. not just for developers to consume, it is also intended for usage by software .
是什么,一大特点
Versus older architectural styles, the specifics of the REST architectural style — their simplicity, their elegance, and their ability to rely on existing standard networking protocols like the one that makes the World Wide Web work (aka the “Hypertext Transfer Protocol” or “HTTP”) — have made it one of the more enduring and popular architectural styles for networkable APIs. This is one reason that REST APIs are sometimes also called “Web APIs.” Although it is not a requirement, most REST APIs rely on HTTP (the Web’s official protocol) to perform their magic.
这里解释REST架构API 为什么被称为 “Web API”
Restful API
RESTFul API设计指南
前端设备与后端进行通信,导致API架构的流行,甚至出现“API First”的思想。
RESTFul API是目前比较成熟的一套互联网应用程序的API设计理论。
协议
域名
版本
路径
HTTP动词
过滤信息
状态码
错误处理
返回结果
Hypermedia API
其他
Rest API backword compatibility
- Tests
- Always add parameters
- Do not make optional parameters be mandatory
- Always add additional HTTP response code returned by the API
- Never delete or modify existing HTTP Response code behavior
- Change URLs wisely
WSDL(Web Services Description Language )
网络服务描述语言
are complimentary to other older but still deeply entrenched networkable API architecture like “remote procedure call " or “RPC "
VS REST API
OAS is complimentary to the REST architectural style
参考
- How to maintain Rest API backward compatibility? https://zubialevich.blogspot.com/2018/09/backward-compatibility.html