Socket
Socket
Sign inDemoInstall

captionbot.js

Package Overview
Dependencies
7
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    captionbot.js

A tiny JavaScript wrapper for Microsoft's Captionbot API.


Version published
Weekly downloads
0
Maintainers
2
Created
Weekly downloads
 

Readme

Source

captionbot.js

A tiny JavaScript wrapper for Microsoft's Captionbot API.

All image recognition is made by the Captionbot; this package only makes requesting the captions a little easier.

Installation

npm install captionbot.js

Usage

const { caption } = require("captionbot.js")
const imageURL = "https://zuwanu.com/wp-content/uploads/2019/09/cars-zuwanu.jpg"

// using then()
caption(imageURL)
    .then(imageCaption => console.log(`Caption: ${imageCaption}`))
    .catch(error => console.log(`Error: ${error.message}`))
    // => Caption: I think it's a car parked in a parking lot.

// using async/await
async function logCaption(imageURL) {
    try {
        const imageCaption = await caption(imageURL)
        console.log(`Caption: ${caption}`)
    } catch (error) {
        console.log(`Error: ${error.message}`)
    }
}
logCaption()
// => Caption: I think it's a car parked in a parking lot.

API

captionbot.caption()

Caption an image given its URL.

Parameters

namedescriptiondefault
imageURLThe URL of the image to caption
options{}
options.errorWhether to throw an error/reject when the provided URL is invalid/missing, but a response is still obtained—this will be irrelevant if there's a network error, for examplefalse

Returns

Promise<String>

captionbot.URLError extends TypeError

Thrown by caption() when the specified URL is invalid, and the error option is true.

new URLError(message)

captionbot.ERROR_CAPTIONS

A list of captions the API returns when the specified URL is invalid.

Type

Array<String>

Example captions

Some examples of captions returned by the API.

"I think it's a dog standing on grass."

"I think it's a car parked in a parking lot."

"I think it's a view of water and a mountain in the background."

Keywords

FAQs

Last updated on 07 Jul 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc