Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

duckduckgo-images-api

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duckduckgo-images-api

DuckDuckGo image-search api for node

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
increased by4.47%
Maintainers
1
Weekly downloads
 
Created
Source

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

image_search_generator function is a async generator that yield promise of result set on each iteration. Useful for large iterations. Please check the node version compatability for this syntax.

async function main(){
    for await (let resultSet of image_search_generator({ query: "birds", moderate: true ,iterations :4})){
      console.log(resultSet)
    }
  }
  
main().catch(console.log);

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.

Keywords

FAQs

Package last updated on 29 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc