@ifelix18/omdb

4.1.3 • Public • Published

@ifelix18/omdb

OMDb API for userscripts

Version Size Minified Size Downloads JavaScript Style Guide License

Usage

Setup and initialization

Include it in your script in the Metadata Block via @require specifying the version, also specifying the required API to be granted (GM.getValue, GM.setValue, GM.xmlHttpRequest) via @grant, and the domain which can be allowed to be retrieved by GM.xmlHttpRequest via @connect, like this:

// ...
// @require https://cdn.jsdelivr.net/npm/@ifelix18/omdb@4.0.0/lib/index.min.js
// @grant   GM.getValue
// @grant   GM.setValue
// @grant   GM.xmlHttpRequest
// @connect omdbapi.com
// ...

Next, initialize the library:

const omdb = new OMDb({
  api_key: '<your_api_key>', // <string> - OMDb API Key [required]
  api_url: 'https://www.omdbapi.com', // <string> - OMDb API URL
  debug: false, // <boolean> - Debug
  cache: { // Cache options
    active: false, // <boolean> - Cache status
    time_to_live: 3600 // <number> - Time to Live cache, in seconds
  }
})

API requests

Search by ID

Returns infos related to a specific IMDb ID.

Parameter Required Type Description
id Yes string IMDb ID
type No string Type of result (movie, series, or episode)
year No number Year of release
plot No string Type of plot (short or full)
tomatoes No boolean Include Rotten Tomatoes data
omdb.id({
  id: 'tt0088763'
}).then((data) => {
  console.log(data) // <object> - Response from API request
}).catch((error) => console.error(error))

Search by Title

Returns infos related to the first result with a specific title.

Parameter Required Type Description
title Yes string Item title
type No string Type of result (movie, series, or episode)
year No number Year of release
plot No string Type of plot (short or full)
tomatoes No boolean Include Rotten Tomatoes data
omdb.title({
  title: 'Back to the Future'
}).then((data) => {
  console.log(data) // <object> - Response from API request
}).catch((error) => console.error(error))

Search by Search

Returns all results of a specific search.

Parameter Required Type Description
title Yes string Item title
type No string Type of result (movie, series, or episode)
year No number Year of release
page No number Results page (1-100)
omdb.search({
  search: 'Back to the Future'
}).then((data) => {
  console.log(data) // <object> - Response from API request
}).catch((error) => console.error(error))

Credits

This product uses the OMDb API but is not endorsed or certified by OMDb.

Readme

Keywords

none

Package Sidebar

Install

npm i @ifelix18/omdb

Weekly Downloads

5

Version

4.1.3

License

MIT

Unpacked Size

15.7 kB

Total Files

5

Last publish

Collaborators

  • ifelix18