JSPM

kodi-api

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 208
  • Score
    100M100P100Q82881F
  • License ISC

A complete implementation of Kodi JSON-RPC calls in an easy-to-use Javascript/TypeScript client.

Package Exports

  • kodi-api

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kodi-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Kodi API

A complete implementation of Kodi JSON-RPC calls in an easy-to-use Javascript/TypeScript client.

Installation and usage

Availabel via npm:

npm install --save kodi-api

Then import or require:

import { KodiClient } from 'kodi-api'
const { KodiClient } = require('kodi-api')

async function main () {
  const client = KodiClient.tcp()
  const result = client.JSONRPC.Ping()

  console.log(result) // Expected output: 'pong'
}

main()

Documentation

Documentation for the client is available in ./docs.

How it works

First, the library instantiates a connection over the desired type, such as tcp. Then, it dynamically caches the output from JSONRPC.Introspect. This metadata is then used to make and validate calls to Kodi's JSON-RPC api. No functions are predefined on the client class itself; the class self-mutates to confirm to the metadata from JSONRPC.Introspect.

This makes it possible to use the most up-to-date API documentation available from Kodi's website, or to output the documentation by executing JSONRPC.Introspect yourself.

Future

Eventually, the plan is to generate TypeScript definitions from Kodi for the latest two major releases and include them in ./lib/api/<version>. The generator will also be included in the library so that types can be generated on-the-fly for use in other projects.