npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lglen/bing-image-search

v0.2.1

Published

TypeScript SDK for searching and downloading images from Bing. Returns Bing-hosted thumbnail URLs (safe for <img> tags) and supports batch image downloads with deduplication.

Readme

@lglen/bing-image-search

TypeScript SDK for searching and downloading images from Bing. ESM only.

Originally started as a fork from the better-bing-image-downloader python projec to port basic functionality into typescript. The regular bing image downloader is part of the OG fork. The new thumbnail grabber API is my own work, including the custom logging framework. There is more to come!

Install

npm install @lglen/bing-image-search

API

searchBingImages(options) — get Bing-hosted thumbnails

Returns thumbnail URLs served directly by Bing's CDN — safe to embed in <img> tags, no hotlinking issues.

import { searchBingImages } from "@lglen/bing-image-search";

const results = await searchBingImages({
  query: "sunset landscape",
  limit: 10,
  adult: "moderate",  // default
  mkt: "en-US",       // default
});

console.log(`Found ${results.length} results:\n`);

for (const r of results) {
  console.log(`  Title: ${r.title || "(none)"}`);
  console.log(`  Source: ${r.sourceUrl.substring(0, 100)}...`);
  console.log(`  Thumb:  ${r.thumbnailUrl.substring(0, 100)}...`);
  console.log(`  Page:  ${r.pageUrl.substring(0, 100)}...`);
  console.log(`  Size:   ${r.width}x${r.height}`);
  console.log();
}

Bing class — download images to disk

Fetches images from source hosts and saves them locally with deduplication and resume support.

import { Bing } from "@lglen/bing-image-search";

const bing = new Bing({
  query: "kittens",
  limit: 20,
  outputDir: "./downloads/kittens",
  adult: "moderate",
  filter: "photo",        // "photo" | "clipart" | "gif" | "transparent" | "line"
  forceReplace: false,    // skip already-downloaded files
  verbose: true,
});

await bing.run();

// Results after run:
console.log(bing.images);   // ImageResult[] — saved files
console.log(bing.skipped);  // number already on disk
console.log(bing.errors);   // { url, error }[] — failed downloads

Error types

All download errors extend ImageSaveError: NetworkError · InvalidImageError · DuplicateImageError · WriteError

import { ImageSaveError, NetworkError } from "@lglen/bing-image-search";

Debugging

Debug logging is off by default. Enable it to see internal requests, parsed data, and errors:

import { debug, TraceEvents } from "@lglen/bing-image-search";

debug.enable("trace", {
  [TraceEvents.BingMedia.ParsedCardJson]: 5,
  [TraceEvents.BingMedia.AcceptedResult]: 20,
  [TraceEvents.Bing.FileExists]: 10,
});

// Reset counters between runs:
debug.resetCounts();

Custom handler — for Firebase Cloud Functions or structured logging:

debug.setHandler((entry) => {
  // entry.timestamp, entry.level, entry.module, entry.message, entry.data
  console.log(JSON.stringify(entry));
});

Levels: "off" | "error" | "warn" | "info" | "debug" | "trace"

Tip: "trace" level logs are rate-limited internally to avoid flooding — noisy per-item logs auto-cap at 5–20 entries. Call debug.resetCounts() to reset the caps between runs.

License

MIT