Bulk Image Search: Getting Started
Introducing the Bulk Image Search tool - a simple, no-code web app to utilize SerpApi's Google Lens API. Whether you're a researcher, marketer, or someone who performs many visual searches, the Bulk Image Search tool streamlines visual searches and helps you get the insights you need faster. Keep reading to learn how to get started.
What Does It Do?
- Upload images to Imgur in bulk
- Scrape multiple Google Lens search results simultaneously
- Download search results in your preferred format (CSV, JSON, or Excel)
- Access images from your Imgur account
SerpApi Introduction
SerpApi is a web scraping company that allows developers to extract search engine results and data from various search engines, including Google, Bing, Yahoo, Baidu, Yandex, and others. It provides a simple way to access search engine data programmatically without dealing directly with the complexities of web scraping.
Google Lens API
This tool uses SerpApi's Google Lens API to scrape search results from Google Lens search results (https://lens.google/) when performing an image search. The results related to the image could contain visual matches, video, text, and other data. Search results can be returned from specific countries or languages.
The Google Lens API currently only supports images with URLs, meaning the image must be hosted publicly to be searched. SerpApi has an open feature request to enable file uploads, and you can follow on it's progress here:
[Google Lens API] Support image search via file upload #948
To-do
- [ ] Implement Google Lens and Reverse Image search via file upload
- [ ] Document that
async=1
is not available for these requests
Experimental implementation: https://github.com/serpapi/SerpApi/pull/2412
Use Cases
The Google Lens API can be leveraged for various use cases across different industries. Here are a few examples:
Visual Search for E-commerce
- Identify similar products or alternatives based on an image of a product
- Monitor competitor pricing and product offerings by searching for their images
Academic and Scientific Research
- Identify plant and animal species from images
- Reverse image search to find the original source of an image
- Find similar images for training AI models
Trend Analysis
- Detect emerging visual styles, designs, or themes across industries
- Monitor changes in product packaging, advertising, or website designs over time
- Gather insights on popular visual motifs, objects, or scenes
The Google Lens API is a versatile and powerful tool for developers, researchers, marketers, and anyone who needs to extract insights from visual data at scale. By leveraging programmatic access to this visual search functionality, users can streamline their workflows.
You can test the Google Lens API in SerpApi's playground environment found here:
Quick Setup
1 - Sign up for free accounts:
- An Imgur account, for storing your images.
- A SerpApi account, is needed to perform searches. SerpApi provides a free plan with 100 successful searches included every month.
2 - Log in to Bulk Image Search with your Imgur account
3 - Add your SerpApi API key to the settings page.
Using the Tool
In this section, we will walk through performing a bulk image search. The tool has three simple steps: uploading your images, configuring your search parameters, and reviewing your results.
Upload Images
Head to the upload page page to get started. You can upload up to 50 images with a maximum single image size of 4.5MB:
https://bulkimagesearch.com/upload
Search Images
After adding images to your Imgur account, navigate to the search page to select all the images you would like to search for, set your search parameters, and choose the format you want the results returned in.
Get Your Results
Click the "Search" button to start your search. Before your searches are processed, you'll be asked to confirm the maximum number of credits that will be used.
Note that if you perform a search with the same parameters within an hour, SerpApi will serve cached results that do not count against your monthly search quota. To bypass search caching, select the "No Cache" search option.
Manual Method
Now that I've shown you how easy it is to use the Bulk Image Search tool let's discuss what it would take to accomplish this manually using scripts (or as close as possible).
Image Hosting
One common issue I see while trying to use the Google Lens API is searching for images hosted via AWS S3 buckets. For whatever reason, Google Lens has trouble processing AWS URLs, making choosing an image hosting option a bit tricky.
For this reason, I typically suggest users host their images on Imgur (https://imgur.com/), as the issues mentioned above do not exist for Imgur URLs.
Imgur uses OAuth 2.0 for Authorization of requests; while I won't walk through the complete configuration, below are some resources for getting up and running with the Imgur API:
Image Uploading
Once Authorization is set up, uploading images to Imgur is as easy as POSTing form data to the following endpoint:
https://api.imgur.com/3/image
Below is an example from Imgur's docs from uploading an image:
var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.imgur.com/3/image',
'headers': {
'Authorization': 'Client-ID {{clientId}}'
},
formData: {
'image': {
'value': fs.createReadStream('/home/flakrim/Downloads/GHJQTpX.jpeg'),
'options': {
'filename': 'GHJQTpX.jpeg',
'contentType': null
}
},
'type': 'image',
'title': 'Simple upload',
'description': 'This is a simple image upload in Imgur'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Image Search
After uploading your images to Imgur and storing the image's URL, you can start fetching search results from the Google Lens API. I recommend using one of SerpApi's integrations for many popular programming languages:
Using these integrations will allow you to export code directly from SerpApi's playground:
To get a better sense of how to write a script that performs image searches, check out these other blog posts:
- How to Scrape Google Lens Results
- Web scraping Google Lens Results with Nodejs
- Scrape Google Lens with Python
- Get Image Sources through Google Lens
Ready to Try It?
The Bulk Image Search tool solves all of these problems for you. It handles authentication with Imgur, uploading images to Imgur, batching requests to SerpApi, and returning more useful spreadsheet-ready formats (CSV and XSLX).
Visit https://bulkimagesearch.com/ to start searching your images in bulk.
Frequently Asked Questions
Is my API key safe?
Yes, your API key is encrypted and never stored in plaintext. It is only used to perform searches on your behalf. API keys are not stored in a database or server.
How do I handle "suspicious download" warnings?
Chrome may flag the ZIP file as suspicious when downloading bulk search results. You can safely proceed by clicking "download suspicious file" in Chrome's download bar.
I have a question or issue not answered here
For any additional questions or concerns, please get in touch with me at nathan@serpapi.com.
Top comments (1)
That's handy. Thanks for sharing!