什么是api_什么是API

API,即应用程序接口,是软件系统之间交互的一种方式。它允许开发者通过调用接口来获取或传递数据,实现不同应用之间的功能整合。API在互联网服务、移动应用以及企业系统集成中扮演着关键角色。
摘要由CSDN通过智能技术生成

什么是api

Do you pull the same reports every week to send to your superiors?

您是否每周都会提取相同的报告以发送给您的上级?

Do you pay an intern to enter data from one AP to another every week?

您是否需要支付实习生才能每周从一个AP输入数据到另一个AP?

Does your organization have some custom process that you want to implement that your software doesn’t support by default?

您的组织是否有一些想要实施的自定义流程,而该流程默认情况下不支持您的软件?

If the answer to any of the above questions is yes, then you should care if the software your organization uses has an API.

如果以上任何一个问题的答案为是,那么您应该注意您的组织使用的软件是否具有API。

什么是API (What is an API)

API stands for Application Programming Interface. Just like:

API代表应用程序编程接口。 就像:

a GUI, Graphical User Interface, lets any interact with the software graphically,

一个GUI(图形用户界面) ,可让任何人以图形方式与该软件进行交互

an API lets any application (computer program) interact with the software programmatically.

API可让任何应用程序(计算机程序)以编程方式与软件进行交互。

(Example)

For example, to find the current weather from openweathermap.org using the human-friendly user interface (GUI), you would enter the location in the search bar like so.

例如,要使用人性化的用户界面(GUI)从openweathermap.org查找当前天气,您将像这样在搜索栏中输入位置。

Image for post

Now suppose you wanted to automatically pull the weather data for every day and store it in a Google Spreadsheet. To do so, you’d hit the openweathermap.org API endpoint(a URL for APIs) like so:

现在假设您要自动提取每天的天气数据并将其存储在Google Spreadsheet中。 为此,您可以按以下方式访问openweathermap.org API端点(API的URL):

http://api.openweathermap.org/data/2.5/weather?q=Austin&appid=439d4b804bc8187953eb36d2a8c26a02&units=imperial

And you’ll get the same weather data shown in the human-friendly GUI but in a computer-friendly format called JSON.

而且,您将获得与人类友好的GUI相同的天气数据,但采用的计算机友好格式为JSON

{
"coord": {
"lon": -97.74,
"lat": 30.27
},
"weather": [
{
"id": 802,
"main": "Clouds",
"description": "scattered clouds",
"icon": "03d"
}
],
"base": "stations",
"main": {
"temp": 83.34,
"feels_like": 86.83,
"temp_min": 81,
"temp_max": 86,
"pressure": 1020,
"humidity": 66
},
"visibility": 10000,
"wind": {
"speed": 8.05,
"deg": 360
},
"clouds": {
"all": 40
},
"dt": 1600101504,
"sys": {
"type": 1,
"id": 3344,
"country": "US",
"sunrise": 1600085716,
"sunset": 1600130257
},
"timezone": -18000,
"id": 4671654,
"name": "Austin",
"cod": 200
}

As you can imagine, it’s much easier to program a computer to simply hit the API endpoint than to train it to use the GUI. And while the JSON response is not designed to be easily read by humans, it is easy for computer programs to use.

可以想象,对计算机进行编程以使其简单地访问API端点要比训练计算机使用GUI容易得多。 而且,尽管JSON响应的设计目的不是让人们容易阅读,但计算机程序很容易使用。

为什么您应该关心自己是否不是程序员 (Why you should care if you’re not a programmer)

Okay, so APIs make it easier for computer programs to interact with software. But why should you care if you are not a computer programmer?

好的,因此API使计算机程序更易于与软件进行交互。 但是,为什么您不关心自己不是计算机程序员呢?

Well, if you want to automate routine tasks, integrate different software applications together, or customize a process that your software doesn’t allow by default, then it behooves you to select software that has a good API.

好吧,如果您要自动化日常任务,将不同的软件应用程序集成在一起或自定义默认情况下您的软件不允许的过程,那么您应该选择具有良好API的软件。

With a good API, you are much more likely to find off the shelf solutions to these problems or find consultants that can quickly and cheaply build them for you.

有了一个好的API,您就更有可能找到这些问题的现成解决方案,或者找到可以为您快速廉价地构建它们的顾问。

用途 (Uses)

自动化技术(Automations)

Google Analytics tracks how visitors interact with your website. With its GUI you can create a report of the top-visited pages of your website like so.

Google Analytics(分析)会跟踪访问者如何与您的网站进行互动。 借助其GUI,您可以像这样创建网站访问量最高页面的报告。

Image for post

You can even download it to a Google Sheet to share with your boss.

您甚至可以将其下载到Google表格中,以便与老板共享。

But what if you wanted to send this to your boss every week? This is one of those routine tasks that can get really annoying over time.

但是,如果您想每周将其发送给老板,该怎么办? 这是随着时间的流逝会变得很烦人的例行任务之一。

Because Google Analytics has a reporting API, a consultant, or even a tech-handy coworker could write a small program to automate this task.

由于Google Analytics(分析)具有报告API ,因此顾问或什至是技术熟练的同事都可以编写一个小型程序来自动执行此任务。

整合方式 (Integrations)

Now suppose you use Stripe to accept payments for your services online and you use Salesforce as your CRM.

现在,假设您使用Stripe在线接受服务付款,并且使用Salesforce作为CRM

By default, Salesforce doesn’t have a built-in Stripe integration. If neither had APIs, you might be stuck manually entering payments into your CRM (yuck).

默认情况下,Salesforce没有内置的Stripe集成。 如果两者都没有API,您可能会被迫手动将付款输入到CRM中(不幸)。

However, because both Stripe and Salesforce have open, well-documented APIs, you have options for integrating the two services.

但是,由于StripeSalesforce都具有开放的,有据可查的API,因此您可以选择集成这两个服务。

In fact, there are several off-the-shelf tools that do exactly this. No need to pay a developer to create it for you.

实际上,确实有几种现成的工具可以做到这一点。 无需支付开发人员为您创建的费用。

Of course, if those off-the-shelf solutions don’t work for you, you’ll still be able to pay a developer to program a custom solution for you.

当然,如果这些现成的解决方案对您不起作用,您仍然可以向开发人员付费以为您编写自定义解决方案。

客制化 (Customization)

Suppose however you wanted to implement some custom pricing that your payment provider doesn’t provide by default. For instance, say you charge clients for hours of consulting upfront but offer price breaks like so.

但是,假设您要实现一些付款提供商默认不提供的自定义定价。 例如,假设您向客户收取数小时的前期咨询费用,但会像这样提供价格优惠。

If you use a payment provider that doesn’t have an API, you may be stuck manually creating invoices and sending them to clients.

如果您使用没有API的付款服务提供商,则可能会被困在手动创建发票并将其发送给客户的过程中。

But if you’re using Stripe (which I recommend) you could pay any developer or Stripe consultant to create your custom pricing for you.

但是,如果您使用的是Stripe(建议使用),则可以向任何开发人员或Stripe顾问付费,以为您创建自定义价格。

Stripe’s API is so good, you could even integrate it with a form on your website and allow clients to buy more hours without having to talk to you at all.

Stripe的API非常好,您甚至可以将其与网站上的表单集成,并允许客户购买更多时间而无需与您交谈。

如何判断应用程序是否具有良好的API (How to tell if an app has a good API)

If your organization’s software has a good API, you can automate, integrate and customize much more cheaply and easily.

如果您的组织的软件具有良好的API,则可以更便宜,更轻松地实现自动化,集成和自定义。

But, when selecting software, how can you tell that it has a good API?

但是,在选择软件时,如何判断它具有良好的API?

Many software applications will claim to have an API, but, for a non-coder, it can be difficult to tell upfront if it’s a good API or not.

许多软件应用程序将声称具有API,但是对于非编码器,可能很难预先告知它是否是一个好的API。

Here are a couple of heuristics you can use.

您可以使用以下两种启发式方法。

文献资料 (Documentation)

First, look at the documentation for the application’s API. Even though you may not be able to interpret the documentation yourself, it’s usually pretty clear when an API is well documented.

首先,查看应用程序API的文档。 即使您可能无法自己解释文档,但通常可以很清楚地知道API的文档编制时间。

Good documentation will be clear, well organized, with both code-level examples and qualitative descriptions of those examples. Often, a well-maintained API will support multiple coding languages, which you can see in the documentation.

好的文档将清晰,组织良好,并带有代码级示例和这些示例的定性描述。 通常,维护良好的API将支持多种编码语言,您可以在文档中看到它们。

Finally, world-class API documentation is interactive — you can actually test the examples with your data, right from the documentation.

最后,世界一流的API文档是交互式的-您可以直接从文档中实际使用数据测试示例。

For instance, Stripe’s documentation is famously good.

例如, Stripe的文档非常有名。

Image for post

Conversely, Evernote’s is infamously bad.

相反,印象笔记的坏处在于。

Image for post

The Stripe documentation is interactive and loaded with code-level examples in different languages with clear descriptions of the examples on a split-screen. The Evernote documentation is just a wall of text with little or no code-level examples.

Stripe文档是交互式的,并以不同语言提供了代码级示例,并在分屏上清晰地描述了示例。 Evernote文档只是一堵文本墙,几乎没有代码级示例。

Good documentation saves a developer a ton of time, which saves you money.

好的文档可以为开发人员节省大量时间,为您节省金钱。

网络挂钩 (Webhooks)

Pro-tip: if you need to integrate with the app in real-time, you need to make sure the app’s API has a webhook. A webhook is a specific type of API that fires an event immediately when something happens.

专家提示:如果您需要与应用程序实时集成,则需要确保应用程序的API有一个Webhook。 Webhook是一种特定类型的API,可在发生某些情况时立即触发事件。

For instance, if you want to be emailed every time somebody makes a payment on your website, your payment provider needs to have a webhook that fires whenever a payment is made.

例如,如果您希望每次有人在您的网站上付款时都通过电子邮件发送电子邮件,则您的付款服务提供商需要有一个在每次付款时都会触发的网络挂钩。

REST API (REST APIs)

REST stands for REpresentational State Transfer. It’s a bit technical, but suffice it to say, most modern, well-maintained APIs are designed as REST API as opposed to Thrift or SOAP APIs.

REST代表代表性状态转移。 这有点技术性,但是可以说,大多数现代的,维护良好的API都设计为REST API,而不是ThriftSOAP API。

快速入门示例 (Quickstart examples)

Many well designed API’s have simple quick start examples that you can use without any programming experience yourself. Think about the openweathermap.org API example above.

许多设计良好的API都有简单的快速入门示例,您无需任何编程经验就可以使用它们。 考虑上面的openweathermap.org API示例。

Often times just getting up and running with the API is the hardest part of the whole project, so effective quickstart guides can save a lot of time.

通常,仅使用API​​进行启动和运行是整个项目中最难的部分,因此有效的快速入门指南可以节省大量时间

社区 (Communities)

The best APIs have large communities of developers that discuss issues and share projects on community forums.

最好的API拥有大量的开发人员社区,他们讨论问题并在社区论坛上共享项目。

A large community will help you or your developer find examples similar to your needs, saving you time and money.

一个大型社区将帮助您或您的开发人员找到与您的需求相似的示例,从而节省时间和金钱。

现成的第三方解决方案 (Off-the-shelf third-party solutions)

Finally, you should look for off-the-shelf solutions developed by third-party developers. For instance, Salesforce has an entire App store where developers share and sell add-ons built with its API.

最后,您应该寻找由第三方开发人员开发的现成解决方案。 例如,Salesforce拥有一个完整的App商店,开发人员可以在其中共享和销售使用其API构建的附加组件。

As such, you may be able to find an off-the-shelf solution to your problem.

这样,您也许可以找到解决问题的现成解决方案。

结论 (Conclusion)

When selecting software for your organization, you doubtlessly consider how intuitive and user-friendly the GUI is. For analogous reasons, you should consider how computer-friendly the API is.

在为您的组织选择软件时,您无疑会考虑GUI的直观性和用户友好性。 出于类似的原因,您应该考虑API对计算机的友好程度。

With a good API, you can replace repetitive user tasks with automated computer programs. Thus freeing the employees at your organization to do the creative things that only humans can do.

使用良好的API,您可以用自动计算机程序代替重复的用户任务。 从而使组织中的员工有更多的时间去做只有人类才能做的创造性工作。

Originally published at https://slideruletech.com on September 14, 2020.

最初于2020年9月14日https://slideruletech.com发布

翻译自: https://medium.com/@kvnmclaughlin/what-are-apis-657fdeb306cc

什么是api

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值