Skip to main content

imgsearch-api

Scrape direct image URLs from Bing, DuckDuckGo, Yandex, and Google. Returns links like https://example.com/photo.jpg — not thumbnails, not base64, not search pages.


Install

Python (pip)

pip install imgsearch-api
scrapling install   # one-time: downloads stealth browser (~200 MB)

Node.js (npm)

npm install imgsearch-api
# browser is installed automatically via postinstall

Python usage

Import

from imgsearch_api import image_search, random_image

image_search(query, engines=None, n=10)

Search for images matching a query. Returns a list of direct image URLs.

Parameters

Parameter Type Default Description
query str required Search term, e.g. "golden retriever"
engines list[str] | None ["bing", "ddg"] Engines to query, in priority order
n int 10 Maximum number of URLs to return

Returns list[str] — direct image URLs, up to n items.

Examples

from imgsearch_api import image_search

# Default: Bing first, DDG fills the rest
urls = image_search("sunset", n=10)

# Specific engine only
urls = image_search("cat", engines=["bing"], n=5)

# Multiple engines, tries each until n results collected
urls = image_search("dog", engines=["bing", "ddg"], n=20)

random_image(query, engines=None)

Returns a single random direct image URL for the query.

Parameters

Parameter Type Default Description
query str required Search term
engines list[str] | None ["bing", "ddg"] Engines to query

Returns str | None — one direct image URL, or None if no results.

Examples

from imgsearch_api import random_image

url = random_image("abstract art")
# → "https://upload.wikimedia.org/wikipedia/commons/..."

url = random_image("mountain", engines=["bing"])
# → "https://images.pexels.com/photos/.../mountain.jpg"

Engines

Engine Key Returns Notes
Bing "bing" Full-size original URLs ✅ Recommended. Fast, reliable, high quality.
DuckDuckGo "ddg" Bing CDN thumbnails ✅ Works. Uses Bing's index — thumbnails are valid images.
Yandex "yandex" Full-size originals ⚠️ May be geo-blocked. Works with VPN.
Google "google" Full-size originals ⚠️ Requires residential proxy. Blocked by reCAPTCHA on most IPs.

Recommended: use ["bing"] or ["bing", "ddg"] for reliability.


Node.js usage

Import

const { imageSearch, randomImage, closeBrowser } = require("imgsearch-api");

imageSearch(query, options?)

Parameters

Parameter Type Default Description
query string required Search term
options.engines string[] ["bing","ddg"] Engines in priority order
options.n number 10 Max URLs to return

Returns Promise<string[]>

const { imageSearch } = require("imgsearch-api");

const urls = await imageSearch("sunset", { n: 10 });
const urls = await imageSearch("cat", { engines: ["bing"], n: 5 });
const urls = await imageSearch("dog", { engines: ["bing", "ddg"], n: 20 });

randomImage(query, options?)

Parameters

Parameter Type Default Description
query string required Search term
options.engines string[] ["bing","ddg"] Engines to query

Returns Promise<string|null>

const { randomImage } = require("imgsearch-api");

const url = await randomImage("abstract art");
console.log(url); // "https://example.com/image.jpg"

closeBrowser()

Shut down the browser instance cleanly when done.

const { imageSearch, closeBrowser } = require("imgsearch-api");

const urls = await imageSearch("mountain");
console.log(urls);
await closeBrowser();

How it works

Each engine scrapes results using a stealth headless browser to bypass bot detection. Image URLs are extracted from structured data — never from thumbnails or base64 blobs:

  • Bing: parses murl from a.iusc[m] JSON attribute
  • DDG: decodes real URL from DDG CDN proxy ?u= param
  • Yandex: parses img_href from data-bem JSON
  • Google: extracts "ou":"..." original URL from embedded script data

The browser stays open between calls (singleton) — starts once, reused for speed.


Project structure

imgsearch_api/       # Python package source
  __init__.py
  _fetcher.py
  search.py
  engines/
    bing.py  ddg.py  yandex.py  google.py

node/                # Node.js package source
  index.js
  _browser.js
  engines/
    bing.js  ddg.js  yandex.js  google.js

Metadata

Release files for imgsearch-api 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imgsearch-api 0.1.2
File Size Uploaded
imgsearch_api-0.1.2.tar.gz 27.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for imgsearch-api 0.1.2
File Interpreter ABI Platform
imgsearch_api-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.2 kB

Release files / imgsearch_api-0.1.2.tar.gz

Download URL imgsearch_api-0.1.2.tar.gz
Size 27.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dc26fb5b2dbb47dfe77c27bb93f4f4d3487edd5385d1cf3aa20cc341977037e9
BLAKE2b-256 checksum
How to use checksums
c114e0b76772358b432d57e6249c7fcf1af70557e1a5b2933b03a2966e778e51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / imgsearch_api-0.1.2-py3-none-any.whl

Download URL imgsearch_api-0.1.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec2e83b64c751420e0b50a2665abc384d9608e83d595151bb454bea82fa9a540
BLAKE2b-256 checksum
How to use checksums
666aaae463843b02bff61130eeaa87493e02472e651294b2087bebfe1a1f276f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page