@l2studio/iqdb-api
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.3 • Public • Published

    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

    By default, there is only one default function.

    import iqdb from '@l2studio/iqdb-api'
    
    iqdb(picture: string | Buffer | Readable, opts?: Options): Promise<Response>

    Options:

    type Options = {
      filename?: string       // File name when picture is Buffer or Readable type (optional)
      website?: WebsiteOption // Website and services (optional)
      ignoreColors?: boolean  // Whether ignore picture color (optional)
      similarity?: number     // Whether to filter results greater than or equal this similarity (optional: 0 - 100)
      timeout?: number        // http request timeout (optional)
      proxy?: {               // http proxy (optional)
        host: string          //      proxy host (required)
        port: number          //      porxy port (required)
      }
    }
    
    // Website options use corresponding services due to id. Services is optional.
    type WebsiteOption = ({
      id: 'www'
      services?: ('danbooru' | 'konachan' | 'yandere' | 'gelbooru' | 'sankaku' | 'e-shuushuu' | 'zerochan' | 'anime-pictures')[]
    } | {
      id: '3d'
      services?: ('3dbooru' | 'idol')[]
    })

    Response:

    type Response = {
      success: boolean   // Whether succeed
      error?: string     // Error message (Only when success is false)
      results?: Result[] // Search results (Only when success is true)
    }
    
    type Result = {
      head: 'best match' | 'additional match' | 'possible match' | string // Result title head
      url: string                                // Service source url
      image: string                              // IQDB picture preview url
      sources: string[]                          // Service sources
      width: number                              // Picture width
      height: number                             // Picture height
      type: 'safe' | 'ero' | 'explicit' | string // Picture type (safe: not R18, ero: R18)
      similarity: number                         // Picture similarity (0 - 100)
      properties: {                              // Picture properties
        rating?: string                          // Rating
        score?: number                           // Score
        tags?: string[]                          // Tags
      } & Record<string, any>                    // Others
    }

    Example 1: Default website options is www and all services.

    iqdb('http://your-picture-url.jpg')

    Example 2: Search using specified services.

    iqdb('http://your-picture-url.jpg', {
      website: {
        id: 'www',
        services: ['danbooru', 'yandere'] // Use Danbooru and yande.re services
      }
    })

    License

    Apache-2.0

    Install

    npm i @l2studio/iqdb-api

    DownloadsWeekly Downloads

    6

    Version

    0.1.3

    License

    Apache-2.0

    Unpacked Size

    16.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • l2studio