kkbox_openapi 2.1.0+12

  • 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

http://www.apache.org/licenses/LICENSE-2.0

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.1.0+12 #

  • Updates documentation.

2.1.0+10 #

  • Updates documentation.

2.1.0+6 #

  • A new start.

0.9.8 #

  • Fixes dependency issues.

0.9.7 #

  • Fixes typos.

0.9.6 #

  • Supports Dart 2.

0.9.5 #

  • Bug fixes.

0.9.4 #

  • Bug fixes.

0.9.3 #

  • Updates documentation.

0.9.1 #

  • Initial version.

example/main.dart

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

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

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

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

Use this package as a library

1. Depend on it

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


dependencies:
  kkbox_openapi: ^2.1.0+12

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';
  
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 Nov 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0+1 0.12.0+2
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
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
pedantic ^1.0.0 1.8.0+1
test ^1.0.0
test_coverage ^0.2.0