Introduction to APIs - How APIs Work

举个例子:Client-Server Communication
When you got to a bank, the bank teller acts as an intermediary or interface between you and the bank vault. And this is the same type of relationship we see in client-server communication: The user or client makes a request to the API server, which parses the requests, queries the database, formats a response and then sends it back.

Here is the process listed out:

  1. Client sends a request to the API server
  2. The API server parses that request
  3. Assuming the request is formatted correctly, the server queries the database for the information or performs the action in the request
  4. The server formats the response and sends it back to the client
  5. The client renders the response according to its implementation

如果上面的例子,很难理解,再提供一个例子
A customer talks to the waiter and tells the waiter what she wants. The waiter takes down the order and communicates it to the kitchen. The kitchen does their work, creating the food, and then the waiter delivers the order back to the customer.

In the metaphor, a customer is like a user, who tells the waiter what she wants. The waiter is like an API, receiving the customer’s order and training the order into easy-to-follow instructions that the kitchen then uses to fulfill that order - often following a specific set of codes, or input, that the kitchen easily recognizes. The kitchen is like a server that does the work of creating the order in the manner the customer wants it, hopefully! When the food is ready, the waiter picks up the order and delivers it to the customer.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值