lbry_api 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 45

LBRYDart #

LRBY API binding for the Dart Language #

Placeholder for actual information about this binding

Installation #

To install this package, first include lbry_api in your dependencies in your project's pubspec.yaml:

    lbry_api: any

Then, installing for Native Dart or Flutter, you simply run $ pub get and $ flutter packages get, respectively.

Finally, you import the package in your code:

import 'package:lbry_api/lbry_ap.dart';

And you're done!

Usage #

Simply import package:lbry_api/lbry_api.dart in your dart file, and initialize the API objects as follow:

import 'package:lbry_api/lbry_api.dart';

void main() {
  // optional timeout parameter
  LbrydApi api = LbrydApi(timeout: 5);
  // lbrycrd requires username and password
  LbrycrdApi api = LbrycrdApi("username", "password");
  // calling api method 'help' without args"help");
  // calling resolve method with args"resolve", params: {"name": "odder otter"});

For a more detailed example, see example/main.dart.

Feedback #

If you would like to provide feedback or find a bug, simply open an issue in the github repository.

0.2.1 #

Minor change to

0.2.0 #

Renames package from lbry to lbry_api

0.1.6 #

Describes the installation procedure in

0.1.5 #

Provides a clear and descriptive usage in

0.1.4 #

Removes verbosity from description

0.1.3 #

Adds more verbosity to description

0.1.2 #

Initial Release


import 'dart:convert';
import 'package:lbry_api/lbry_api.dart';

void main() async {
  /*  This API provides two classes, LbrydApi and LbrycrdApi.
   *  To call either simply import lbry/lbry_api.dart, and initialize them.
  // Returns an object of type LbrydApi
  var lbrydApi = LbrydApi();
  /* To use the API, simply provide a name to a method in the API
   * This returns the body of the HTTP Response as a JSON MAP */
  var response = await"help");

  // This prints something along the lines of:
  // id: 1, jsonrpc: 2.0, result: {about: This is the LBRY JSON-RPC API ...

  // Create a JSON Encoder to pretty-print output
  JsonEncoder json = JsonEncoder.withIndent('  ');

  // Now we can try and display it much more nicely

  /* This prints the following:
  > {
  >   "id": 1,
  >   "jsonrpc": "2.0",
  >   "result": {
  >     "about": "This is the LBRY JSON-RPC API",
  >     "command_help": "Pass a `command` parameter to this method to see help for that command (e.g. `help command=resolve_name`)",
  >     "command_list": "Get a full list of commands using the `commands` method",
  >     "more_info": "Visit for more info"
  >   }
  > }

  As we can see, the actual body of the response is given in the `result`
  field, however the everything in the response is returned for
  better context about what specific request did what.

  // To access the Map, use simple Map notation

  // To get the ID of the last request, simply use the LbryApi's getter.
  int id = lbrydApi.requestId;

  /* If we want to use parameters to functions, we can do so as follows: */
  var metatableDict = await"resolve_name",
      params: {
        "name": "doge",
        "force": true,

    /* Since the HTTP Methods are asynchronous, the method
   * returns a dynamic Map representing the JSON dict returned
   * by the API.
   * It is preferable to use the await keyword instead of
   * using the Futures API, however you may do as you please.
   * */

  /* We can also use the Future API */"resolve",
      params: {
    "uri": "doge",
    "uris": ["crab", "otter", "turtle"]
  }).then((response) {

    LbrycrdApi works in the same way as LbrydApi, however
    LbrycrdApi requires your username and password when
    initializing the object to use the API  */
  var lbrycrdApi = LbrycrdApi("username", "password");

  /* Since lbrynet isn't running currently, this will error out.
  *  This is the (uglier) way to asynchronously handle errors
  *  and responses through the Future API */"help").then((response) {
  }).catchError((error) {


Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  lbry_api: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:lbry_api/lbry_api.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 20, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/src/lbrycrd_api.dart. (-1 points)

Analysis of lib/src/lbrycrd_api.dart reported 2 hints:

line 13 col 3: Prefer using /// for doc comments.

line 33 col 3: Prefer using /// for doc comments.

Fix lib/src/lbryd_api.dart. (-1 points)

Analysis of lib/src/lbryd_api.dart reported 2 hints:

line 13 col 3: Prefer using /// for doc comments.

line 22 col 3: Prefer using /// for doc comments.

Fix lib/src/base_api.dart. (-0.50 points)

Analysis of lib/src/base_api.dart reported 1 hint:

line 11 col 3: Prefer using /// for doc comments.

Fix lib/src/exceptions.dart. (-0.50 points)

Analysis of lib/src/exceptions.dart reported 1 hint:

line 7 col 3: Prefer using /// for doc comments.

Maintenance suggestions

Package is getting outdated. (-18.63 points)

The package was last published 61 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6