所有文章 > 学习各类API > 如何获取serper API 密钥(分步指南)

如何获取serper API 密钥(分步指南)

Serper提供的Google Search服务,是一个高性能的搜索引擎结果页面(SERP)API,它使开发者可以通过集成编程接口获取Google的搜索结果。这种API允许用户在应用程序中集成Google的搜索功能,从而无需手动访问搜索引擎界面即可获取和处理搜索数据。

本文旨在为你提供一份详尽的分步指南,教你如何轻松获取Serper API密钥。通过一系列清晰明确的步骤,你将能够顺利获得访问Serper服务的权限。一旦成功获取API密钥,你就可以开始在你的项目中集成Serper API,从而利用这些先进的工具和技术来优化你的应用,提升性能和功能。接下来,让我们一步步来探索如何获取Serper API密钥。

1. 登录注册 serper

2. 获取密钥

  1. 左侧菜单栏点击API KEY

2. 点击复制按钮复制API密钥

3. 请求示例

把headers里面的X-API-KEY替换成上面复制的api key

const axios = require('axios');
let data = JSON.stringify({
"q": "apple inc"
});

let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://google.serper.dev/search',
headers: {
'X-API-KEY': YOUR X-API-KEY,
'Content-Type': 'application/json'
},
data : data
};

async function makeRequest() {
try {
const response = await axios.request(config);
console.log(JSON.stringify(response.data));
}
catch (error) {
console.log(error);
}
}

makeRequest();

响应示例

{
"searchParameters": {
"q": "apple inc",
"gl": "us",
"hl": "en",
"autocorrect": true,
"page": 1,
"type": "search"
},
"knowledgeGraph": {
"title": "Apple",
"type": "Technology company",
"website": "http://www.apple.com/",
"imageUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0",
"description": "Apple Inc. is an American multinational technology company specializing in consumer electronics, software and online services headquartered in Cupertino, California, United States.",
"descriptionSource": "Wikipedia",
"descriptionLink": "https://en.wikipedia.org/wiki/Apple_Inc.",
"attributes": {
"Headquarters": "Cupertino, CA",
"CEO": "Tim Cook (Aug 24, 2011–)",
"Founded": "April 1, 1976, Los Altos, CA",
"Sales": "1 (800) 692-7753",
"Products": "iPhone, Apple Watch, iPad, and more",
"Founders": "Steve Jobs, Steve Wozniak, and Ronald Wayne",
"Subsidiaries": "Apple Store, Beats Electronics, Beddit, and more"
}
},
"organic": [
{
"title": "Apple",
"link": "https://www.apple.com/",
"snippet": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
"sitelinks": [
{
"title": "Support",
"link": "https://support.apple.com/"
},
{
"title": "iPhone",
"link": "https://www.apple.com/iphone/"
},
{
"title": "Apple makes business better.",
"link": "https://www.apple.com/business/"
},
{
"title": "Mac",
"link": "https://www.apple.com/mac/"
}
],
"position": 1
},
{
"title": "Apple Inc. - Wikipedia",
"link": "https://en.wikipedia.org/wiki/Apple_Inc.",
"snippet": "Apple Inc. is an American multinational technology company specializing in consumer electronics, software and online services headquartered in Cupertino, ...",
"attributes": {
"Products": "AirPods; Apple Watch; iPad; iPhone; Mac",
"Founders": "Steve Jobs; Steve Wozniak; Ronald Wayne",
"Founded": "April 1, 1976; 46 years ago in Los Altos, California, U.S",
"Industry": "Consumer electronics; Software services; Online services"
},
"sitelinks": [
{
"title": "History",
"link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
},
{
"title": "Timeline of Apple Inc. products",
"link": "https://en.wikipedia.org/wiki/Timeline_of_Apple_Inc._products"
},
{
"title": "List of software by Apple Inc.",
"link": "https://en.wikipedia.org/wiki/List_of_software_by_Apple_Inc."
},
{
"title": "Apple Store",
"link": "https://en.wikipedia.org/wiki/Apple_Store"
}
],
"position": 2
},
{
"title": "Apple Inc. | History, Products, Headquarters, & Facts | Britannica",
"link": "https://www.britannica.com/topic/Apple-Inc",
"snippet": "Apple Inc., formerly Apple Computer, Inc., American manufacturer of personal computers, smartphones, tablet computers, computer peripherals, ...",
"date": "Aug 31, 2022",
"attributes": {
"Related People": "Steve Jobs Steve Wozniak Jony Ive Tim Cook Angela Ahrendts",
"Date": "1976 - present",
"Areas Of Involvement": "peripheral device"
},
"position": 3
},
{
"title": "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg.com",
"link": "https://www.bloomberg.com/quote/AAPL:US",
"snippet": "Stock analysis for Apple Inc (AAPL:NASDAQ GS) including stock price, stock chart, company news, key statistics, fundamentals and company profile.",
"position": 4
},
{
"title": "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
"link": "https://finance.yahoo.com/quote/AAPL/profile/",
"snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. It also sells various related ...",
"position": 5
},
{
"title": "AAPL | Apple Inc. Stock Price & News - WSJ",
"link": "https://www.wsj.com/market-data/quotes/AAPL",
"snippet": "Apple, Inc. engages in the design, manufacture, and sale of smartphones, personal computers, tablets, wearables and accessories, and other varieties of ...",
"position": 6
},
{
"title": "Apple Inc Company Profile - Apple Inc Overview - GlobalData",
"link": "https://www.globaldata.com/company-profile/apple-inc/",
"snippet": "Apple Inc (Apple) designs, manufactures, and markets smartphones, tablets, personal computers (PCs), portable and wearable devices. The company also offers ...",
"position": 7
},
{
"title": "Apple Inc (AAPL) Stock Price & News - Google Finance",
"link": "https://www.google.com/finance/quote/AAPL:NASDAQ?hl=en",
"snippet": "Get the latest Apple Inc (AAPL) real-time quote, historical performance, charts, and other financial information to help you make more informed trading and ...",
"position": 8
}
],
"peopleAlsoAsk": [
{
"question": "What does Apple Inc mean?",
"snippet": "Apple Inc., formerly Apple Computer, Inc., American manufacturer of personal\ncomputers, smartphones, tablet computers, computer peripherals, and computer\nsoftware. It was the first successful personal computer company and the\npopularizer of the graphical user interface.\nAug 31, 2022",
"title": "Apple Inc. | History, Products, Headquarters, & Facts | Britannica",
"link": "https://www.britannica.com/topic/Apple-Inc"
},
{
"question": "Is Apple and Apple Inc same?",
"snippet": "Apple was founded as Apple Computer Company on April 1, 1976, by Steve Jobs,\nSteve Wozniak and Ronald Wayne to develop and sell Wozniak's Apple I personal\ncomputer. It was incorporated by Jobs and Wozniak as Apple Computer, Inc.",
"title": "Apple Inc. - Wikipedia",
"link": "https://en.wikipedia.org/wiki/Apple_Inc."
},
{
"question": "Who owns Apple Inc?",
"snippet": "Apple Inc. is owned by two main institutional investors (Vanguard Group and\nBlackRock, Inc). While its major individual shareholders comprise people like\nArt Levinson, Tim Cook, Bruce Sewell, Al Gore, Johny Sroujli, and others.",
"title": "Who Owns Apple In 2022? - FourWeekMBA",
"link": "https://fourweekmba.com/who-owns-apple/"
},
{
"question": "What products does Apple Inc offer?",
"snippet": "APPLE FOOTER\nStore.\nMac.\niPad.\niPhone.\nWatch.\nAirPods.\nTV & Home.\nAirTag.",
"title": "More items...",
"link": "https://www.apple.com/business/"
}
],
"relatedSearches": [
{
"query": "Who invented the iPhone"
},
{
"query": "Apple Inc competitors"
},
{
"query": "Apple iPad"
},
{
"query": "iPhones"
},
{
"query": "Apple Inc us"
},
{
"query": "Apple company history"
},
{
"query": "Apple Store"
},
{
"query": "Apple customer service"
},
{
"query": "Apple Watch"
},
{
"query": "Apple Inc Industry"
},
{
"query": "Apple Inc registered address"
},
{
"query": "Apple Inc Bloomberg"
}
]
}

4. 常见问题

Q:如何找到Serper API

A:幂简集成是国内领先的API集成管理平台,专注于为开发者提供全面、高效、易用的API集成解决方案。幂简API平台可以通过以下两种方式找到所需API:通过关键词搜索API(例如,输入’Serper API‘这类品类词,更容易找到结果)、或者从API hub分类页进入寻找。

Q:多快能收到查询结果?
A:一般来说,所有查询都会在 1 到 2 秒内返回。 有时,当我们需要重新向谷歌提交请求时,单个请求可能需要更长的时间(2-4 秒)。 我们正在密切监控响应时间。

Q:每秒可以提交多少次查询?
A:我们对终极信用额度的默认速率限制为每秒 300 次查询。 这允许您在 1 分钟内执行约 15,000 至 18,000 次搜索。 如果您的具体使用情况需要更高的并发量,我们可以更改这一限制。我们对终极信用额度的默认速率限制为每秒 300 次查询。 这允许您在 1 分钟内执行约 15,000 至 18,000 次搜索。 如果您的具体使用情况需要更高的并发量,我们可以更改这一限制。

Q:查询是实时进行的吗?
A:是的,每当您调用我们的 API 时,我们都会直接查询 Google 的最新结果。 我们不会缓存任何内容,因此返回的响应将反映 Google 的最新 SERP 结果。

Q:能否自定义搜索查询位置?
A:是的,您可以通过指定国家、语言以及城市或社区等更精确的区域来设置搜索位置。是的,您可以通过指定国家、语言以及城市或社区等更精确的区域来设置搜索位置。

Q:何时扣除积分?

A:每次您成功收到查询回复,我们都会从您的账户余额中扣除点数。 当您的积分余额为零时,我们将停止接受新的查询。

Q:serperAPI的替代品有哪些?

除了serperAPI,还有其他替代服务商也提供类似api服务,例如:

TLDWai.comFast Query Recognizer全球新闻搜索服务-Rapidapi

更多竞品可以在幂简集成开放平台中找到。

Q:serperAPI这个密钥还适用于哪些api?

图片地点评论专利

5.  总结

本文旨在为开发者提供一个详尽而实用的指南,帮助他们顺利获取Serper API密钥,并将其有效集成到应用中。通过一系列清晰明确的步骤,从注册Serper API账号、完成开发者认证,到最终获取API服务密钥,我们详细阐述了整个获取过程。此外,本文还强调了获取密钥后进行可用性测试的重要性,以确保开发者能够充分利用Serper API的功能,并避免在集成过程中出现不必要的错误。这一环节对于提升应用的交互性和功能性至关重要。本文为开发者提供了一个全面、系统的指南,旨在帮助他们轻松获取Serper API密钥,并将其转化为推动应用发展的强大动力。通过遵循本文提供的步骤和建议,开发者将能够更高效地利用Serper API,为他们的应用注入更多创新和活力。

#你可能也喜欢这些API文章!