4.1.4 • Published 5 months ago

@taki9/omdb v4.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@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.

ParameterRequiredTypeDescription
idYesstringIMDb ID
typeNostringType of result (movie, series, or episode)
yearNonumberYear of release
plotNostringType of plot (short or full)
tomatoesNobooleanInclude 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.

ParameterRequiredTypeDescription
titleYesstringItem title
typeNostringType of result (movie, series, or episode)
yearNonumberYear of release
plotNostringType of plot (short or full)
tomatoesNobooleanInclude 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.

ParameterRequiredTypeDescription
titleYesstringItem title
typeNostringType of result (movie, series, or episode)
yearNonumberYear of release
pageNonumberResults 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.

4.1.4

5 months ago