BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News New Google APIs Client Libraries for Dart

New Google APIs Client Libraries for Dart

This item in japanese

Bookmarks

Dart Engineer Søren Gjesse, has this week announced to the community new packages for accessing Google APIs.

Writing about the new packages on Dart News & Updates, Gjesse says the API generator has been built to create Dart client libraries enabling access to Google services, including YouTube, Analytics, Google+ and Drive from Dart.

The two new packages, googleapis and googleapis_beta, are based on previous work by GDEs Adam Singer and Gerwin Sturm.

Gjesse says: 

The googleapis package contains all the APIs that are available in a stable version. The googleapis_beta package contains the APIs that are currently in beta and only available through a Limited Preview program. We will be updating these packages on a monthly basis to ensure that they provide access to new services as they become available.

Along with the generated APIs, we have published a googleapis_auth package that handles all the different authorization models supported to access the APIs from different environments. Using googleapis_auth makes it easy to use the client libraries in a standalone application, on a Google Compute Engine instance, or in the browser.

The feedback to the official Dart News article was positive, with the community expressing thanks to the team -- although there was also some polite dissent elsewhere. 

Commenting on the announcement in the Dart Misc Google group, user Günter Zöchbauer said:

These packages are great!

Why there is no support for accessing the Datastore using Protobuf in addition to JSON? There is another community package available that seems to do just that but I haven't tried it yet.

Gjesse responded:

Right now these packages are generated from the discovery documents, which all support JSON defined by the JSON schema in these documents. The discovery document for Cloud Datastore v1beta2 as the only one of these APIs indicate support for protobuf response through the following information:

"alt": {
            "default": "proto",
            "description": "Data format for the response.",
            "enum": [
                "json",
                "proto"
            ],
            "enumDescriptions": [
                "Responses with Content-Type of application/json",
                "Responses with Content-Type of application/x-protobuf"
            ],
            "location": "query",
            "type": "string"
        },

We might add support for protobuf bodies, but it raises an issue about the generated API, as it will have to take different request/response objects - the ones generated from the associated protobuf definition file.

However, not everyone in the Dart community was on board with the one package approach.

User Bob Nystrom asked Gjesse "Out of curiosity, what benefits do you find to having them all in one package? I tend to prefer smaller packages I can mix and match".

This view was echoed by user Nathan Weizenbaum who asked "What do you think about providing a bunch of separate, separately-versioned packages as well as one "one-stop shopping" package that just depends on and re-exports all of the separate packages?"

Gjesse responded, saying:

This is an approach that we have also discussed, and it provides a path for us to split out and still keep the bundles, making it easy to get started.

The feature in pub for having private packages was coming from this, as all generated packages could share a common package that was not intended for public consumption (otherwise all these packages would contain copies of the same common code).

This might lead to the exact same version constraint issue if we break that common package.

To get started using the libraries, users should look at the GitHub repository googleapis_examples.

The Dart team invite InfoQ readers to post on the discussion group with any questions or comments on the client libraries. Bugs can be filed on GitHub projects for the generator and the googleapis_auth package.

Rate this Article

Adoption
Style

BT