Developer Dashboard

Serper Search

AvalAI provides access to Serper's fast Google-powered search API, offering the most cost-effective direct web search option for high-volume applications.

Search Tool

Serper specializes in affordable Google search results with practical controls for localization, language, autocorrection, time filtering, and pagination.

Serper Search

Low-cost Google-powered search with geo-targeting and time-based filters.

FeatureDetails
Tool IDserper-search
Endpointv1/search/serper-search or v1/search
Max results1-20 results per query
Pricing$0.001 per query
CapabilitiesGoogle-powered web search, geo-targeting, language control, time filters, pagination
StrengthsLowest search cost, practical localization, fast results
Best forHigh-volume search, price monitoring, local search, news tracking

Usage Example:

bash
curl https://api.avalai.ir/v1/search/serper-search \
  -H "Authorization: Bearer $AVALAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "latest AI news",
    "max_results": 10,
    "gl": "uk",
    "hl": "en",
    "autocorrect": false,
    "tbs": "qdr:d",
    "page": 1
  }'
python
import requests

response = requests.post(
    "https://api.avalai.ir/v1/search/serper-search",
    headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"},
    json={
        "query": "latest AI news",
        "max_results": 10,
        # Serper-specific parameters
        "gl": "uk",  # Country/geolocation code
        "hl": "en",  # Language code
        "autocorrect": False,  # Disable autocorrect
        "tbs": "qdr:d",  # Time filter: past day
        "page": 1,  # Page number
    },
)

results = response.json()
for result in results["results"]:
    print(f"{result['title']}: {result['url']}")
javascript
const response = await fetch("https://api.avalai.ir/v1/search/serper-search", {
    method: "POST",
    headers: {
        "Authorization": `Bearer ${process.env.AVALAI_API_KEY}`,
        "Content-Type": "application/json"
    },
    body: JSON.stringify({
        query: "latest AI news",
        max_results: 10,
        // Serper-specific parameters
        gl: "uk",              // Country/geolocation code
        hl: "en",              // Language code
        autocorrect: false,     // Disable autocorrect
        tbs: "qdr:d",          // Time filter: past day
        page: 1                 // Page number
    })
});

const data = await response.json();
data.results.forEach(result => {
    console.log(`${result.title}: ${result.url}`);
});

Request Parameters

Serper Search supports the following parameters:

Standard Parameters

ParameterTypeRequiredDescription
querystringYesSearch query string
max_resultsintegerNoMaximum number of results (1-20). Default: 10
search_domain_filterarrayNoList of domains to filter results (max 20 domains)
max_tokens_per_pageintegerNoMaximum tokens per page to process. Default: 1024
countrystringNoCountry code filter (for example US, GB, DE)
locationstringNoGeographic location for local results (for example Berlin,Germany)

Serper-Specific Parameters

ParameterTypeRequiredDescription
glstringNoCountry/geolocation code for localized results (for example uk, us, de)
hlstringNoLanguage code for result language (for example en, de, fa)
autocorrectbooleanNoEnable or disable search query autocorrection. Set to false to disable autocorrect
tbsstringNoTime-based search filter such as qdr:h, qdr:d, qdr:w, qdr:m, or qdr:y
pageintegerNoPage number for paginated result sets

Use the tbs parameter to filter results by time period:

ValueMeaning
qdr:hPast hour
qdr:dPast day
qdr:wPast week
qdr:mPast month
qdr:yPast year
python
import requests

response = requests.post(
    "https://api.avalai.ir/v1/search/serper-search",
    headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"},
    json={
        "query": "AI product launches",
        "tbs": "qdr:d",  # Past day
        "max_results": 10,
    },
)

Geo-Targeting

Combine country, location, gl, and hl parameters for geo-targeted results:

python
import requests

response = requests.post(
    "https://api.avalai.ir/v1/search/serper-search",
    headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"},
    json={
        "query": "restaurants",
        "country": "DE",
        "location": "Berlin,Germany",
        "gl": "de",
        "hl": "de",
        "max_results": 10,
    },
)

Response Format

Serper searches return results in the standard search response format:

json
{
  "object": "search",
  "results": [
    {
      "title": "Result Title",
      "url": "https://example.com/page",

      "snippet": "Brief excerpt from the page content...",
      "date": "2024-01-15"
    }
  ]
}

Use Serper Search when:

  • You need the lowest-cost direct web search option at $0.001 per query
  • You want Google-powered results through the unified AvalAI Search API
  • You need time filters for recent content, news tracking, or monitoring
  • You need localized search using country, language, and location parameters
  • You are building high-volume systems such as price monitoring, market tracking, or search aggregation