Registry / search / duckduckgo-images-api

duckduckgo-images-api

JSON →
library1.0.5jsnpmunverified

A lightweight Node.js package (v1.0.5) for programmatic image search using DuckDuckGo. It simulates browser requests to retrieve image results, as the official Instant Answer API does not support image search. The package offers both promise-based and async generator interfaces. Compared to alternatives like Google Custom Search, it requires no API key. Updated sporadically; last release in 2021. Not officially supported by DuckDuckGo.

npm install duckduckgo-images-api
INSTALL
IMPORT
SIG · DUCKDUCKGO-IMAGES-
D
duckduckgo-images-api
searchjavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

image_search
import { image_search } from 'duckduckgo-images-api'
const { image_search } = require('duckduckgo-images-api')
ESM import works in Node >=14, but package ships CommonJS; use dynamic import or require() for older Node.
image_search_generator
import { image_search_generator } from 'duckduckgo-images-api'
const image_search_generator = require('duckduckgo-images-api').image_search_generator
Correct as named import; generator requires async iteration support.
default export
import api from 'duckduckgo-images-api'
const api = require('duckduckgo-images-api')
Package has no default export; use named imports only.

Searches DuckDuckGo for bird images with moderation on, logs array of result objects.

import { image_search } from 'duckduckgo-images-api'; async function main() { try { const results = await image_search({ query: 'birds', moderate: true, iterations: 2, retries: 2 }); console.log(results); } catch (err) { console.error(err); } } main();
Debug
Known issues
gotchaPackage mocks browser requests and may violate DuckDuckGo's terms of service; use at your own risk.
fix
Consider using official APIs (e.g., Google Custom Search) for production.
affects: all
deprecatedType definitions are provided by a separate package @types/duckduckgo-images-api, which may be out of sync.
fix
Install @types/duckduckgo-images-api and check for version compatibility.
affects: >=1.0.0
gotchaimage_search_generator is an async generator; requires Node >=10 for for-await-of.
fix
Use Node 14+ or implement a custom wrapper with callbacks.
affects: >=1.0.0
breakingNo breaking changes documented; however, DuckDuckGo may change their response format breaking the scraping logic.
fix
Pin version and watch DuckDuckGo updates.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: image_search is not a function
Incorrect import (e.g., default import) trying to use image_search as function.
fix
Use named import: import { image_search } from 'duckduckgo-images-api'
Cannot find module 'duckduckgo-images-api'
Package not installed or used in browser environment.
fix
Run npm install duckduckgo-images-api in Node project.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
38
Resources
duckduckgo-images-api — npm install duckduckgo-images-api · libregistry