https://github.com/kshitijmhatre/duckduckgo-images-api
lightweight package to get image results from duck duck go
https://github.com/kshitijmhatre/duckduckgo-images-api
api duckduckgo-api image-search js node-module
Last synced: 2 months ago
JSON representation
lightweight package to get image results from duck duck go
- Host: GitHub
- URL: https://github.com/kshitijmhatre/duckduckgo-images-api
- Owner: KshitijMhatre
- License: mit
- Created: 2019-04-19T17:58:51.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-02-25T08:04:02.000Z (over 4 years ago)
- Last Synced: 2025-04-06T12:46:30.074Z (3 months ago)
- Topics: api, duckduckgo-api, image-search, js, node-module
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/duckduckgo-images-api
- Size: 18.6 KB
- Stars: 48
- Watchers: 0
- Forks: 17
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/deepanprabhu/duckduckgo-images-api) with same name. Thanks to, [deepanprabhu](https://github.com/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:
```javascript
{
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 2image_search function return a promise that resolves to array of complete results.
```javascript
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.```javascript
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.