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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@l2studio/iqdb-api

v0.2.1

Published

A library for iqdb.org image search api

Downloads

12

Readme

L2 Studio - IQDB API

A library for iqdb.org image search api

Install

npm install --save @l2studio/iqdb-api
# or
pnpm i @l2studio/iqdb-api

API

import * as iqdb from '@l2studio/iqdb-api'
# or
import { search } from '@l2studio/iqdb-api'

.search

iqdb.search(input: SearchInput, options?: SearchOptions): Promise<SearchResponse>

SearchInput

A type alias, equivalent to String | Buffer | Readable. Can be a stringify image url, image buffer or readable stream.

export type SearchInput = string | Buffer | Readable

E.g.:

  • String - 'http://example.com/yourimage.jpg'
  • Buffer - fs.readFileSync('/path/yourimage.jpg')
  • Readable - fs.createReadStream('/path/yourimage.jpg')

SearchOptions

Website origin and services see also: /src/type.ts

export interface SearchOptions {
  /*
   * Websites and Image Services Used.
   * If services is not defined, all services of the current origin are used.
   */
  website?: ({
    origin: Website,
    services?: RootWebsiteService[]
  } | {
    origin: Website,
    services?: ThreeDWebsiteService[]
  })
  /**
   * Custom filename when the input is a image buffer or readable stream.
   * Use random string when is not defined.
   */
  filename?: string
  // Whether to ignore the color of the input image. (Force Gray)
  ignoreColors?: boolean
  // Whether to pick up more other results.
  pickOtherResults?: boolean
  // Got request options (See: https://github.com/sindresorhus/got/blob/main/documentation/2-options.md)
  requestOptions?: OptionsOfTextResponseBody
}

SearchResult

export interface SearchResult {
  // Result match
  match: 'best' | 'additional' | 'possible' | 'other'
  // Thumbnail
  thumbnail: {
    // Raw src: /danbooru/foo/bar.jpg
    src: string
    // Fixed src: https://iqdb.org/danbooru/foo/bar.jpg
    fixedSrc: string
    // Image rating: q, s, e...
    rating?: string
    // Image score
    score?: number
    // Image tags
    tags?: string[]
  }
  // All source services
  sources: Array<{
    // Service: Danbooru, Gelbooru, etc...
    service: Service
    // Raw href: //danbooru.donmai.us/posts/foo
    href: string
    // Fixed href: http://danbooru.donmai.us/posts/foo
    // Fixed always use http!
    fixedHref: string
  }>
  // Result width
  width: number
  // Result height
  height: number
  // Result type
  type: 'safe' | 'ero' | 'explicit' | 'unrated'
  // Result similarity (0 - 100)
  similarity: number
  // Similarity percentage (0.00 - 1.00)
  similarityPercentage: number
}

SearchResponse

export interface SearchResponse {
  // Searched images
  searched: number
  // Timecost (Seconds) e.g.: 14.054
  timeSeconds: number
  // Timecost (Milliseconds) e.g.: 14054
  timeMilliseconds: number
  // IQDB Thumbnail src. e.g.: https://iqdb.org/thu/thu_24432b8d.jpg
  thumbnailSrc: string
  // Other search sites for thumbnail src.
  otherSearchHrefs: {
    saucenao: string
    ascii2d: string
    google: string
    tineye: string
  }
  // Search results
  results: SearchResult[]
}

License

Apache-2.0