सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक डार्ट लाइब्रेरी जो स्पॉटिफाई वेब एपीआई के साथ आंशिक एकीकरण प्रदान करती है, जिससे फ्लटर एप्लिकेशन स्पॉटिफाई के संगीत और ऑडियो सेवाओं के साथ बातचीत कर सकते हैं। अपूर्ण होने के बावजूद, यह उपयोगकर्ता डेटा, प्लेलिस्ट, ट्रैक्स और खोज सुविधाओं तक पहुँच के लिए मूलभूत कार्यक्षमता प्रदान करती है। संगीत-केंद्रित एप्लिकेशन बनाने वाले विकासकर्ताओं के लिए डिज़ाइन किया गया है, यह एंड्रॉइड, आईओएस, वेब, मैकओएस, विंडोज और लिनक्स जैसे कई प्लेटफॉर्म का समर्थन करता है। लाइब्रेरी सक्रिय रूप से बनाए रखी जा रही है और खुला स्रोत है, जिससे समुदाय के योगदान की अनुमति है। यह फ्लटर प्रोजेक्ट में स्पॉटिफाई के गहन एकीकरण के लिए एक शुरुआती बिंदु के रूप में कार्य करता है।
उपयोग
संगीत एप विकास
उपयोगकर्ता प्लेलिस्ट प्रबंधन
ट्रैक और कलाकार खोजें
Spotify प्रमाणीकरण प्रवाह
ऑडियो कंटेंट खोज
मुख्य विशेषताएँ
आंशिक स्पॉटिफाई वेब एपीआई समर्थन
प्लेटफॉर्म के अनुकूलता
ओपन-सोर्स और समुदाय-चालित
प्रमाणीकरण एकीकरण
ट्रैक्स और प्लेलिस्ट के लिए मूल डेटा प्राप्ति
इनके लिए उपयुक्त
म्यूजिक ऐप्स बनाने वाले Flutter डेवलपर्स
Spotify डेटा एक्सेस की आवश्यकता वाले प्रोजेक्ट
क्रॉस-प्लेटफ़ॉर्म ऑडियो एप्लिकेशन
शुरुआती लोग स्पॉटिफाई API का अन्वेषण कर रहे हैं
विचार योग्य बातें
अपूर्ण फीचर सेट
अनुपस्थित एंडपॉइंट्स का हस्तचालित संभाल आवश्यक है
सीमित दस्तावेज़
बाह्य API परिवर्तनों पर निर्भर
उपयोग के लिए उत्पादन बिना अतिरिक्त प्रमाणीकरण के उपयुक्त नहीं है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
spotify-dart
A Dart library for interfacing with the Spotify API.
Note: Related Artists, Audio Features, Audio Analysis, Featured Playlists, Category Playlists and Recommendation endpoints are deprecated by Spotify but still available in this library.
Quick Start
Simple Example (Client Credentials)
import'package:spotify/spotify.dart';
voidmain() async {
final credentials = SpotifyApiCredentials(clientId, clientSecret);
final spotify = SpotifyApi(credentials);
// Get artist infofinal artist = await spotify.artists.get('0OdUWJ0sBjDrqHygGUXeCF');
print(artist.name); // 'Band of Horses'// Search for tracksvar search = await spotify.search.get('metallica').first(2);
print(search.first.items); // List of albums, artists, tracks, etc.
}
Working with Pagination
Many endpoints return paginated results:
// Get all tracks from an albumvar tracks = await spotify.albums.getTracks(albumId).all();
// Get first N itemsvar featured = await spotify.playlists.featured.first(5);
// Stream through pagesawaitfor (var page in spotify.playlists.getUsersPlaylists(userId).stream()) {
print(page.items);
}
Authorization
This library supports multiple authorization flows:
Client Credentials Flow - For accessing public data (artists, albums, tracks, etc.)
Authorization Code Grant - For accessing user data and controlling playback
PKCE Support - Enhanced security for public clients
For detailed information on authorization flows, OAuth scopes, and advanced usage, see the wiki.
PKCE (Public Client) Authentication
For mobile apps and single-page applications that cannot securely store client secrets, use PKCE:
// Generate a secure code verifierfinal verifier = SpotifyApi.generateCodeVerifier();
// Create PKCE credentials (no client secret needed!)final credentials = SpotifyApiCredentials.pkce(
'your-client-id',
codeVerifier: verifier,
);
// Complete OAuth flowfinal grant = SpotifyApi.authorizationCodeGrant(credentials);
final authUri = grant.getAuthorizationUrl(redirectUri, scopes: scopes);
// ... redirect user, get authorization codefinal client = await grant.handleAuthorizationResponse(params);
final spotify = SpotifyApi.fromClient(client);
// Save credentials for later (including codeVerifier!)final creds = await spotify.getCredentials();
// Store creds.codeVerifier along with other credential fields// Restore laterfinal spotify = awaitSpotifyApi.asyncFromCredentials(restoredCreds);
See example/example_pkce.dart for a complete working example.
Features and bugs
Please file feature requests and bugs at the issue tracker.
Contributing
Contributions are welcome! Here's how to work on this project:
Run dart run build_runner build to generate serializers
Run dart run build_runner watch to continuously rebuild when files change
Code Quality
Before committing, ensure your code passes:
Formatting: dart format .
Analysis: dart analyze
Running Tests
Run the test suite:
dart test
Running Examples
To run the basic example:
dart run example/example.dart
You'll need to modify the file to include your Spotify client ID and secret.
For the authenticated example (accessing user data, playback control) run:
dart run example/example_auth.dart
This example will prompt you for a redirect URL and guide you through the OAuth flow to access features like currently playing tracks and available devices.