/duckduckgo-images-api

lightweight package to get image results from duck duck go

Primary LanguageJavaScriptMIT LicenseMIT

This is a fork of KshitijMhatre's duckduckgo-images-api

Changes:

  • Removed the generator to make the package Node 8-compatible
  • Made axios a peer dependency

duckduckgo-images-api

A lightweight node package to programmatically obtain image search results from DuckDuckGo search engine.

The method used is inspired from python package with same name. Thanks to, deepanprabhu for original source. This is my first node package and it was fun to write.

usage

To install, run:

npm i duckduckgo-images-api

When using TypeScript, run:

npm i @types/duckduckgo-images-api

The package provides simple async api. And uses following config object as input:

{ 
    query: "search term", 
    moderate : false,   
    iterations : 2 ,
    retries  : 2
}
  • query param is mandatory
  • moderate (optional) to moderate search results if none provided defaults to moderation off (false)
  • iterations (optional) limit the number of result sets fetched, default 2
  • retries (optional) limit retries per iteration, default 2

image_search function return a promise that resolves to array of complete results.

image_search({ query: "birds", moderate: true }).then(results=>console.log(results))

Please feel free to report any issues or feature requests.

note

DuckDuckGo provides an instant answer API. This package does not use this route. This package mocks the browser behaviour using the same request format. Use it wisely.