rest api_REST API简介

rest api

API stands for Application Programming Interface, and it’s an umbrella term that identifies different things.

API代表应用程序编程接口,它是一个笼统的术语,用于标识不同的事物。

We saw how the browser can offer some APIs, in the form of functions available to us.

我们了解了浏览器如何以可用功能的形式提供一些API。

We saw how Node.js offers us a programming API with its default modules.

我们看到了Node.js如何为我们提供带有默认模块的编程API。

API also means another thing: creating a service that exposes some specific functionality, provided through a server that can be accessed by multiple clients.

API也意味着另一件事:创建一个服务,该服务公开一些特定功能,该功能是通过服务器提供的,可以由多个客户端访问。

Broadly speaking, we currently have 2 categories of APIs: REST APIs and GraphQL APIs.

从广义上讲,我们目前有2类API:REST API和GraphQL API。

Other kinds of API paradigms exist, like SOAP for example, but they are not very popular in the JavaScript world.

存在其他种类的API范例,例如SOAP,但是它们在JavaScript世界中并不十分流行。

In this post we’ll talk about REST APIs.

在本文中,我们将讨论REST API。

终点 (Endpoints)

In a REST API, we create a number of endpoints that a client can access.

在REST API中,我们创建了许多客户端可以访问的端点

Say we want to expose a list of people. We can create an endpoint that will respond to the /people route.

假设我们要公开人员名单。 我们可以创建一个端点来响应/people 路线

If our service listens on the domain test.com, we’d have the test.com/people URL.

如果我们的服务在域test.com上进行侦听,则将具有test.com/people URL。

This endpoint will provide data in any format, but generally we use JSON, a handy text-based format used to communicate data between two services.

该端点将以任何格式提供数据,但是通常我们使用JSON (一种方便的基于文本的格式,用于在两个服务之间传递数据)。

This /people endpoint can provide a list of names of people, and an id for each person. This might be the id that we use to store them in the database, for example.

/people端点可以提供人员

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值