一文搞懂:API是什么?有何用?怎么用?

API——什么是 API?

API(应用程序编程接口)是一组用于两个应用程序之间通信的规则和规范。简单来说,API允许一个程序与另一个程序交互。例如,你可以开发一个让用户通过FacebookMessenger互发消息的应用。在底层,你可以使用Facebook Messenger API,通过自动化实现这些API调用,将该功能集成到你的应用中。

API——An API (Application Programming Interface) is a set of rules andspecifications used to communicate between two applications. In simpleterms, an API allows one program to interact with another program. Forexample, you can create an app that lets users send messages to each otherthrough Facebook Messenger. Under the hood, you can use Facebook MessengerAPI to integrate this functionality into your application using automationto implement these API calls.


API究竟是什么?API的作用是什么?API的全称

API代表什么?
API代表应用程序编程接口(不要与美国石油协会混淆)。API是允许技术产品和服务通过物联网(IoT)相互通信的一组定义和协议。

What exactly is an API? What does an API Do? API Full Form
What does API Stand for?
API stands for Application Programming Interface. An API (not to be confused with the American Petroleum Institute),an acronym for Application Programming Interface, is a set of definitionsand protocols that allow technology products and services to communicatewith each other via the internet of things (IoT).


API的用途

如果你是编程新手,可能会好奇API的定义。API(应用程序编程接口)允许你的应用通过一组简单的命令与外部服务交互。拆分名称来看,“接口”是不同软件组件交互的地方。使用API能让开发者快速为应用添加特定功能,加速开发流程。

What are APIs used for?
If you are a beginner programmer, you may be wondering what the definitionof API is. An API (Application Programming Interface) allows your applicationto interact with an external service using a simple set of commands. Tobreak down the name, the "Interface" is where different software componentscan interact. Using an API allows developers to add specific functionalitiesto their applications and can speed up the development process.


API的作用

简单来说,API充当两个或多个应用之间的中间人,接收消息并返回响应。开发复杂应用时,所有数据操作代码都写在服务器上,用户无法在客户端直接访问——这主要是出于安全考虑。服务器是托管在其他地方的独立应用。

要从服务器获取数据,必须使用服务器的API。API会根据客户端的认证级别返回响应。API不仅用于获取数据,还可用于在服务器上创建、删除或交换数据。

What does an API do?
In simplest terms, an API acts as a middleman between two or more applications,accepting messages and returning a response. When developing a complexapplication, we write all of the data manipulation code on the server,which is not accessible to the user on the client side. It is primarilyfor security reasons. A server is a separate application that is hostedelsewhere.

To obtain data from the server, we must use the server's API. The APIwill return a response to the client based on their authentication level.An API isn't just for getting data. It can also be used to create, delete,or exchange data on the server.


API示例与用例

以打车应用为例:注册后,你可以规划路线、寻找司机并支付车费,全程无需离开应用。打车应用可能通过集成多个API实现这些功能:

  • 1.Telesign API验证手机号 

  • 2.地图API计算行程时间和距离 

  • 3.Nexmo短信API通知司机到达 

  • 4.Stripe API处理支付 

  • 5.SendGrid API发送电子收据 

查看以上1-5类API,可浏览以下网址:

  • 1.sms: https://rapidapi.com/telesign/api/telesign-sms-verify

  • 2.maps: https://rapidapi.com/blog/top-map-apis/

  • 3.Nexmo: https://rapidapi.com/user/nexmo

  • 4.Stripe: https://rapidapi.com/search/stripe

  • 5.SendGrid: https://rapidapi.com/sendgrid/api/sendgrid

    API Examples and Use Case
    Consider a ride-share app: First, you sign up for the ride-share application.Then, you can map your route, find your driver, and pay for the ride allwithout ever leaving the app.

    The ride-sharing app is likely using APIs to make all of this work. Forexample:

    • Telesign API verifies your phone number.

    • Maps API calculates ride time and distance.

    • Nexmo SMS API notifies you of driver arrival.

    • Stripe API processes payments.

    • SendGrid API emails your receipt.


    API类型(按架构分类)

    1. REST API:支持客户端与服务器之间的CRUD操作(创建、读取、更新、删除)。

    2. GraphQL API:查询语言,允许客户端精确请求所需数据,避免数据冗余或不足。

    3. SOAP API:符合SOAP规范的Web服务。

    4. (详见:https://www.w3.org/TR/soap/)

    5. Kafka API:事件流平台,支持发布/订阅、持久化存储和实时处理事件流。

    6. 异步API:基于事件驱动架构(EDA),发布者通过消息代理通知订阅者。

    Types of APIs (by Architecture)

    1. REST APIs: Allow CRUD (create, read, update, delete) operations between clientand server.

    2. GraphQL APIs: A query language for precise data fetching.

    3. SOAP APIs: Web services compliant with the SOAP specification.

    4. Kafka APIs: An event streaming platform with publish/subscribe capabilities.

    5. Async APIs: Follow Event-Driven Architecture (EDA) via message brokers.


    API管理

    API管理指通过设计、发布、保护、监控和分析API最大化其价值的过程。它包括工具、技术和流程,确保API可访问、可发现且安全,同时提供使用数据和性能洞察。

    What is API Management?
    API management refers to the process of designing, publishing, securing,monitoring, and analyzing APIs to maximize their value. It ensures APIsare accessible, discoverable, and secure while providing usage insights.


    总结

    API专为应用程序间通信而设计,已成为开发的重要组成部分。开发者能快速集成特定功能到应用或网站中

    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

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

    抵扣说明:

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

    余额充值