Skip to content

A tool to scrape Google Lens visual search results with a simple API. Get visual matches, product information, exact matches, and AI-powered image analysis results.

Notifications You must be signed in to change notification settings

serpapi/google-lens-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Google Lens Scraper

Google Lens Scraper

Google Lens Scraper - A tool to scrape Google Lens visual search results with a simple API. Get visual matches, product information, exact matches, and AI-powered image analysis results.

We provide the results in a structured JSON format, eliminating the need for parsing, coding, proxies, or any other web scraping headaches for developers.

How to scrape Google Lens?

Using a simple GET request, you can retrieve Google Lens search results:

https://serpapi.com/search.json?engine=google_lens&url=https://example.com/image.jpg&api_key=YOUR_API_KEY
  • Register for free at SerpApi to get your API Key
  • url parameter: defines the URL of an image to perform the Google Lens search.
  • type parameter (optional): specifies search category (all, products, visual_matches, exact_matches).

Code examples

Here are some code examples based on your favorite programming languages.

cURL Integration

curl --get https://serpapi.com/search \
 -d engine="google_lens" \
 -d url="https://example.com/image.jpg" \
 -d api_key="secret_api_key"

Python Integration

Step 1: Create a new main.py file.

Step 2: Install requests package with:

pip install requests

Step 3: Add this code to your file:

import requests
SERPAPI_API_KEY = "YOUR_SERPAPI_API_KEY"

params = {
    "api_key": SERPAPI_API_KEY,
    "engine": "google_lens",
    "url": "https://example.com/image.jpg"
}

search = requests.get("https://serpapi.com/search", params=params)
response = search.json()
print(response)

If you're only interested in the visual_matches, you can print them from the response directly:

print(response["visual_matches"])

JavaScript Integration

Step 1: Install the SerpApi JavaScript package:

npm install serpapi

Step 2: Create a new index.js file.

Step 3: Add this to your file:

const { getJson } = require("serpapi");
getJson({
  api_key: API_KEY,
  engine: "google_lens",
  url: "https://example.com/image.jpg"
}, (json) => {
  console.log(json["visual_matches"]);
});

Other Programming Languages

While you can use our APIs using a simple GET request with any programming language, you can also see our ready-to-use libraries here: SerpApi Integrations.

Google Lens Scraper Parameters

Please find the parameters for the Google Lens API below:

Name Description Requirement
url Parameter defines the URL of an image to perform the Google Lens search Required
Search Type
type Parameter defines the search type: all (default), about_this_image, products, exact_matches, visual_matches Optional
Localization
hl Parameter defines the two-letter language code (e.g., en, es, fr) Optional
country Parameter defines the two-letter country code for localized results Optional
Filters
q Parameter defines a search query to refine results Optional
safe Parameter defines content filtering: active or off Optional
Advanced
no_cache Parameter to force fresh results Optional

Visit our documentation for more information on all available parameters.

Available data on Google Lens (JSON Response)

Google Lens can return different information from time to time. Here is what the visual_matches array may contain:

 "visual_matches": [
    {
      "position": "Integer - Position of the result",
      "title": "String - Title of the matching result",
      "link": "String - URL to the source page",
      "source": "String - Source website name",
      "thumbnail": "String - URL to the thumbnail image",
      "image": "String - URL to the full image",
      "rating": "Float - Product rating (if applicable)",
      "reviews": "Integer - Number of reviews (if applicable)",
      "price": {
        "value": "Float - Numeric price value",
        "currency": "String - Currency code",
        "extracted_value": "Float - Extracted numeric price"
      },
      "in_stock": "Boolean - Whether the product is in stock"
    }
  ],

The API response also includes:

  • related_content: Related search queries and suggestions
  • ai_overview: AI-generated summary (when available)

Use cases

Here are some use cases for the Google Lens API:

  • Build visual search applications to identify products from images.
  • Create price comparison tools by searching for products using images.
  • Build plant, animal, or object identification apps.
  • Create reverse image search tools for content verification.
  • Build shopping apps that let users search by taking photos.
  • Identify artwork, landmarks, or text from images.

Blog tutorial

Interesting use cases:

Video tutorial

Contacts

Feel free to reach out via contact@serpapi.com.

Check other Google Scrapers from SerpApi.

About

A tool to scrape Google Lens visual search results with a simple API. Get visual matches, product information, exact matches, and AI-powered image analysis results.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published