streamy 0.0.7

Streamy for Dart (experimental) #

Build Status

Streamy is a feature-rich RPC/API framework for applications written using Dart programming language. It relies on Google API Discovery file format for API description. Streamy also provides out-of-the-box JSON-over-REST protocol.

Using Streamy your application can: #

  • Access many Google APIs, such as Google Calendar API
  • Talk to your own APIs built using Google Cloud Endpoints
  • Talk to your own APIs hosted on your own servers and described using Google Discovery format

Features #

  • Rich Entity/Request/Resource objects: mutable, immutable, observable with Map-like interface
  • Fully customizable (in fact, fully replaceable) request handling pipeline
    • Caching
    • Request deduplication
    • API proxy
    • One-shot and keep-alive
    • Tracing
    • Out-of-the-box JSON-over-REST implementation
    • Transactional API
    • Request batching

5-Minute Tutorial #

Let's write a command-line program that shortens URLs using Google URL Shortener API.

What you need for this tutorial #

  • Dart SDK (add Dart's bin folder to your PATH)

Get Full Streamy #

The simplest way is to use git:

> git clone streamy-dart
> cd streamy-dart

Can't I just get it from pub?

Yes, and no. You can and should use pub to import Streamy runtime library necessary to run your app. However, Streamy comes with command-line tools to work with Discovery files and generate API client libraries, so you need to download the full version.

Get a Discovery file #

Find one for the API you want to access. Let's use Google URL shortener as example:

> curl >urlshortener.json

Generate client library #

> dart bin/apigen.dart \
    --discovery_file=urlshortener.json \
    --client_file=urlshortener.dart \

What just happened? #

The apigen.dart program provided by Streamy reads the discovery file (urlshortener.json in the example) and produces a Dart file (urlshortener.dart in the example) that contains an API client library for the API described in the discovery file. You can also give the library your own custom name (urlshortener in the example).

Use it #

Let's create an entry point for our program, called main.dart, which contains the following code:

import 'urlshortener.dart';
import 'package:streamy/impl_server.dart';

main(List<String> args) {
  var requestHandler = new ServerRequestHandler();
  var api = new Urlshortener(requestHandler);
  api.url.insert(new Url()..longUrl = args[0])
    .send().listen((Url response) {
      print('Shortened to ${}');

We are done. Let's run the program:

> dart main.dart

This should print something like:

Shortened to

What just happened? #

import 'urlshortener.dart';

This line imports the API client library that we just generated from the discovery file.

import 'package:streamy/impl_server.dart';

This import provides an implementation of Streamy's RequestHandler interface. This particular implementation works for server-side and command-line apps. If your app runs in the web-browser, use package:streamy/impl_html.dart and HtmlRequestHandler instead.

main() {
  var requestHandler = new ServerRequestHandler();
  var api = new Urlshortener(requestHandler);

The above two lines instantiate a Urlshortener API client backed by ServerRequestHandler.

  api.url.insert(new Url()..longUrl = args[0])

This is an example of how you create an API request. Streamy API generator generates a fully type-annotated root API class (Urlshortener), resources (url), resource methods (insert), entity classes (Url) as well as getters/setters for properties on the entities (longUrl), so you can use auto-completion in your IDE and rely on compiler warnings to tell you about issues in your usage of the API.

    .send().listen((Url response) {
      print('Shortened to ${}');

Finally, we .send() the request to the server and .listen(...) to a Stream of responses.


Use this package as a library

1. Depend on it

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

  streamy: ^0.0.7

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:streamy/streamy.dart';
Version Uploaded Documentation Archive
0.0.7 Nov 19, 2013 Go to the documentation of streamy 0.0.7 Download streamy 0.0.7 archive
0.0.4 Jun 20, 2013 Go to the documentation of streamy 0.0.4 Download streamy 0.0.4 archive
0.0.2 Jun 18, 2013 Go to the documentation of streamy 0.0.2 Download streamy 0.0.2 archive
0.0.1 Jun 18, 2013 Go to the documentation of streamy 0.0.1 Download streamy 0.0.1 archive
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.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=0.8.7