WebSearchAPI.ai Quickstart Guide
Learn how to quickly get started with WebSearchAPI.ai and make your first API call.
WebSearchAPI.ai provides powerful, Google-backed search capabilities designed specifically for AI applications. This guide will walk you through the process of setting up and making your first API call.
Creating an API Key
Before you can use WebSearchAPI.ai, you'll need to create an API key:
- Sign up for a WebSearchAPI.ai account
- Navigate to the Developer section in your dashboard
- Click on "Create New API Key"
- Give your key a descriptive name (e.g., "Development Key")
- Set appropriate permissions and expiration if needed
- Copy your new API key for use in your applications
Remember: Your API key grants access to your account and quotas. Keep it secure and never share it publicly.
Making Your First API Call
Once you have your API key, you can start making requests to the WebSearchAPI.ai endpoint. Below are examples using different methods:
Using cURL
# Direct API call to WebSearchAPI.ai
curl -X POST https://api.websearchapi.ai/ai-search \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APIKEY" \
-d '{
"query": "Why the market crashed?",
"maxResults": 5,
"includeContent": false,
"country": "us",
"language": "en"
}'
Using Python
import requests
API_KEY = "your_api_key_here"
url = "https://api.websearchapi.ai/ai-search"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {API_KEY}"
}
data = {
"query": "Why the market crashed?",
"maxResults": 5,
"includeContent": False,
"country": "us",
"language": "en"
}
response = requests.post(url, headers=headers, json=data)
results = response.json()
print(results)
Using JavaScript
async function searchWithWebSearchAPI() {
const API_KEY = 'your_api_key_here';
const url = 'https://api.websearchapi.ai/ai-search';
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${API_KEY}`
},
body: JSON.stringify({
query: 'Why the market crashed?',
maxResults: 5,
includeContent: false,
country: 'us',
language: 'en'
})
});
const data = await response.json();
console.log(data);
}
searchWithWebSearchAPI();
Understanding the Response
The API will return a JSON response with the following structure:
{
"searchParameters": {
"query": "Why the market crashed?",
"maxResults": 5,
"includeContent": false,
"country": "us",
"language": "en"
},
"organic": [
{
"title": "U.S. stocks plunge after Trump's tariff shock to global trade",
"url": "https://www.nbcnews.com/business/markets/us-stocks-dow-nasdaq-sp-plummet-trump-tariffs-rcna199476",
"description": "U.S. stocks take a historic plunge after Trump's tariffs shock global trade. Wall Street notched its worst day since the depths of the pandemic ...",
"position": 1
},
{
"title": "Markets Crash, Economists Warn of Recession as Trump ...",
"url": "https://www.usnews.com/news/economy/articles/2025-04-03/markets-crash-economists-warn-of-recession-as-trump-announces-sweeping-import-tariffs-on-many-countries",
"description": "The announcement of sweeping tariffs of at least 10% on U.S. imports rocked markets Thursday and had economists warning of dire times for ...",
"position": 2
},
{
"title": "Markets Shudder At Trump's Tariffs: S&P 500 Has Worst Day In 5 ...",
"url": "https://www.forbes.com/sites/dereksaul/2025/04/03/markets-shudder-heres-what-stocks-are-losing-the-most-in-tariff-selloff/",
"description": "Stocks nosedived across the board Thursday as Wall Street largely panned the highly aggressive tariffs announced by President Donald Trump, ...",
"position": 3
},
{
"title": "Stock market plunges after Trump tariff announcement - NBC News",
"url": "https://www.nbcnews.com/video/stock-market-plunges-after-trump-tariff-announcement-236427845598",
"description": "The markets closed down around 4% after President Donald Trump's announcement to slap reciprocal tariffs on global trading partners.",
"position": 4
}
]
}
When you set includeContent: true
, the API will automatically crawl each
page and return the full content in structured markdown format, ready for AI
consumption.
API Parameters
Code Examples
# With full content crawling enabled
curl -X POST https://api.websearchapi.ai/ai-search \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APIKEY" \
-d '{
"query": "Latest AI advancements",
"maxResults": 3,
"includeContent": true,
"country": "us",
"language": "en"
}'
For any questions or issues, please reach out to our support team or visit our community forum.