Google Lens API

Our Google Lens API allows you to scrape results from the Google Lens page when performing an image search. The results related to the image could contain a knowledge graph, visual matches, text, and other data. The API is accessed through the following endpoint: /search?engine=google_lens. A user may query the following: https://serpapi.com/search?engine=google_lens utilizing a GET request. Head to the playground for a live and interactive demo.

API Parameters

Search Query

url

Required

Parameter defines the URL of an image to perform the Google Lens search.

Localization

hl

Optional

Parameter defines the language to use for the Google Lens search. It's a two-letter language code. (e.g., en for English, es for Spanish, or fr for French). Head to the Google languages page for a full list of supported Google languages.

Serpapi Parameters

engine

Required

Set parameter to google_lens to use the Google Lens API engine.

no_cache

Optional

Parameter will force SerpApi to fetch the Google Lens results even if a cached version is already present. A cache is served only if the query and all parameters are exactly the same. Cache expires after 1h. Cached searches are free, and are not counted towards your searches per month. It can be set to false (default) to allow results from the cache, or true to disallow results from the cache. no_cache and async parameters should not be used together.

async

Optional

Parameter defines the way you want to submit your search to SerpApi. It can be set to false (default) to open an HTTP connection and keep it open until you got your search results, or true to just submit your search to SerpApi and retrieve them later. In this case, you'll need to use our Searches Archive API to retrieve your results. async and no_cache parameters should not be used together. async should not be used on accounts with Ludicrous Speed enabled.

api_key

Required

Parameter defines the SerpApi private key to use.

output

Optional

Parameter defines the final output you want. It can be set to json (default) to get a structured JSON of the results, or html to get the raw html retrieved.

API Results

JSON Results

JSON output includes structured data for "Visual matches", "Knowledge graph", "Text results", "Related content" and "Reverse image search".

A search status is accessible through search_metadata.status. It flows this way: Processing -> Success || Error. If a search has failed, error will contain an error message. search_metadata.id is the search ID inside SerpApi.

HTML Results

This API does not have the full html response. search_metadata.prettify_html_file contains prettified version of result. It is displayed in playground.
HTML output is useful to debug JSON results or support features not supported yet by SerpApi. HTML output gives you the raw HTML results from Google.

API Examples

JSON structure overview

{
  ...
  "knowledge_graph": [
    {
      "title": "String - Title of the image",
      "subtitle": "String - Subtitle of the image",
      "rating": "Float - Rating of the item in the image",
      "reviews": "Integer - Number of reviews of the item in the image",
      "link": "String - URL to the Google knowledge graph search",
      "more_images": {
        "link": "URL to the Google images search",
        "serpapi_link": "String - URL to the SerpApi images search"
      },
      "thumbnail": "String - URL to the image thumbnail",
      "images": [
        {
          "title": "String - Title of the image",
          "source": "String - Source URL of the website containing the image",
          "link": "String - URL to the image",
          "size": {
            "width": "Integer - Width of the image",
            "height": "Integer - Height of the image"
          }
        },
        ...
      ]
    },
    ...
  ],
  "visual_matches": [
    {
      "position": "Integer - Position of the image",
      "title": "String - Title of the image",
      "link": "String - Source URL of the website containing the image",
      "source": "String - Displayed URL of the website containing the image",
      "source_icon": "String - Icon URL of the source website containing the image",
      "rating": "Float - Rating of the item in the image",
      "reviews": "Integer - Number of reviews of the item in the image",
      "price": {
        "value": "String - Price of the item in the image",
        "extracted_value": "Float - Extracted price of the item in the image",
        "currency": "String - Price currency of the item in the image"
      },
      "thumbnail": "String - URL to the image thumbnail"
    },
    ...
  ],
  "text_results": [
    {
      "text": "String - Text extracted from the image",
      "link": "String - URL to the Google search",
      "serpapi_link": "String - URL to the SerpApi search"
    },
    ...
  ],
  "related_content": [
    {
      "query": "String - Related image query",
      "link": "String - URL to the Google search",
      "serpapi_link": "String - URL to the SerpApi search"
    },
    ...
  ],
  "reverse_image_search": {
    "link": "String - URL to the Google Reverse Image search"
  }
}

Example with url: https://i.imgur.com/HBrB8p0.png

Example with url: https://i.imgur.com/HBrB8p0.png

JSON Example

{
  "search_metadata": {
    "id": "6380ad5dde983400b1fa6938",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/f6000d11bb444c9d/6380ad5dde983400b1fa6938.json",
    "created_at": "2022-11-25 11:56:13 UTC",
    "processed_at": "2022-11-25 11:56:13 UTC",
    "google_lens_url": "https://lens.google.com/uploadbyurl?url=https://i.imgur.com/HBrB8p0.png",
    "raw_html_file": "https://serpapi.com/searches/f6000d11bb444c9d/6380ad5dde983400b1fa6938.html",
    "prettify_html_file": "https://serpapi.com/searches/f6000d11bb444c9d/6380ad5dde983400b1fa6938.prettify",
    "total_time_taken": 2.75
  },
  "search_parameters": {
    "engine": "google_lens",
    "url": "https://i.imgur.com/HBrB8p0.png"
  },
  "knowledge_graph": [
    {
      "title": "Danny DeVito",
      "subtitle": "American actor",
      "link": "https://www.google.com/search?q=Danny+DeVito&kgmid=/m/0q9kd&hl=en&gl=US",
      "more_images": {
        "link": "https://www.google.com/search?q=Danny+DeVito&kgmid=/m/0q9kd&ved=0EOTpBwgAKAAwAA&source=.lens.button&tbm=isch&hl=en&gl=US",
        "serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=US&google_domain=google.com&hl=en&q=Danny+DeVito&tbm=isch"
      },
      "thumbnail": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRMLD_Ff8SPnXg5lP46m0Vq319gWJA33v2SM-95m01xm6ynHSNJrlFcyJNhydawpUpt_mU",
      "images": [
        {
          "title": "Image #1 for Danny DeVito",
          "source": "https://www.reddit.com/user/neodiogenes/",
          "link": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQri_oPDW2JJmoPHi-uPQQi7ij4aC8zgojZhn9FOZ50Vh2HiLh-",
          "size": {
            "width": 310,
            "height": 162
          }
        },
        ...
      ]
    },
    {
      "title": "Tony DeVito",
      "subtitle": "American professional wrestler",
      "link": "https://www.google.com/search?q=Tony+DeVito&kgmid=/m/06g2j9&hl=en&gl=US",
      "thumbnail": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTmnVrAz0VBdVVT3yGFVsY9bicxyC0CZFBrrxG8P9PpliSr5hqEcQCasl0TZ_SuC1nVo0w",
      "images": [
        {
          "title": "Image #1 for Tony DeVito",
          "source": "https://dom2-tv.xyz/brian-devito-facebook.html",
          "link": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQKkfXYfi_39BFVG4aXsoq3VBt3-l2p87KyRzD1KZbEJrQoaoZO",
          "size": {
            "width": 181,
            "height": 278
          }
        },
        ...
      ]
    },
    {
      "title": "Gage Skidmore",
      "subtitle": "American photographer",
      "link": "https://www.google.com/search?q=Gage+Skidmore&kgmid=/g/11crz_tb2h&hl=en&gl=US",
      "thumbnail": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQpi6H5mnWFrJKGhc6GNo8Or55e8SUZnfgMvNlXetPYSWQCg0dB",
      "images": [
        {
          "title": "Image #1 for Gage Skidmore",
          "source": "http://www.gageskidmore.com/",
          "link": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQpi6H5mnWFrJKGhc6GNo8Or55e8SUZnfgMvNlXetPYSWQCg0dB",
          "size": {
            "width": 275,
            "height": 183
          }
        },
        ...
      ]
    }
  ],
  "visual_matches": [
    {
      "position": 1,
      "title": "File:Danny DeVito by Gage Skidmore.jpg - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/File:Danny_DeVito_by_Gage_Skidmore.jpg",
      "source": "wikipedia.org",
      "source_icon": "https://encrypted-tbn2.gstatic.com/favicon-tbn?q=tbn:ANd9GcRLIcgPlYxOaoBg0MnSobLYyflrgF_RLdwAY09AXHWGy2jqWQnuIBNCY5I1BuzY7jeAJga0y0b9htBHe94i3Pg4B0NhHMNDVsmS-FVRKL014d-Xf6sX",
      "thumbnail": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS_EZZflK6_1HccjH6c-eZbcBIqmW7CZi1EL6Nfjm-2iiJoE6Am"
    },
    {
      "position": 2,
      "title": "Danny DeVito gets his own day in his native New Jersey",
      "link": "https://www.wowt.com/content/news/Danny-DeVito-gets-his-own-day-in-his-native-New-Jersey-481195051.html",
      "source": "wowt.com",
      "source_icon": "https://encrypted-tbn0.gstatic.com/favicon-tbn?q=tbn:ANd9GcSVS8rpJSkeh0oF49zOIkukNBkwhiOPhg25uAwQPduIqJjmu2tpFhgKz3uab91Zhvoei4tphrzYTCGGF2ifTsrhQiWZRLPjdGZDJcM5VQ-b3VM",
      "thumbnail": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQlRycvDiA1DhF7j8NtRoTpUOJNYzek1UML4jggGuegndiRzWNw"
    },
    {
      "position": 3,
      "title": "Danny Devito Earrings - Etsy Israel",
      "link": "https://www.etsy.com/il-en/listing/857117638/danny-devito-earrings",
      "source": "etsy.com",
      "source_icon": "https://encrypted-tbn2.gstatic.com/favicon-tbn?q=tbn:ANd9GcSBC4oQ3bkBuevoH8XpxAl0ri8XiuLd4I543l3vUizk2p7JnS_Kl1aJTVxs9nt4vEC2m0siqwjI-o3Mysd9TaJqSrdOdkseIKFJA66bIfBIaDs",
      "thumbnail": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS3w5zFc3jROLJYb_b8lmPJRkmMQRxsngR4zxtpAKl-F83Y5sk0"
    },
    ...
  ],
  "reverse_image_search": {
    "link": "https://www.google.com/search?tbs=sbi:AMhZZitM8l2rzmKo2mryfKQQ3vsvvac0sLKW6CjYJPr_109zyj0G3pP0hpVr9mxAcDyp6ZUtAZmz3--5Jg2K_1EfNMzRYsPDjZ2DNFZqWhXm_1CO9CMZCBwViH5oeybf-9uJcRHA-ibPhY-8-M07Avncl-zpMR5Mw6Xuw"
  }
}

Example with url: https://io.google/2021/assets/io_social_asset.jpg

Example with url: https://io.google/2021/assets/io_social_asset.jpg

JSON Example

{
  ...
  "text_results": [
    {
      "query": "May",
      "link": "https://www.google.com/search?q=May",
      "serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&google_domain=google.com&q=May"
    },
    {
      "query": "18-20",
      "link": "https://www.google.com/search?q=18-20",
      "serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&google_domain=google.com&q=18-20"
    },
    {
      "query": "#Googlel",
      "link": "https://www.google.com/search?q=#Googlel",
      "serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&google_domain=google.com&q=%23Googlel"
    },
    ...
  ],
  "related_content": [
    {
      "query": "#googlel",
      "link": "https://www.google.com/search?q=%23googlel&hl=en&gl=US",
      "serpapi_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=US&google_domain=google.com&hl=en&q=%23googlel"
    }
  ],
  ...
}