1. Defining a LangChain / Tool-Calling Web Search Function
Wrap GET /v1/search as a deterministic tool so your LLM agent can cite verifiable URLs and up-to-the-minute facts.
LangChain `@tool` Grounding with SearchData API
Compact context formatting for GPT-5, Claude Sonnet/Opus, and Gemini tool calling.
curl -s "https://api.searchdataapi.com/v1/search?q=best+vector+database+for+rag+2026&country=us&lang=en&limit=5" \
-H "Authorization: Bearer sr_live_your_api_key"import os, requests
from langchain_core.tools import tool
@tool
def google_web_search(query: str, country: str = "us") -> str:
"""Search real-time Google SERP + People Also Ask for fresh factual grounding."""
r = requests.get(
"https://api.searchdataapi.com/v1/search",
params={"q": query, "country": country, "lang": "en", "limit": 5},
headers={"Authorization": f"Bearer {os.environ['SEARCHDATA_API_KEY']}"},
timeout=15,
).json()["data"]
lines = [f"[{i['rank']}] {i['title']} ({i['url']}): {i['snippet']}" for i in r["organic_results"]]
return "\n".join(lines)import { tool } from "ai";
import { z } from "zod";
export const webSearchTool = tool({
description: "Query live Google SERP + PAA results",
parameters: z.object({ query: z.string(), country: z.string().default("us") }),
execute: async ({ query, country }) => {
const res = await fetch(
`https://api.searchdataapi.com/v1/search?q=${encodeURIComponent(query)}&country=${country}&limit=5`,
{ headers: { Authorization: `Bearer ${process.env.SEARCHDATA_API_KEY}` } }
);
const { data } = await res.json();
return data.organic_results;
},
});{
"code": 0,
"message": "success",
"data": {
"query": "best vector database for rag 2026",
"country": "us",
"lang": "en",
"total_results": 10,
"organic_results": [
{
"rank": 1,
"title": "Best Vector Databases for Production RAG in 2026 — Benchmark",
"url": "https://supabase.com/blog/vector-database-rag-benchmark",
"domain": "supabase.com",
"snippet": "Compare pgvector, Qdrant, Pinecone, and Weaviate across recall@10, p95 query latency, and hybrid BM25 + dense vector indexing."
},
{
"rank": 2,
"title": "Qdrant vs Pinecone vs pgvector: Choosing a RAG Vector Store",
"url": "https://qdrant.tech/benchmarks/",
"domain": "qdrant.tech",
"snippet": "Filtered HNSW vector search benchmarks at 10M and 100M embeddings with quantization memory footprints."
}
],
"people_also_ask": [
{
"question": "Which vector database is fastest for RAG?",
"answer": "In-memory Rust engines like Qdrant and Milvus achieve sub-10ms p95 latency at 10M+ vectors, while PostgreSQL pgvector (HNSW) simplifies transactional hybrid search."
}
],
"related_searches": [
"pgvector vs qdrant",
"hybrid search rag pipeline",
"langchain vector store"
]
},
"meta": {
"credits_charged": 2,
"credits_remaining": 11998
}
}Interactive Telemetry Workbench · GET /v1/search
Verify real-time latency, credit math & JSON schema
Frequently Asked Questions
- How do I connect SearchData API to Claude Desktop or Cursor via MCP?
- Point your MCP client to https://mcp.searchdataapi.com/mcp with header x-api-key: sr_live_... or use OAuth 2.1 PKCE on https://mcp.searchdataapi.com/v1/mcp. See /mcp for 1-click configs.
- Does SearchData API publish /llms.txt and /openapi.json?
- Yes. Coding agents can read https://searchdataapi.com/llms.txt, /llms-full.txt, /SKILL.md, and /openapi.json directly.
Zero 429 Rate Limits · Instant Production Key
Test live in the Playground or mint your sr_live_ key with 1-Click Google OAuth
Every new account receives 12,000 free Credits ($1.20) at 0ms plus up to +20,000 Sandbox Streak Credits — no credit card required, 0 Credits charged on empty or failed requests.