Skip to main content
Integrating real-time, external information into your AI applications can dramatically improve their accuracy, relevance, and overall usefulness. YouRouter provides a simple interface to Google’s search APIs, allowing you to seamlessly pull in web pages and articles. All search requests are covered by our Zero Completion Insurance policy, meaning you won’t be charged for failed or empty search results. Leverage Google’s search power. Provide a cx ID to search the sites you specify; otherwise the request uses YouRouter’s default search engine. Create your own Custom Search Engine at programmablesearchengine.google.com to obtain a cx ID. Endpoint: GET /customsearch/v1
import requests
import json

response = requests.get(
    "https://api.yourouter.ai/customsearch/v1",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    params={
        "q": "how to set up billing",
        "cx": "YOUR_CUSTOM_SEARCH_ENGINE_ID",
        "num": 3
    }
)
results = response.json()
print(json.dumps(results, indent=2))

Parameters

ParameterTypeDescriptionRequired
qstringThe search query.Yes
cxstringCustom Search Engine ID. Uses YouRouter’s default if omitted.No
numintegerNumber of search results to return (1-10).No
startintegerThe index of the first result to return.No
siteSearchstringSpecifies a given site to search.No

Response Format

A successful response contains an items array of search result objects.
{
  "kind": "customsearch#search",
  "searchInformation": {
    "totalResults": "123000",
    "formattedTotalResults": "123,000"
  },
  "items": [
    {
      "kind": "customsearch#result",
      "title": "Billing Information - Your Product Docs",
      "htmlTitle": "<b>Billing</b> Information - Your Product Docs",
      "link": "https://docs.yourproduct.com/billing",
      "displayLink": "docs.yourproduct.com",
      "snippet": "This page contains all the information you need about billing, invoices, and payment methods.",
      "htmlSnippet": "This page contains all the information you need about <b>billing</b>, invoices, and payment methods."
    }
  ]
}

Use Cases & Best Practices

Use Case: Create a chatbot that can answer user questions about your products by searching your own documentation websites. Best Practice: Create a Google Custom Search Engine configured to index only your documentation sites (e.g., docs.yourproduct.com, help.yourproduct.com). When a user asks a question, use their query to search your docs via the API. Pass the top search results to a language model to generate a specific, helpful answer. This is a core component of Retrieval-Augmented Generation (RAG).
I