A library for iqdb.org image search api
npm install --save @l2studio/iqdb-api
# or
pnpm i @l2studio/iqdb-apiimport * as iqdb from '@l2studio/iqdb-api' # or import { search } from '@l2studio/iqdb-api'
iqdb.search(input: SearchInput, options?: SearchOptions): Promise<SearchResponse>
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')
Website
originandservicessee 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 }
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 }
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[] }
Apache-2.0