Google Lens API: Reverse Image Search as JSON
You can run a Google Lens reverse image search over HTTP with one GET request to /v1/google-lens/lens and an image URL in the url parameter. The response is JSON, with matches listed by position, each with a title, a link and a source. A successful call costs 1 credit, and a failed call costs nothing.
What does the Google Lens API return?
Google Lens takes a picture and finds pages that show the same or similar images. The Perceptlayer endpoint wraps that lookup: you send an image URL, and you get back JSON with the matches Lens found, in ranked order. There's no HTML to parse and no browser session to drive.
The API page for Google Lens lists a single endpoint, Lens, in the Search engines area. It's a standard-tier endpoint, so it works with an ordinary key and doesn't need the restricted-endpoint terms.
What you get depends on type. The recorded sample for this article uses type=visual_matches, so the response excerpt below shows that group. We haven't recorded the other three values, so this guide doesn't describe their fields. Run them in the playground on the API page to see what they return for your own images.
How do you make a reverse image search request?
Send a GET request with the image address URL-encoded in url and your key in the X-API-Key header. Keys start with sk_live_, and the authentication docs cover the api_key query parameter for clients that can't set headers. If you don't have a key yet, get a free API key.
This request searches for matches of a coffee photo hosted on Wikimedia Commons:
curl "https://api.perceptlayer.com/v1/google-lens/lens?url=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F4%2F45%2FA_small_cup_of_coffee.JPG&type=visual_matches" \
-H "X-API-Key: $API_KEY"
The url value is percent-encoded because it contains : and / characters inside a query string. If you build requests in code, let your HTTP library do the encoding. In Python, passing a dict to params does it for you:
import os
import requests
resp = requests.get(
"https://api.perceptlayer.com/v1/google-lens/lens",
params={
"url": "https://upload.wikimedia.org/wikipedia/commons/4/45/A_small_cup_of_coffee.JPG",
"type": "visual_matches",
},
headers={"X-API-Key": os.environ["API_KEY"]},
timeout=60,
)
resp.raise_for_status()
for match in resp.json()["visual_matches"]:
print(match["position"], match["title"])
The image in these examples is the Commons file A small cup of coffee. Swap in any image address your own pipeline holds.
Which parameters does the Lens endpoint take?
The endpoint takes one required parameter and two optional ones. url is the image to look up, q adds a text query alongside the image, and type narrows the response to one kind of match. Nothing else about them is documented, so there are no stated defaults to rely on: pass type explicitly when you care which group you get.
| Parameter | Type | Required | Notes |
|---|---|---|---|
url |
string | yes | Address of the image; up to 2048 characters |
q |
string | no | Text query to go with the image; up to 500 characters |
type |
string | no | One of all, products, exact_matches, visual_matches |
The four type values map to different jobs, which is how you'd choose between them:
type |
Use it when you want |
|---|---|
visual_matches |
Pages with images that look like yours |
exact_matches |
Pages that show the same image |
products |
Product results for the item in the image |
all |
Every group in one response |
The q parameter is useful when the image has more than one subject. If a photo shows a desk with a lamp on it and you care about the lamp, a short text query gives Lens something to focus on. Keep it within 500 characters.
What does a response look like?
The response echoes your inputs under search_parameters, then lists matches under the group you asked for. Here is an excerpt from the recorded response for the coffee photo, trimmed with … where the long link values are cut:
{
"search_parameters": {
"url": "https://upload.wikimedia.org/wikipedia/commons/4/45/A_small_cup_of_coffee.JPG",
"type": "visual_matches"
},
"visual_matches": [
{
"source": "google.com",
"title": "Coffee - Wikipedia",
"link": "https://www.google.com/goto?url=CAESYAHrOzAVjqyZsRw2qYBWnGTQxvo0jp82FNgkFtdeekgdFsMzllECFQuW0N_YE0jQU21l8peWTBGW9imMZMQnJR97PbsxrAVhJlwl7Y3TiYThovCMSqoX1PYgBXCF…",
"position": 1
},
{
"source": "google.com",
"title": "Un espresso con carácter: tueste oscuro, aroma a chocolate y ...",
"link": "https://www.google.com/goto?url=CAESYwHrOzAVNdoGpK3FtZxCqcuZTEUq7d9luEWqqwu14ENvcGHD8sy55sN4m7HGYYUpQ0EeamvXBbXOfY-pkMl80yJ8WBgs9vWiCC9-HhswGQ8J1dWANIdzkP-CGSaR…",
"position": 2
}
]
}
Three details from this sample matter if you build on it. First, position is the rank, starting at 1. Second, title is the title of the matched page, and it comes back in the page's own language: the second match is Spanish. Third, in this recording link is a google.com/goto address and source is google.com, so neither field names the destination site by itself.
That last point affects how you'd use the data. If you need the destination domain, test a few results from your own images before you design around source. Don't assume it carries the site name.
How do you use it to find a product source or duplicate listings?
Reverse image search answers a narrow question: where else does this picture appear? That makes it a good fit for two jobs. One is tracing a product photo back to the pages that sell or describe the item. The other is spotting the same photo reused across listings, such as a used-car ad or a rental that appears on more than one site.
For product sourcing, call the endpoint with a supplier or marketplace photo and type=products, then review the matches by hand or pass the titles to a matcher. For listing checks, call it with type=exact_matches and treat any other page that shows the same image as a candidate duplicate. A shared photo is a signal, not proof: agents and dealers legitimately post the same pictures in several places, and a different photo doesn't prove two listings differ.
So combine the image signal with fields you already have. Compare price, location and attributes before you merge two records. The post on deduplicating listings across sources covers matching without shared IDs, and the guides to the AutoScout24 API and the Rightmove API show where listing photos come from in the first place.
For a visual pass over a phrase instead of a photo, the Google Images API searches by text. For prices on a product once you know what it is, see the Google Shopping API.
What does it cost, and how fast can you call it?
Each successful call costs 1 credit, and a failed call costs nothing. Every successful response carries X-Credits-Used and X-Credits-Remaining, so you can track spend per call. The credits docs explain how the balance works.
A worked example: one pass over 5,000 listing photos is 5,000 calls × 1 credit, or 5,000 credits. The free tier gives 100 credits after you verify an email address, with no credit card, so the first 100 of those lookups are free and the rest need a pack. Purchased credits come in prepaid packs from 10,000 credits and last 12 months. See pricing for what credits cost.
Rates are per account and counted per minute. Free accounts get 1 request a second (60 a minute), and paying accounts get at least 5 a second (300 a minute). A rate-limited call returns 429 with a Retry-After header, and the rate limits docs have the rest. For a batch of images, a bounded worker loop is enough; the post on concurrent requests in Python under rate limits shows one.
Failures arrive as an HTTP status and a JSON body with error.code, error.message and error.request_id. A bad url or type returns invalid_parameters (422). Requests have no idempotency key, so a call that timed out on your side may still have succeeded and been billed. The errors docs list every code.
Next step: open the Lens endpoint page, paste one of your own image URLs into the playground, and run a real call with your key.
APIs in this post
Frequently asked questions
Can I upload an image file to the Google Lens API?
The endpoint takes an image address in the url parameter, not a file upload. The only documented image input is url, up to 2048 characters. If your image sits on a local disk, host it somewhere reachable first and pass that address.
How much does a Google Lens API call cost?
A successful call to /v1/google-lens/lens costs 1 credit. Failed calls cost nothing and return X-Credits-Used: 0. Checking 2,000 images = 2,000 calls × 1 credit = 2,000 credits. The free tier includes 100 credits once, on signup, and pricing shows what additional credits cost.
Which match types can I request?
The type parameter accepts all, products, exact_matches and visual_matches. Leave it out and you rely on undocumented behaviour, so set it explicitly. The recorded sample in this guide covers visual_matches, whose entries have title, link, source and position.
Does a match prove two listings are the same?
No. A match tells you the same or a similar picture appears on another page. Sellers reuse photos legitimately, so use the match as one signal and compare price, location and attributes before merging records. The data is returned as found at the time of the call.
Can an AI agent call this endpoint?
Yes. The MCP server at https://perceptlayer.com/mcp exposes search_endpoints, get_endpoint and call_endpoint. An agent can look up the Lens endpoint for free and call it with an image URL, spending 1 credit on success. See the AI agents docs.