kkbox_openapi 2.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

kkbox_openapi #

pub package Actions Status License Apache

The package implements a client to access data provided by KKBOX's Open API, using Dart programming language. You can adopt the package to build Flutter apps, or Dart command line tools.

Installation #

To use the SDK, add kkbox_openapi to your pubspec.yaml file.

Then call pub get or flutter packages get.

Usage #

Where you start is to create an instance of ClientConfiguration, pass your client ID and client secret. All of the classes that do API calls in the package require your client configuration.

var config = ClientConfiguration(
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'CLIENT_SECRET');

Then you can use a method to fetch an valid AccessToken. For example, you can use the client credential flow:

final config = ClientConfiguration(
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'CLIENT_SECRET');
final flow = ClientCredentialsFlowApi(configuration: config);
final result = await flow.run();
final String accessToken = result.accessToken;

Then you will get an AccessToken, you can use it to do other API calls.

Convention #

We creates a class for each restful API endpoint. To access an API endpoint, just create an instance of it, and then call run().

The run method returns a Future object to fetch data asynchronously, and it may raise errors when there are network errors, or errors for parsing API responses. So, you may want to use try-catch while calling these classes along with async-await keywords.

For example:

func() {
  try {
      final api = TrackApi('4kxvr3wPWkaL9_y3o_',
          accessToken: ACCESS_TOKEN, configuration: YOUR_CONFIG);
      final track = await api.run();
  } catch {

Features and bugs #

Please file feature requests and bugs at the issue tracker.

License #

Copyright 2018 KKBOX Technologies Limited

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

2.2.1 #

  • Adopts modern Dart syntax.

2.2.0+4 #

  • Formats code.

2.2.0 #

  • Adds APIs for fetching contents for children.

2.1.0+10 #

  • Updates documentation.

2.1.0+6 #

  • A new start.


import 'package:kkbox_openapi/kkbox_auth.dart';
import 'package:kkbox_openapi/kkbox_openapi.dart';

const clientID = 'c2330e22836b0012d2750f70dd503253';
const clientSecret = '951802f5a6caae8b5905f4b6e76a557f';

void main() async {
  final config =
      ClientConfiguration(clientId: clientID, clientSecret: clientSecret);
  final flow = ClientCredentialsFlowApi(configuration: config);
  final result = await flow.run();
  final accessToken = result.accessToken;

  final api = TrackApi('4kxvr3wPWkaL9_y3o_',
      accessToken: accessToken, configuration: config);
  final track = await api.run();

Use this package as a library

1. Depend on it

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

  kkbox_openapi: ^2.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:kkbox_openapi/kkbox_openapi.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 Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
http ^0.12.0+3 0.12.1
meta ^1.1.8 1.1.8 1.2.0
Transitive dependencies
charcode 1.1.3
collection 1.14.13
http_parser 3.1.4
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
Dev dependencies
pedantic ^1.9.0 1.9.0 1.9.1
test ^1.9.4
test_coverage ^0.4.0