
如何快速實(shí)現(xiàn)REST API集成以優(yōu)化業(yè)務(wù)流程
2. 點(diǎn)擊復(fù)制按鈕復(fù)制API密鑰
把headers里面的X-API-KEY替換成上面復(fù)制的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();
響應(yīng)示例
{
"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"
}
]
}
Q:如何找到Serper API
A:冪簡集成是國內(nèi)領(lǐng)先的API集成管理平臺,專注于為開發(fā)者提供全面、高效、易用的API集成解決方案。冪簡API平臺可以通過以下兩種方式找到所需API:通過關(guān)鍵詞搜索API(例如,輸入’Serper API‘這類品類詞,更容易找到結(jié)果)、或者從API hub分類頁進(jìn)入尋找。
Q:多快能收到查詢結(jié)果?
A:一般來說,所有查詢都會在 1 到 2 秒內(nèi)返回。 有時,當(dāng)我們需要重新向谷歌提交請求時,單個請求可能需要更長的時間(2-4 秒)。 我們正在密切監(jiān)控響應(yīng)時間。
Q:每秒可以提交多少次查詢?
A:我們對終極信用額度的默認(rèn)速率限制為每秒 300 次查詢。 這允許您在 1 分鐘內(nèi)執(zhí)行約 15,000 至 18,000 次搜索。 如果您的具體使用情況需要更高的并發(fā)量,我們可以更改這一限制。我們對終極信用額度的默認(rèn)速率限制為每秒 300 次查詢。 這允許您在 1 分鐘內(nèi)執(zhí)行約 15,000 至 18,000 次搜索。 如果您的具體使用情況需要更高的并發(fā)量,我們可以更改這一限制。
Q:查詢是實(shí)時進(jìn)行的嗎?
A:是的,每當(dāng)您調(diào)用我們的 API 時,我們都會直接查詢 Google 的最新結(jié)果。 我們不會緩存任何內(nèi)容,因此返回的響應(yīng)將反映 Google 的最新 SERP 結(jié)果。
Q:能否自定義搜索查詢位置?
A:是的,您可以通過指定國家、語言以及城市或社區(qū)等更精確的區(qū)域來設(shè)置搜索位置。是的,您可以通過指定國家、語言以及城市或社區(qū)等更精確的區(qū)域來設(shè)置搜索位置。
Q:何時扣除積分?
A:每次您成功收到查詢回復(fù),我們都會從您的賬戶余額中扣除點(diǎn)數(shù)。 當(dāng)您的積分余額為零時,我們將停止接受新的查詢。
Q:serperAPI的替代品有哪些?
除了serperAPI,還有其他替代服務(wù)商也提供類似api服務(wù),例如:
TLDWai.com、Fast Query Recognizer、全球新聞搜索服務(wù)-Rapidapi
更多競品可以在冪簡集成開放平臺中找到。
Q:serperAPI這個密鑰還適用于哪些api?
本文旨在為開發(fā)者提供一個詳盡而實(shí)用的指南,幫助他們順利獲取Serper API密鑰,并將其有效集成到應(yīng)用中。通過一系列清晰明確的步驟,從注冊Serper API賬號、完成開發(fā)者認(rèn)證,到最終獲取API服務(wù)密鑰,我們詳細(xì)闡述了整個獲取過程。此外,本文還強(qiáng)調(diào)了獲取密鑰后進(jìn)行可用性測試的重要性,以確保開發(fā)者能夠充分利用Serper API的功能,并避免在集成過程中出現(xiàn)不必要的錯誤。這一環(huán)節(jié)對于提升應(yīng)用的交互性和功能性至關(guān)重要。本文為開發(fā)者提供了一個全面、系統(tǒng)的指南,旨在幫助他們輕松獲取Serper API密鑰,并將其轉(zhuǎn)化為推動應(yīng)用發(fā)展的強(qiáng)大動力。通過遵循本文提供的步驟和建議,開發(fā)者將能夠更高效地利用Serper API,為他們的應(yīng)用注入更多創(chuàng)新和活力。