Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dinky.js

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dinky.js

JavaScript bindings for Derpibooru API

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

dinky.js

JavaScript bindings for Derpibooru API

Build Status Code Coverage dependencies Status devDependencies Status

Installation

You can install this package from npm:

npm install dinky.js

Or with yarn:

yarn add dinky.js

Usage

Dinky implements chainable API to build each request and all requests will return a Promise that resolves data taken from Derpibooru API. The minimal example that will return an image by known ID:

import dinky from "dinky.js"

// The following request will return the 1th uploaded image from Derpibooru.
// Equivalent to https://derpibooru.org/images/0.json request
dinky().images().id(0).then(console.log)

Or if you want to find pictures by their tags, just use .search() method:

import dinky from "dinky.js"

// You can specify tags right in the .search() method
// By default all requests will be sent to derpibooru.org, but you can
// manually set one of Derpibooru's host in constructor options if you need.
// The following example is equivalent of these requests:
// https://derpibooru.org/search.json?q=artist:rainbow,safe&random_image=true
// ...and then this one:
// https://trixiebooru.org/images/<received image id>.json
dinky({url: "trixiebooru.org"}).search(["artist:rainbow", "safe"]).random()
  .then(console.log)

API

class Dinky

constructor([options]) -> {Dinky}

Creates a new instance of the Derpibooru API client

  • {object} [options = {}] – client options
  • {string} [options.url = "derpibooru.org"] - Derpibooru API hostname (you can set trixiebooru.org or derpibooru.org)
  • {string} [options.key = null] – your personal API key taken from your account settings
Instance methods
images() -> {Images}

Creates a request handler for /images.json

Creates a request handler for /search.json. This method takes a list of tags

  • {string | string[]} [tags = null] – a tag or a list of tags and returns Search instance

class Images > Request

constructor() -> {Images}

Creates a request handler for /images.json

Instance methods
id(id) -> {Promise<object>}

Returns an image with given ID

class Search > Request

Creates a request handler for /search.json.

Instance methods

Appends a tag or a list of tags to the current search request

  • {string | string[]} list – a tag or a list of tags you want to append

Specifies how many images per page should API return

  • {number} value – an amount of images you want to take. The value must be in range of 1 and 50.

Sets the minimal score of requested images.

  • {number} value – a value of minimal socre

Sets the maximal score of requested images

  • {number} value – a value of maximal socre
random() -> {Promise<object>}

If been called, the API will return random image

class Request

constructor() -> {Request}

Creates a new request handler.

Instance methods
ascending() -> {Request}

Sets images ordering to ascending

descending() -> {Request}

Sets images ordering to descending

page(offset) -> {Request}

Sets the page offset

  • {number} [offset = 1] – The page offset.
exec() -> {Promise<object>}

Executes current request.

then(onFulfilled, onRejected) -> {Promise<object>}

This method takes up to two arguments: callback functions for the success and failure cases of the Promise. See Promise#then() documentation for more info.

catch(onRejected) -> {Error}

This method returns a Promise and deals with rejected cases only. See Promise#catch documentation for more info.

Another API bindings:

Keywords

FAQs

Package last updated on 02 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc