lbry 0.1.6

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new50

LBRYDart

LRBY API binding for the Dart Language

Placeholder for actual information about this binding

Installation

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

dependencies:
    lbry: any

Then, instlling 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/lbry.dart';

And you're done!

Usage

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

import 'package:lbry/lbry.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
  api.call("help");
  
  // calling resolve method with args
  api.call("resolve", params: {"name": "odder otter"});
  
}

Feedback

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

0.1.6

Describes the installation procedure in README.md

0.1.5

Provides a clear and descriptive usage in README.md

0.1.4

Removes verbosity from description

0.1.3

Adds more verbosity to description

0.1.2

Initial Release

example/main.dart

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


void main() async {
  
  /*  This API provides two classes, LbrydApi and LbrycrdApi.
   *  To call either simply import lbry/lbry.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 lbrydApi.call("help");

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

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

  // Now we can try and display it much more nicely
  print(json.convert(response));

  /* 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 https://lbry.io/api 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
  print(response["result"]["about"]);

  // 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 lbrydApi.call("resolve_name",
      params: {
        "name": "doge",
        "force": true,
      });
  
  print(json.convert(metatableDict));

    /* 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 */
  lbrydApi.call("resolve",
      params: {
    "uri": "doge",
    "uris": ["crab", "otter", "turtle"]
  }).then((response) {
    print(json.convert(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 */
  lbrycrdApi.call("help").then((response) {
    print(json.convert(response));
  }).catchError((error) {
    print(error);
  });

}

Use this package as a library

1. Depend on it

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


dependencies:
  lbry: ^0.1.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:lbry/lbry.dart';
  
Version Uploaded Documentation Archive
0.1.6 Nov 12, 2018 Go to the documentation of lbry 0.1.6 Download lbry 0.1.6 archive
0.1.5 Nov 12, 2018 Go to the documentation of lbry 0.1.5 Download lbry 0.1.5 archive
0.1.4 Nov 12, 2018 Go to the documentation of lbry 0.1.4 Download lbry 0.1.4 archive
0.1.3 Nov 12, 2018 Go to the documentation of lbry 0.1.3 Download lbry 0.1.3 archive
0.1.2 Nov 12, 2018 Go to the documentation of lbry 0.1.2 Download lbry 0.1.2 archive
0.0.0 Nov 12, 2018 Go to the documentation of lbry 0.0.0 Download lbry 0.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:lbry/lbry.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.6
path 1.6.2
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6