Skip to content

FriendlyUser1/async-image-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-image-search

Asynchronous Google Images search.

Returns:

{ width: number, height: number, url: string }[]

Installation

npm install async-image-search

Usage/Examples

import { search as imageSearch } from "async-image-search";

async function getImage(query, index = 0) {
	const results = await imageSearch(query);

	console.log(`Found ${results.length} results for ${query}.`);

	return results[Math.min(index, results.length - 1)];
}

getImage("Rosalina").then((image) => {
	const { width, height, url } = image;
	console.log(`Image (${width} x ${height}): ${url}`);
});

Contributing

Please open an issue for bug reports, or a pull request if you want to contribute.