当营销行业首次从出站转移到入站营销时,许多营销人员将其作为内容创建者的新内容介绍了旧的内容关注者。

But that shift is still producing aftershocks, and to keep up with your competitors today, you need to understand what APIs are, how they integrate with yourcontent strategy, and the social insight they bring to your website.

不用担心 - API似乎似乎很复杂,但是到本文结尾,您将知道它们的工作方式以及使用它们的方式。 Unlock tips, systems & recommended resources to stay ahead of the tech curve. Here's a brief definition of an API, followed by some key information on how to make one work for your business.

什么是API?

An API, short forapplication programming interface,是一系列规则。更清楚,这是一个信息中间人。API允许应用程序从软件中提取信息,并在自己的应用程序中或有时用于数据分析中使用该信息。bob电竞官方下载

用最明确的话来说,API是一种蓝图,使您可以与“他们的东西”交谈并与“他们的东西”合作。在这种情况下,您的东西被称为API端点。

Sound confusing? Don’t worry — we’ll walk through an example below.

API端点示例

Let’s say you want to stream public tweets in real-time so that you can stay informed on a specific topic of interest or on current trends in the world. Then you could useTwitter’s filtered stream endpoint。它的URL是:https://api.twitter.com/2/tweets/search/stream

Technically, an API endpoint need only be referred to with the end path of the resource URL. The base path, which is common to all endpoints, is https://api.twitter.com. Because that stays the same, there’s no need to keep listing it. You can instead just list the endpoint: /2/tweets/search/stream.

如何测试API端点

There are several online tools available for testing an API endpoint. For the sake of this post, we’ll walk through how to set up a test using cURL.cURL是用于传输支持多个协议的数据的命令行工具,包括HTTP。它能够提出请求,获取数据并发送数据 - 使其成为请求API信息的理想工具。

Let’s use an example fromTwitter’s own documentation。Say, you want to stay informed on the Twitter API. Then you will want to get tweets from major accounts like @TwitterDev and @TwitterAPI as soon as they’re posted. And maybe you only want tweets that contain links to articles or documentation so you’re getting as much context as possible.

在这种情况下,使用过滤的流端点是理想的选择。但是,为了让端点知道要发送什么样的推文,您必须定义过滤条件。否则,您只是要求看到每个推文实时发布。

Filtering criteria will be applied to the endpoint in the form of rules. To build these rules, you’ll need a set of operators. For this example, you can use two operators —from:andhas:links— in order to only see tweets from certain accounts and that contain links. To instruct the filtered stream endpoint to only show tweets from the accounts @Twitterdev and @TwitterApi that contain links, you’d use the following rule:“来自:Twitterdev来自:Twitterapi具有:链接”

To request this information from the filtered stream endpoint, you need to include the correct HTTP request to tell the API what action to take. There are four main options. Take a look at a brief description of each below:

  • 获取:检索资源
  • 帖子:创建资源
  • fut:更新现有资源
  • DELETE: remove a resource

For this example, you’ll use the POST request. In addition to including the rule mentioned above in your request, you’ll include the content type and authorization. Below the content type is defined as “application/json” so the request is rendered in the lightweight data format JavaScript Object Notation (JSON). To authenticate your request, you’ll have to replace the placeholder text $BEARER_TOKEN with your app’s uniqueBearer Token, which can be generated in your developer portal.


curl -X POST 'https://api.twitter.com/2/tweets/search/stream/rules' \
-H "Content-type: application/json" \
-h“授权:持有人$ bearer_token” -d \
'{
“添加”: [
{"value": "from:twitterdev from:twitterapi has:links"}
]
}'

Why are APIs important?

许多营销人员问的第一个问题之一是:为什么所有这些业务都免费共享数据?

通常,答案是:比例。随着软bob电竞官方下载件公司的成长,这些公司中的员工很快意识到他们拥有的想法要比他们有时间和资源来开发更多的想法。bob体育苹果系统下载安装

By creating APIs, companies let third-party developers create applications that can improve usage and adoption of the main platform. In that way, a business can build an ecosystem that becomes dependent on the data from their API — a dynamic that often leads to additional revenue opportunities.

如何使用API

Understanding the value of a particular API is essentially about understanding what information is available through an API and how it can be accessed. To find out what a particular API can do for you, you can do one of two things.

  1. Ask a web developer to look at an API and discuss it with you.
  2. Do the research on your own. If you don't have access or budget to use a web developer, this is an appealing option. But don't panic — many online services have good API documentation.

API Documentation

让我们快速看一下Twitter的API参考索引as an example.

Twitter APIreference index

Twitter的大部分成长都是因为外部开发人员,第一个Twitter APIstarted as a basic wiki. Since then, it has evolved into a detailed指数of APIs that a savvy marketer can use to determine what information might be available to a developer in the form of an API以及如何在您的网站上包含此API。

Looking at the screenshot above, you can see there are multiple categories of information available to outside developers. Once you select an API you're interested in, you can click on it to see what information is available through this API. Check outTwitter's Tweet Timeline API endpointbelow.

Twitter的推文时间轴API端点文档

In the API documentation above, Twitter's Tweet Timeline API explains how you can take a brief collection of recent tweets from a specific user's timeline and display them, in clickable form, on your own website. The API documentation includes tweet volume limitations, the API's resource URL, as well as what you can and cannot choose to display through this API.

应用API来你的网站

If you add the API's resource URL to the backend of your website, it'll return the information you called for to the frontend of your website. Here's what this looks like on the纽约路跑者website, helping them promote the New York City Marathon (with a few custom design modifications):

纽约路跑者website embeds Tweets using Twitter API

You can also check out theHubSpot API documentionto see how you can build applications and integrations using data from HubSpot.

最后一个警告:为了正式使用开发人员的API,您可能还需要分配一个API键。

Think of your API key as your authentication token, declaring you a member of a developer's community. In effect, this token identifies what you're using the API for, and verifies that you've been given permission to carry out this project by the API's owner.

Rest assured, your API key doesnot让开发人员访问有关您的个人信息。

API作为营销平台

入站世界中的营销是关于公司开发有用的应用程序和服务以维持客户保留率的。品牌需要间歇性地放弃广告,成为消费者通信的渠道。

在此过程中,API促进了为客户问题提供解决方案所需的数据。

API Examples

了解通过API提供的信息将有助于您确定是否值得与开发人员合作进一步追求该项目。这是两个例子。

Twitter提到

If you wanted to show tweets on your website that included mentions on Twitter to articles from your blog, you'd need to understand if you could request tweets with only specific URLs from the Twitter API.

YouTube视频嵌入

当您在YouTube.com上右键单击YouTube视频,然后选择“复制嵌入代码”时,您本质上要求在网站上使用YouTube的API。YouTube使公众可以轻松地嵌入YouTube视频直接在其他网站上播放。

API服务条款

无论专业ject, it's critical that you actually read and understand the terms of service for an API you're considering for your website.

Most APIs have certain usage restrictions. If you don't take the time to understand the restrictions of an API you're interested in, you could invest more time and money in developing a marketing asset that's rendered useless once the API provider determines you've violated the API's terms of service (and revokes your access).

For this reason, most APIs have "call limits."

What is an API call?

An API call, also known as an API request, is an instance of a website owner "calling" for the use of a developer's API. Saving the API, logins to the developer's website, and queries about the application all count as API calls.

With this in mind, an API call limit is the number of times you can request information about an API from a web service within a given time period. Again, please read the terms of use for any APIs you are thinking about using. These documents should clearly detail any limitations as well as appropriate use of the program.

API在业务中的未来

Developing on the APIs of existing web services is only the beginning. We live in a world that now expects open and available content for allthe natural progression of this is for publishers themselves to release their own APIs, so thattheir客户可以开发应用程序。

API共享适用于所有业务 - 不仅是基于Web的业务,而且还适用于其组织中基于Web的工具或组件的任何业务。显然,这个概念可能会给某些组织,尤其是法律部门带来障碍。您要确定哪种API最有价值,以及如何合法和可持续地使用它们。

Editor's note: This post was originally published in March 2013 and has been updated for comprehensiveness.

保持新兴技术的最新

Guide Stay Current on Emerging Tech

最初发布于12月9日,2020年12月7:00 am,更新于2020年12月9日