Skip to content

JavaScript bindings for interacting with lbry-daemon and lbrycrd.

Notifications You must be signed in to change notification settings

rynomad/lbry-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LBRY-JS

lbry-js is a small JavaScript client library for interacting with lbry-daemon and lbrycrd via the JSON-RPC api. works in node.js and the browser (via webpack or similar).

Usage

npm install --save lbry

Lbry-js supports both the LBRY daemon and LbryCrd; the api's are similar but slightly different. The daemon accepts arguments as an object, wheras since LbryCrd expects them as an array, you must pass them as an ordered array. see the RPC docs for the parameters for each method on the corresponding clients.

// If in node; you'll need to supply a 'fetch' polyfill
// global.fetch = require('node-fetch')

const {DaemonClient, CrdClient} = require('lbry')

const client = new DaemonClient('http://localhost:5279')

client.wallet_list().then(list => console.log(list))

client.help({command : "blob_announce"}).then(({help}) => {
  console.log(help)

})

client.settings_set({
  download_timeout : 6000,
  share_usage_data : false,
  run_reflector_server : true,
  max_key_fee : {
    currency : 'LBC',
    amount : 5
  }
}).then(settings => {
  console.log(settings)

})

const crd = new CrdClient('http://localhost:9245', 'rpcuser', 'rpcpass')

crd.help(['getinfo']).then(help => {
  console.log(help)
})

crd.signmessage(['lbrycrdaddress','message']).then(signature => {
  console.log(signature)
  // prints signature

})

Building

lbry-js is programatically generated by jrgen. The JSON file consumed by jrgen is currently generated by jrgen.js in the scripts directory, but will eventually be targeted at the artifact being generated for lbry.tech api documentation.

# do this once
$ npm install
$ npm run setup

# set up lbry-daemon virtualenv to get a raw json file from lbry-daemon, ensure a daemon is running then cd back here
# also make sure a LbryCrd daemon is running

(venv)$ npm run build
$ npm test 

Roadmap to 0.1.0

  • basic client.request(<\method_name>, [params]) lbrycrd client
  • programmatic generation of full lbry-daemon client
  • lbry-daemon api tests
  • programmatic generation of lbrycrd client
  • lbrycrd api tests
  • don't use a custom fork of jrgen; use plugin systems
  • npm test script
  • npm build script

About

JavaScript bindings for interacting with lbry-daemon and lbrycrd.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published