John Cole

Jul 17, 2026 • 4 min read

How to Build an Image Dataset from Google Images with One API

Pull thousands of labeled image URLs with dimensions from Google Images in one API call, export to CSV or JSON, and refresh it on a schedule.

I needed a few thousand labeled images to train a small vision model, and every path looked painful. Google does not hand out an open image search API, the first-party options are quota bound and thin on fields, and writing a headless browser scraper to walk the results meant maintaining a fragile pipeline. So I put the boring part behind one API.

The Google Images API is a pay-per-result scraper that takes a list of queries and returns clean JSON for every image, so you can build an image dataset from Google Images without writing or maintaining any scraping code.

What it returns

Each image comes back as one row, ready to load straight into a dataframe or a database:

  • The full-size imageUrl with imageWidth and imageHeight

  • A thumbnailUrl with its own dimensions

  • The source site name and domain

  • The link to the page where the image appears

  • The query and position it ranked at

It returns the image search data, not the raw files, and it does not run reverse-image search or visual de-duplication. You follow the link or imageUrl to download a file yourself.

Run it in three steps

Open the Google Images scraper, pass your class labels as queries, and set how many results you want per query. Optionally set a country and language. Run it, then export the dataset as JSON, CSV, or Excel. For a machine-learning dataset, pass every label at once and set a high per-query ceiling so one run fills the whole set.

Use it as a REST API

The Apify API runs the Actor and returns the dataset in one call, so you can wire the image pull into any script or job:

POST /v2/acts/johnvc~google-images-api/run-sync-get-dataset-items

{"queries": ["golden retriever", "german shepherd"], "maxResultsPerQuery": 200, "gl": "us", "hl": "en"}

The Python example shows the same call with the apify-client package.

Wire it into Claude with MCP

The Actor runs over the Model Context Protocol, so an AI agent can call it as a tool. Add the hosted Apify MCP server and your agent can pull image results for any topic in one call:

https://mcp.apify.com/?tools=actors,docs,johnvc/google-images-api

What people build with it

Beyond training data, people use it to pull product and competitor imagery for SEO research, source high-resolution reference shots for design, and track which images rank for a keyword over time. Each of these has a one-click setup on the Examples page, and the full write-up lives on the Peerlist project.

FAQ About Scraping Google Images

What does this Google Images scraper actually return?

It returns structured JSON for each image in the results: the full-size image URL with width and height, a thumbnail, the source site and domain, the page the image appears on, and the query and position it ranked at. It reads the live image search results, so freshness matches what Google shows for that query. It does not download the raw files or run reverse-image search.

How do I call the scraper as an API, and what does it cost?

Send a POST to the Actor's run-sync-get-dataset-items endpoint with your queries and a per-query limit, and the run returns the dataset as JSON. You pay per image returned at $0.0001 each, which is $0.10 per 1,000 images, with no per-run or setup fee, so a small pull costs a fraction of a cent.

Can I use this scraper from Claude or another AI agent over MCP?

Yes. Add it as a tool through the hosted Apify MCP server with the Actor URL, and an agent in Claude, Cursor, or ChatGPT can fetch image results for any topic in one call and work with the JSON directly, no scraping code required.

Can I schedule the scraper to refresh a dataset automatically?

Yes. Save a task with your queries, then attach a schedule from the Actor's Actions, then Schedule menu. A cron string like 0 7 * * * runs it daily at 7 AM, and one schedule can refresh every query you track, so a rankings history builds up on its own.

Questions or a field you wish it returned? Open an issue on the Actor page and I usually reply within a day.

Join John on Peerlist!

Join amazing folks like John and thousands of other builders on Peerlist.

peerlist.io/

It’s available... this username is available! 😃

Claim your username before it's too late!

This username is already taken, you’re a little late.😐

0

0

0