Local Google Search API Documentation

This API allows you to perform Google searches targeting specific geographic locations. By sending a postal code or location name along with your search query, you can obtain location-based Google search results.

Overview

This API lets you customize Google search results based on a specific geographic location. This is particularly useful when you want to view Google search results from different locations, perform local SEO work, or test results across different regions.

Basic Usage

To use the API, send a request to the following endpoint:

GET https://www.malatyauyducum.com/search/search_api.php?location=POSTAL_CODE&query=SEARCH_QUERY&country=COUNTRY_CODE

Parameters

Parameter Required Default Description
location Yes - Postal code or place name. Specifies the location for the search.
query Yes - The search query to look up on Google.
country No TR Two-letter ISO country code (e.g., TR, US, DE, UK).
format No json Response format. Can be json or redirect. If redirect is selected, you will be directly forwarded to the search results.

Example Requests

1. Simple Query (JSON response)

GET https://www.malatyauyducum.com/search/search_api.php?location=44080&query=pizza&country=TR

2. Query with Place Name

GET https://www.malatyauyducum.com/search/search_api.php?location=istanbul&query=weather+forecast&country=TR

3. Direct Redirect

GET https://www.malatyauyducum.com/search/search_api.php?location=90210&query=best+restaurants&country=US&format=redirect

Response Format

By default, the API returns data in JSON format. Example response:

{
  "success": true,
  "search_url": "https://google.com.tr/search?q=pizza&gl=TR&hl=tr&uule=a+CMKC...",
  "location": {
    "input": "34200",
    "resolved": "Istanbul",
    "country": "TR",
    "latitude": 41.0138,
    "longitude": 28.9496
  },
  "query": "pizza",
  "uule": "a+CMKC..."
}

Failed Request Response

{
  "success": false,
  "error": "Location not found: 12345 in country: TR"
}

Test Tool

Code Examples

JavaScript (Fetch API)

// Sending a request to the API
async function searchWithLocation(location, query, country = 'TR') {
  try {
    const url = `https://www.malatyauyducum.com/search/search_api.php?location=${encodeURIComponent(location)}&query=${encodeURIComponent(query)}&country=${country}`;
    const response = await fetch(url);
    
    if (!response.ok) {
      throw new Error(`API request failed: ${response.status}`);
    }
    
    const data = await response.json();
    
    if (data.success) {
      // Use the search URL
      window.open(data.search_url, '_blank');
    } else {
      // Show error message
      console.error(data.error);
    }
  } catch (error) {
    console.error('Request error:', error);
  }
}

PHP (cURL)

// Sending a request to the API
function searchWithLocation($location, $query, $country = 'TR') {
  $url = "https://www.malatyauyducum.com/search/search_api.php?location=" . urlencode($location) . 
         "&query=" . urlencode($query) . 
         "&country=" . $country;
         
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch);
  
  if (curl_errno($ch)) {
    echo 'Request error: ' . curl_error($ch);
    return false;
  }
  
  curl_close($ch);
  $data = json_decode($response, true);
  
  if ($data['success']) {
    // Use the search URL
    header("Location: " . $data['search_url']);
    exit;
  } else {
    // Show error message
    echo 'API error: ' . $data['error'];
  }
}

Limits and Restrictions