Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 894 Bytes

README.md

File metadata and controls

43 lines (27 loc) · 894 Bytes

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.