APIs是当今庞大的软件生态系统的核心。bob电竞官方下载几乎有无限的方法可以连接各种Web应用程序,并且API为这些整合behind the scenes. So, if you want to connect your app or service to the digital world, it’s worth understanding how APIs work.

One key thing to know about APIs is that not every software integration is the same — therefore, not all APIs are the same. There are different categories of APIs based on different protocols, functions, and access levels.

为了使公司的API根据需要工作,选择bob全站app正确的类型很重要。例如,与公众共享数据的API可能与仅用于您的员工内部使用的API具有不同的构建。

In this guide, we’ll introduce you to the different types of APIs, so you’ll know which to pursue in order to share your company’s data efficiently and safely.

立即下载:HTML&CSS的免费介绍指南

What are the different types of APIs?

引用API时,我们通常会谈论称为Web API的API子类别。Web API是使用超文本传输​​协议(HTTP)访问的API,该协议与在浏览器中获取和显示网页相同的协议。

We can divide Web APIs into groups by intended level of access and scope of use. There are four widely agreed-upon types of web APIs: open APIs, partner APIs, internal APIs, and composite APIs.

Open APIs

Open APIs, also known as public APIs or external APIs, are available to use by any developer. As a result, open APIs typically have relatively low authentication and authorization measures, and are often restricted in the assets they share. While一些开放的API是免费的, others require a subscription fee to use, which is often tiered based on the number of calls made to the API.

There are several advantages to making APIs public, the biggest being the ability to share data openly. This encourages any external business or developer to integrate with the app that owns the API, making both the third-party software and the API more valuable. Because of the lack of restrictions and easy implementation allowed by the open API, third parties can quickly leverage the data it provides.

For example, the traffic app Waze uses public APIs provided by municipalities and other partners about road closures, accidents, construction delays, and service vehicles. In turn, Waze makes cities easier to navigate, which pleases residents and attracts more visitors.

Partner APIs

合作伙伴API在外部共享,但仅在与提供API的公司有业务关系的人中。bob全站app访问仅限于具有官方许可的授权客户,因此security measures与公共API相比,与合作伙伴API相比,与合作伙伴API更强大。

Some businesses favor partner APIs because they want (1) greater control over who can access their resources and (2) more say in how those resources are used. For example, Pinterest adopted a submission-based approach to providing access to new data services via its API, requiring partners to submit a request detailing how they would like to use the API before being granted access.

Internal APIs

Unlike open APIs and partner APIs, internal APIs (also called private APIs) are not intended for use by third parties. Internal APIs are only made available for use inside a company and are meant to streamline data transfers between teams and systems. Developers working for the company can use these APIs, but external developers can’t.

由于内部API在公开发布的软件开发套件(或在某些情况下)都没有记录下来,因此它们通常完全被公众隐藏。bob电竞官方下载但是,许多公司最终确实以其内部API公开。

Using APIs for internal data transfers is regarded as more efficient, secure, and traceable. It’s also a scalable solution — when a business introduces a new internal system, this system can communicate with existing systems via their APIs.

复合API

复合API结合了多个API,允许开发人员捆绑电话或请求,并从不同的服务器接收一个统一的响应。如果您需要来自不同应用程序或数据源的数据,则将使用复合API。另外,您可以使用复合API来启动自动呼叫和响应链,而无需干预。

Because they reduce the number of total API calls, composite APIs can result in less server load and overall faster systems, as well as reduced complexity in the system. They’re commonly deployed in微服务in which one job may require data from many internal APIs to complete.

以此示例为例:说您想在购物车API中创建订单。您可能会认为这只需一个请求。但是,实际上,必须提出几个请求。首先,您需要创建客户资料。然后,您需要创建订单,添加一个项目,添加另一个,然后更改订单的状态。与其连续进行五个单独的API呼叫,不如使用复合API进行一个。

API体系结构的类型

我们也可以从API上理解其架构。API的体系结构包括指导API可以与客户共享的信息以及如何共享数据的规则。休息,肥皂和RPC是当今最受欢迎的API架构 - 让我们更详细地解开每个API架构。

REST

Today, the majority of web APIs are built on REST. REST, which stands for representational state transfer, is a set of guidelines for scalable, lightweight, and easy-to-use APIs. A REST API (or “RESTful” API) is an API that follows REST guidelines and is used for transferring data from a server to a requesting client.

For a more in-depth look at REST guidelines, see our fullguide to REST APIs. Briefly, these guidelines are:

  • Client-Server Separation:All client-server interactions must be in the form of a request from the client, followed by a response from the server. Servers can’t request and clients can’t respond.
  • Uniform Interface:All requests and responses must use HTTP as the communication protocol and be formatted in a specific way to ensure compatibility between any client and any server. Server responses are formatted in JavaScript Object Notation (JSON).
  • 无状态:Each client-server interaction is independent of every other interaction. The server stores no data from client requests and remembers nothing from past interactions.
  • Layered system:即使通过客户端和API之间的中间服务器,请求和响应也必须始终以相同的方式进行格式。
  • 可缓存:Server responses should indicate whether a provided resource can be cached by the client and for how long.

By following these guidelines, REST APIs can be used for quick, easy, secure data transfers, making them a popular choice among developers.

SOAP

SOAP(简单对象访问协议)是用于跨网络传输数据的协议,可用于构建API。肥皂是由World Wide Web Consortium (W3C)and utilizesXML编码信息。

肥皂严格定义了如何发送消息以及其中必须包含的内容。这使SOAP API比REST API更安全,尽管严格的指南也使它们更加较重,更难实施。

For this reason, SOAP is often implemented for internal data transfers that require high security, and the more flexible REST architecture is deployed more commonly everywhere else. But, one more advantage to SOAP is that it works over any communication protocol (not just HTTP, as is the case with REST).

RPC

The RPC (Remote Procedural Call) protocol is the most straightforward of the three architectures. Unlike REST and SOAP that facilitate the transfer of data, RPC APIs invoke processes. In other words, they execute scripts on a server.

RPC API可以在其呼叫中使用JSON(JSON-RPC协议)或XML(XML-RPC协议)。XML比JSON更安全,更具包容性,但这两个协议否则相似。尽管RPC协议是严格的,但这是在远程网络上执行代码的一种相对简单简便的方法。

RPC APIs are limited in their security and capabilities, so you likely won’t see them as often as REST or SOAP APIs on the web. However, it can be used for internal systems for making basic process requests, especially many at once.

选择正确类型的API

To summarize, we can group web APIs into four broad categories:

  • Open APIs, which any developer can access.
  • Partner APIs,只有授权开发人员才能访问。
  • Internal APIs, which only internal teams may access.
  • 复合API, which combine multiple APIs.

API体系结构也有三种常见类型:

  • REST,轻巧,可扩展的Web API的指南集合。
  • SOAP,更安全的API的更严格的协议。
  • RPC,用于调用可以使用XML编写的过程的协议(XML-RPC)或json(JSON-RPC)。

If you’re not someone who needs to know the gritty-gritty, this is a good baseline understanding of the types of APIs out there and how developers use them. By harnessing the right API, you’ll empower your business to partner with other applications, expanding your reach and influence.

New Call-to-action

CSS简介

Originally published Aug 26, 2021 7:00:00 AM, updated August 26 2021

Topics:

Application Programming Interface (API)