spotify 0.1.2

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

spotify-dart Pub Build Status

A dart library for interfacing with the Spotify API.

Usage

A simple usage example:

import 'package:spotify/spotify_io.dart';

main() async {
  var credentials = new SpotifyApiCredentials(clientId, clientSecret);
  var spotify = new SpotifyApi(credentials);

  var artist = await spotify.artists.get('0OdUWJ0sBjDrqHygGUXeCF');
}

For usage in the browser use

import 'package:spotify/spotify_browser.dart';

Features and bugs

Please file feature requests and bugs at the issue tracker.

Development

Generating JSON Serializers

Run pub run build_runner build to generate JSON serilizers via json_serializable.

Changelog

0.1.2

  • make pub analyzer happy

0.1.1

  • add search endpoint

0.0.9 - 0.1.0

  • support Dart 2 with switch to json_serializable

0.0.8

  • add missing _putImpl implementation to SpotifyMock

0.0.7

  • add user's saved tracks endpoints

0.0.6

  • add pagination support

0.0.5

  • add user and playlist endpoints

0.0.4

  • fix typo in artists endpoint
  • add basic unit tests

0.0.3

  • add support for albums and artists
  • refactor code a little

0.0.1

  • Initial version

example/example.dart

// Copyright (c) 2017, rinukkusu. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:io';
import 'dart:convert';
import '../lib/spotify_io.dart';

main() async {
  var keyJson = await new File('example/.apikeys').readAsString();
  var keyMap = json.decode(keyJson);

  var credentials = new SpotifyApiCredentials(keyMap['id'], keyMap['secret']);
  var spotify = new SpotifyApi(credentials);

  print("Artists:");
  var artists = await spotify.artists.list(['0OdUWJ0sBjDrqHygGUXeCF']);
  artists.forEach((x) => print(x.name));

  print("\nAlbum:");
  var album = await spotify.albums.get('2Hog1V8mdTWKhCYqI5paph');
  print(album.name);

  print("\nAlbum Tracks:");
  var tracks = await spotify.albums.getTracks(album.id).all();
  tracks.forEach((track) {
    print(track.name);
  });

  print("\nFeatured Playlist:");
  var featuredPlaylists = await spotify.playlists.featured.all();
  featuredPlaylists.forEach((playlist) {
    print(playlist.name);
  });

  print("\nSearching for \'Metallica\':");
  var search = await spotify.search
      .get("metallica")
      .first(2)
      .catchError((err) => print((err as SpotifyException).message));
  if (search == null) {
    return;
  }
  search.forEach((pages) {
    pages.items.forEach((item) {
      if (item is PlaylistSimple) {
        print('Playlist: \n'
            'id: ${item.id}\n'
            'name: ${item.name}:\n'
            'collaborative: ${item.collaborative}\n'
            'href: ${item.href}\n'
            'trackslink: ${item.tracksLink.href}\n'
            'owner: ${item.owner}\n'
            'public: ${item.owner}\n'
            'snapshotId: ${item.snapshotId}\n'
            'type: ${item.type}\n'
            'uri: ${item.uri}\n'
            'images: ${item.images.length}\n'
            '-------------------------------');
      }
      if (item is Artist) {
        print('Artist: \n'
            'id: ${item.id}\n'
            'name: ${item.name}\n'
            'href: ${item.href}\n'
            'type: ${item.type}\n'
            'uri: ${item.uri}\n'
            '-------------------------------');
      }
      if (item is TrackSimple) {
        print('Track:\n'
            'id: ${item.id}\n'
            'name: ${item.name}\n'
            'href: ${item.href}\n'
            'type: ${item.type}\n'
            'uri: ${item.uri}\n'
            'isPlayable: ${item.isPlayable}\n'
            'artists: ${item.artists.length}\n'
            'availableMarkets: ${item.availableMarkets.length}\n'
            'discNumber: ${item.discNumber}\n'
            'trackNumber: ${item.trackNumber}\n'
            'explicit: ${item.explicit}\n'
            '-------------------------------');
      }
      if (item is AlbumSimple) {
        print('Album:\n'
            'id: ${item.id}\n'
            'name: ${item.name}\n'
            'href: ${item.href}\n'
            'type: ${item.type}\n'
            'uri: ${item.uri}\n'
            'albumType: ${item.albumType}\n'
            'artists: ${item.artists.length}\n'
            'availableMarkets: ${item.availableMarkets.length}\n'
            'images: ${item.images.length}\n'
            '-------------------------------');
      }
    });
  });
  exit(0);
}

Use this package as a library

1. Depend on it

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


dependencies:
  spotify: ^0.1.2

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:spotify/spotify_browser.dart';
import 'package:spotify/spotify_browser.g.dart';
import 'package:spotify/spotify_io.dart';
import 'package:spotify/spotify_io.g.dart';
  
Version Uploaded Documentation Archive
0.1.2 Nov 21, 2018 Go to the documentation of spotify 0.1.2 Download spotify 0.1.2 archive
0.1.1 Nov 21, 2018 Go to the documentation of spotify 0.1.1 Download spotify 0.1.1 archive
0.1.0 Nov 7, 2018 Go to the documentation of spotify 0.1.0 Download spotify 0.1.0 archive
0.0.7 Feb 10, 2018 Go to the documentation of spotify 0.0.7 Download spotify 0.0.7 archive
0.0.6 Oct 15, 2017 Go to the documentation of spotify 0.0.6 Download spotify 0.0.6 archive
0.0.5 Oct 14, 2017 Go to the documentation of spotify 0.0.5 Download spotify 0.0.5 archive
0.0.4 Oct 12, 2017 Go to the documentation of spotify 0.0.4 Download spotify 0.0.4 archive
0.0.3 Aug 13, 2017 Go to the documentation of spotify 0.0.3 Download spotify 0.0.3 archive
0.0.2 Aug 12, 2017 Go to the documentation of spotify 0.0.2 Download spotify 0.0.2 archive
0.0.1 Aug 12, 2017 Go to the documentation of spotify 0.0.1 Download spotify 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
53
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
76
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: web

Platform components identified in package: html, io.

Health suggestions

Fix lib/src/models/token_request.g.dart. (-1 points)

Analysis of lib/src/models/token_request.g.dart reported 2 hints:

line 13 col 22: The function '_$TokenRequestToJson' isn't used.

line 23 col 22: The function '_$ApiTokenToJson' isn't used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0
json_annotation ^2.0.0 2.0.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
Dev dependencies
build_runner ^1.1.1
json_serializable ^2.0.0
test ^1.5.1