Skip to main content

Scrape direct image URLs from Bing, DuckDuckGo, Yandex, and Google

Project description

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 imgapi 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 imgapi 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 imgapi 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

imgapi/              # 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

Project details


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.1.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.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: imgsearch_api-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 69e2181fbcb61a9a73dcc2e41338e5f42b25f870751b6389e91e8c6f2ffbd947
MD5 7e09b742aa61bb56c62b4784e4a17f75
BLAKE2b-256 16ed8acfbf09a97ed92ad713ebf834521ca5b48bcb0d7a4034ebd77ef88edacd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: imgsearch_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5df793d581ef97a6ed87af0c0afd2e2f5a002f64bc263e0a6de12e215b628c66
MD5 978f32454d595f4814f4b5f3e878cae8
BLAKE2b-256 d3095335885eed6540f9ac39cf1be12c1c8b8dd7787751395b27b91616fc8e84

See more details on using hashes here.

Supported by

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