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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgsearch_api-0.1.2.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imgsearch_api-0.1.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file imgsearch_api-0.1.2.tar.gz.

File metadata

  • Download URL: imgsearch_api-0.1.2.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for imgsearch_api-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dc26fb5b2dbb47dfe77c27bb93f4f4d3487edd5385d1cf3aa20cc341977037e9
MD5 75e65a1bf45a0d99cf9cddff3f64d0af
BLAKE2b-256 c114e0b76772358b432d57e6249c7fcf1af70557e1a5b2933b03a2966e778e51

See more details on using hashes here.

File details

Details for the file imgsearch_api-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: imgsearch_api-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for imgsearch_api-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec2e83b64c751420e0b50a2665abc384d9608e83d595151bb454bea82fa9a540
MD5 8f635635bb0147970f9cba0ad0ff5077
BLAKE2b-256 666aaae463843b02bff61130eeaa87493e02472e651294b2087bebfe1a1f276f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page