odesli.js 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,106 +1,333 @@
1
- # odesli.js
2
- Node.js Client to query odesli.co (song.link/album.link) API
3
-
4
- ## v1.0.4
5
-
6
- Initial release
7
-
8
- ## Installation
9
- ```
10
- npm install odesli.js --save
11
- ```
12
-
13
- ## Initilise
14
- ```js
15
- const Odesli = require('odesli.js');
16
- const odesli = new Odesli();
17
- ```
18
-
19
- ## API Key
20
- An API Key is not needed, however, you will be limited to 10 Requests per minute.
21
- Email `developers@song.link` to get an API Key.
22
-
23
- ```js
24
- const odesli = new Odesli({
25
- apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
26
- version: 'vX-beta.X'
27
- });
28
- ```
29
-
30
- *If no version is supplied, it'll default to 'v1-alpha.1'*
31
-
32
- ## Fetch
33
- Use `fetch()` to fetch a song by a streaming service url:
34
-
35
- #### async/await
36
-
37
- ```js
38
- // fetch(url: string, country?: 2-character code)
39
- let song = await odesli.fetch('https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR');
40
- console.log(`${song.title} by ${song.artist[0]}`);
41
-
42
- // output: Bad and Boujee by Migos
43
- ```
44
-
45
- #### or you can use promises.
46
-
47
- ```js
48
- // fetch(url: string, country?: 2-character code)
49
- odesli.fetch('https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR').then(song => {
50
- console.log(`${song.title} by ${song.artist[0]}`);
51
-
52
- // output: Bad and Boujee by Migos
53
- });
54
- ```
55
-
56
- ## Get By Parameters
57
- Use `getByParams()` to fetch a song by a streaming service type, song/album type, and it's unique ID:
58
-
59
- #### async/await
60
-
61
- ```js
62
- // getByParams(platform: string, type: enum<song|album>, id: string, country?: 2-character code)
63
- let song = await odesli.getByParams('spotify', 'song', '4Km5HrUvYTaSUfiSGPJeQR');
64
- console.log(song.artist[0]);
65
-
66
- // output: Migos
67
- ```
68
-
69
- #### or you can use promises.
70
-
71
- ```js
72
- // getByParams(platform: string, type: enum<song|album>, id: string, country?: 2-character code)
73
- odesli.getByParams('spotify', 'song', '4Km5HrUvYTaSUfiSGPJeQR').then(song => {
74
- console.log(song.artist[0]);
75
-
76
- // output: Migos
77
- });
78
- ```
79
-
80
- ## Get By ID
81
- Use `getById()` to fetch a song by it's unique ID:
82
-
83
- #### async/await
84
-
85
- ```js
86
- // // getById(id: string, country?: 2-character code)
87
- let song = await odesli.getByParams('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR');
88
- console.log(song.title);
89
-
90
- // output: Bad and Boujee
91
- ```
92
-
93
- #### or you can use promises.
94
-
95
- ```js
96
- // getByParams(platform: string, type: enum<song|album>, id: string)
97
- odesli.getByParams('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR').then(song => {
98
- console.log(song.title);
99
-
100
- // output: Bad and Boujee
101
- });
102
- ```
103
-
104
- ## Odesli API Docs
105
-
106
- Check the [Odesli's Public API Documentation](https://www.notion.so/Public-API-d8093b1bb8874f8b85527d985c4f9e68) for more info.
1
+ # odesli.js
2
+
3
+ [![npm version](https://badge.fury.io/js/odesli.js.svg)](https://badge.fury.io/js/odesli.js)
4
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
+ [![Node.js CI](https://github.com/MattrAus/odesli.js/workflows/CI/badge.svg)](https://github.com/MattrAus/odesli.js/actions/workflows/ci.yml)
6
+ [![Test Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/MattrAus/odesli.js)
7
+ [![Bundle Size](https://img.shields.io/bundlephobia/min/odesli.js)](https://bundlephobia.com/result?p=odesli.js)
8
+ [![Downloads](https://img.shields.io/npm/dm/odesli.js.svg)](https://www.npmjs.com/package/odesli.js)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
10
+
11
+ A Node.js client for the [Odesli API](https://odesli.co/) (formerly song.link/album.link) that helps you find links to music across multiple streaming platforms.
12
+
13
+ ## 📋 Table of Contents
14
+
15
+ - [odesli.js](#odeslijs)
16
+ - [📋 Table of Contents](#-table-of-contents)
17
+ - [Features](#features)
18
+ - [Installation](#installation)
19
+ - [Quick Start](#quick-start)
20
+ - [API Key](#api-key)
21
+ - [Usage](#usage)
22
+ - [Fetch by URL](#fetch-by-url)
23
+ - [Fetch by Parameters](#fetch-by-parameters)
24
+ - [Fetch by Entity ID](#fetch-by-entity-id)
25
+ - [Country-Specific Results](#country-specific-results)
26
+ - [Error Handling](#error-handling)
27
+ - [Advanced Usage](#advanced-usage)
28
+ - [Batch Processing](#batch-processing)
29
+ - [Working with Different Platforms](#working-with-different-platforms)
30
+ - [Error Recovery](#error-recovery)
31
+ - [Response Format](#response-format)
32
+ - [Supported Platforms](#supported-platforms)
33
+ - [TypeScript Support](#typescript-support)
34
+ - [Examples](#examples)
35
+ - [API Documentation](#api-documentation)
36
+ - [Contributing](#contributing)
37
+ - [License](#license)
38
+ - [Support](#support)
39
+
40
+ ## Features
41
+
42
+ - 🔗 **Cross-platform links**: Get links for music across Spotify, Apple Music, YouTube Music, and more
43
+ - 🎵 **Song & Album support**: Works with both individual tracks and full albums
44
+ - 🌍 **Multi-country support**: Specify country codes for region-specific results
45
+ - 🔑 **API Key support**: Optional API key for higher rate limits
46
+ - 📦 **TypeScript support**: Full TypeScript definitions included
47
+ - ⚡ **Lightweight**: Minimal dependencies, fast performance
48
+ - 🛡️ **Robust error handling**: Comprehensive error messages and validation
49
+ - 🧪 **Fully tested**: 100% test coverage with comprehensive test suite
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ npm install odesli.js
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ```javascript
60
+ const Odesli = require('odesli.js');
61
+
62
+ // Initialize without API key (10 requests/minute limit)
63
+ const odesli = new Odesli();
64
+
65
+ // Or with API key for higher limits
66
+ const odesli = new Odesli({
67
+ apiKey: 'your-api-key-here',
68
+ version: 'v1-alpha.1', // optional, defaults to v1-alpha.1
69
+ });
70
+ ```
71
+
72
+ ## API Key
73
+
74
+ An API key is **optional** but recommended for production use. Without an API key, you're limited to 10 requests per minute.
75
+
76
+ To get an API key, email `developers@song.link`.
77
+
78
+ ## Usage
79
+
80
+ ### Fetch by URL
81
+
82
+ Get links for a song using any streaming service URL:
83
+
84
+ ```javascript
85
+ // Using async/await
86
+ const song = await odesli.fetch(
87
+ 'https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR'
88
+ );
89
+ console.log(`${song.title} by ${song.artist[0]}`);
90
+ // Output: Bad and Boujee by Migos
91
+
92
+ // Using promises
93
+ odesli
94
+ .fetch('https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR')
95
+ .then(song => {
96
+ console.log(`${song.title} by ${song.artist[0]}`);
97
+ });
98
+ ```
99
+
100
+ ### Fetch by Parameters
101
+
102
+ Get links using platform, type, and ID:
103
+
104
+ ```javascript
105
+ // Using async/await
106
+ const song = await odesli.getByParams(
107
+ 'spotify',
108
+ 'song',
109
+ '4Km5HrUvYTaSUfiSGPJeQR'
110
+ );
111
+ console.log(song.artist[0]); // Output: Migos
112
+
113
+ // Using promises
114
+ odesli.getByParams('spotify', 'song', '4Km5HrUvYTaSUfiSGPJeQR').then(song => {
115
+ console.log(song.artist[0]);
116
+ });
117
+ ```
118
+
119
+ ### Fetch by Entity ID
120
+
121
+ Get links using the full entity ID:
122
+
123
+ ```javascript
124
+ // Using async/await
125
+ const song = await odesli.getById('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR');
126
+ console.log(song.title); // Output: Bad and Boujee
127
+
128
+ // Using promises
129
+ odesli.getById('SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR').then(song => {
130
+ console.log(song.title);
131
+ });
132
+ ```
133
+
134
+ ### Country-Specific Results
135
+
136
+ All methods accept an optional country parameter (ISO 3166-1 Alpha-2 code):
137
+
138
+ ```javascript
139
+ // Get results for the United Kingdom
140
+ const song = await odesli.fetch(
141
+ 'https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR',
142
+ 'GB'
143
+ );
144
+
145
+ // Get results for Japan
146
+ const song = await odesli.getByParams(
147
+ 'spotify',
148
+ 'song',
149
+ '4Km5HrUvYTaSUfiSGPJeQR',
150
+ 'JP'
151
+ );
152
+ ```
153
+
154
+ ### Error Handling
155
+
156
+ The library throws descriptive errors for various scenarios:
157
+
158
+ ```javascript
159
+ try {
160
+ const song = await odesli.fetch('invalid-url');
161
+ } catch (error) {
162
+ console.error(error.message);
163
+ // Examples:
164
+ // "No URL was provided to odesli.fetch()"
165
+ // "429: RATE_LIMITED, You are being rate limited, No API Key is 10 Requests / Minute."
166
+ // "API returned an unexpected result."
167
+ }
168
+ ```
169
+
170
+ ### Advanced Usage
171
+
172
+ #### Batch Processing
173
+
174
+ ```javascript
175
+ // Process multiple songs efficiently
176
+ const urls = [
177
+ 'https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR',
178
+ 'https://open.spotify.com/track/0V3wPSX9ygBnCm8psDIegu',
179
+ 'https://open.spotify.com/track/1z6WtY7X4HQJvzxC4UgkS1',
180
+ ];
181
+
182
+ const songs = await Promise.allSettled(urls.map(url => odesli.fetch(url)));
183
+
184
+ songs.forEach((result, index) => {
185
+ if (result.status === 'fulfilled') {
186
+ console.log(`Song ${index + 1}: ${result.value.title}`);
187
+ } else {
188
+ console.log(`Song ${index + 1}: Error - ${result.reason.message}`);
189
+ }
190
+ });
191
+ ```
192
+
193
+ #### Working with Different Platforms
194
+
195
+ ```javascript
196
+ // Get all available platform links
197
+ const song = await odesli.fetch(
198
+ 'https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR'
199
+ );
200
+
201
+ // Extract all platform URLs
202
+ const platformUrls = Object.entries(song.linksByPlatform).map(
203
+ ([platform, data]) => ({
204
+ platform,
205
+ url: data.url,
206
+ mobileUri: data.nativeAppUriMobile,
207
+ desktopUri: data.nativeAppUriDesktop,
208
+ })
209
+ );
210
+
211
+ console.log('Available platforms:', platformUrls);
212
+ ```
213
+
214
+ #### Error Recovery
215
+
216
+ ```javascript
217
+ async function fetchWithRetry(url, maxRetries = 3) {
218
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
219
+ try {
220
+ return await odesli.fetch(url);
221
+ } catch (error) {
222
+ if (attempt === maxRetries) throw error;
223
+
224
+ // Wait before retrying (exponential backoff)
225
+ await new Promise(resolve => setTimeout(resolve, attempt * 1000));
226
+ console.log(`Retry attempt ${attempt} for ${url}`);
227
+ }
228
+ }
229
+ }
230
+
231
+ // Usage
232
+ const song = await fetchWithRetry(
233
+ 'https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR'
234
+ );
235
+ ```
236
+
237
+ ## Response Format
238
+
239
+ All methods return a response object with the following structure:
240
+
241
+ ```javascript
242
+ {
243
+ entityUniqueId: "SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR",
244
+ title: "Bad and Boujee",
245
+ artist: ["Migos"],
246
+ type: "song",
247
+ thumbnail: "https://i.scdn.co/image/...",
248
+ userCountry: "US",
249
+ pageUrl: "https://song.link/i/4Km5HrUvYTaSUfiSGPJeQR",
250
+ linksByPlatform: {
251
+ spotify: {
252
+ entityUniqueId: "SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR",
253
+ url: "https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR",
254
+ nativeAppUriMobile: "spotify://track/4Km5HrUvYTaSUfiSGPJeQR",
255
+ nativeAppUriDesktop: "spotify://track/4Km5HrUvYTaSUfiSGPJeQR"
256
+ },
257
+ appleMusic: {
258
+ // ... similar structure
259
+ }
260
+ // ... other platforms
261
+ },
262
+ entitiesByUniqueId: {
263
+ "SPOTIFY_SONG::4Km5HrUvYTaSUfiSGPJeQR": {
264
+ id: "4Km5HrUvYTaSUfiSGPJeQR",
265
+ type: "song",
266
+ title: "Bad and Boujee",
267
+ artistName: ["Migos"],
268
+ thumbnailUrl: "https://i.scdn.co/image/...",
269
+ apiProvider: "spotify",
270
+ platforms: ["spotify"]
271
+ }
272
+ // ... other entities
273
+ }
274
+ }
275
+ ```
276
+
277
+ ## Supported Platforms
278
+
279
+ - Spotify
280
+ - Apple Music
281
+ - iTunes
282
+ - YouTube Music
283
+ - YouTube
284
+ - Google Play Music
285
+ - Pandora
286
+ - Deezer
287
+ - Tidal
288
+ - Amazon Music
289
+ - SoundCloud
290
+ - Napster
291
+ - Yandex Music
292
+ - Spinrilla
293
+
294
+ ## TypeScript Support
295
+
296
+ This package includes full TypeScript definitions:
297
+
298
+ ```typescript
299
+ import Odesli from 'odesli.js';
300
+
301
+ const odesli = new Odesli({ apiKey: 'your-key' });
302
+ const song = await odesli.fetch('https://open.spotify.com/track/...');
303
+ // song is fully typed with all properties
304
+ ```
305
+
306
+ ## Examples
307
+
308
+ Check out the [examples directory](./examples) for more detailed usage examples:
309
+
310
+ - [Basic Usage](./examples/basic-usage.js) - Simple song fetching
311
+ - [Advanced Usage](./examples/advanced-usage.js) - Complex scenarios and error handling
312
+
313
+ ## API Documentation
314
+
315
+ For more detailed information about the Odesli API, check the [official documentation](https://www.notion.so/d8093b1bb8874f8b85527d985c4f9e68).
316
+
317
+ ## Contributing
318
+
319
+ 1. Fork the repository
320
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
321
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
322
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
323
+ 5. Open a Pull Request
324
+
325
+ ## License
326
+
327
+ This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
328
+
329
+ ## Support
330
+
331
+ - 📧 Email: `developers@song.link` (for API key requests)
332
+ - 🐛 Issues: [GitHub Issues](https://github.com/MattrAus/odesli.js/issues)
333
+ - 📖 Documentation: [Odesli API Docs](https://www.notion.so/d8093b1bb8874f8b85527d985c4f9e68)
@@ -0,0 +1,84 @@
1
+ # Release v1.1.0 - Major Improvements & Professional Setup
2
+
3
+ ## 🎉 What's New
4
+
5
+ This release brings significant improvements to the odesli.js package, transforming it from a basic client into a production-ready, professionally maintained library.
6
+
7
+ ## ✨ Key Features Added
8
+
9
+ ### 🧪 **Comprehensive Testing**
10
+
11
+ - **40 comprehensive tests** with 100% coverage
12
+ - Jest test suite with mocking for reliable testing
13
+ - Edge case handling and error scenario testing
14
+ - Automated test runs in CI/CD pipeline
15
+
16
+ ### 🛠️ **Development Tools**
17
+
18
+ - **ESLint** configuration for code quality
19
+ - **Prettier** for consistent code formatting
20
+ - **TypeScript 5.0** with enhanced type definitions
21
+ - **Security scanning** with Snyk integration
22
+
23
+ ### 🚀 **CI/CD Pipeline**
24
+
25
+ - **GitHub Actions** workflows for automated testing
26
+ - **Automated publishing** on release tags
27
+ - **Code quality checks** (linting, formatting, security)
28
+ - **Multi-platform testing** support
29
+
30
+ ### 📚 **Documentation & Examples**
31
+
32
+ - **Professional README** with badges and comprehensive guides
33
+ - **Example scripts** for basic and advanced usage
34
+ - **TypeScript support** documentation
35
+ - **Error handling** examples and best practices
36
+
37
+ ### 🔧 **Code Improvements**
38
+
39
+ - **Enhanced error handling** with descriptive messages
40
+ - **Simplified async logic** for better performance
41
+ - **Modern ES modules** support
42
+ - **Better TypeScript** type definitions
43
+ - **Professional project structure**
44
+
45
+ ## 🐛 Bug Fixes
46
+
47
+ - Fixed API parameter mismatch (`api` → `apiKey`)
48
+ - Removed unnecessary Promise.all wrappers
49
+ - Improved error handling in request methods
50
+ - Enhanced TypeScript compatibility
51
+
52
+ ## 📦 Installation
53
+
54
+ ```bash
55
+ npm install odesli.js@1.1.0
56
+ ```
57
+
58
+ ## 🚀 Quick Start
59
+
60
+ ```javascript
61
+ const Odesli = require('odesli.js');
62
+
63
+ const odesli = new Odesli();
64
+ const song = await odesli.fetch(
65
+ 'https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR'
66
+ );
67
+ console.log(`${song.title} by ${song.artist[0]}`);
68
+ ```
69
+
70
+ ## 🔗 Links
71
+
72
+ - **NPM Package**: [npmjs.com/package/odesli.js](https://www.npmjs.com/package/odesli.js)
73
+ - **GitHub Repository**: [github.com/MattrAus/odesli.js](https://github.com/MattrAus/odesli.js)
74
+ - **Documentation**: [github.com/MattrAus/odesli.js#readme](https://github.com/MattrAus/odesli.js#readme)
75
+
76
+ ## 🙏 Thanks
77
+
78
+ Thank you to all contributors and users who provided feedback and suggestions for this release!
79
+
80
+ ---
81
+
82
+ **Breaking Changes**: None - This is a backward-compatible release.
83
+
84
+ **Migration**: No migration required. Simply update to version 1.1.0 for all improvements.
package/SECURITY.md ADDED
@@ -0,0 +1,112 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 1.0.x | :white_check_mark: |
8
+
9
+ ## Reporting a Vulnerability
10
+
11
+ We take security vulnerabilities seriously. If you discover a security vulnerability in odesli.js, please follow these steps:
12
+
13
+ ### 1. **DO NOT** create a public GitHub issue
14
+
15
+ Security vulnerabilities should be reported privately to avoid potential exploitation.
16
+
17
+ ### 2. Email the maintainer
18
+
19
+ Send a detailed report to: `me@mtr.gg`
20
+
21
+ ### 3. Include the following information
22
+
23
+ - **Description**: A clear description of the vulnerability
24
+ - **Steps to reproduce**: Detailed steps to reproduce the issue
25
+ - **Impact**: Potential impact of the vulnerability
26
+ - **Suggested fix**: If you have suggestions for fixing the issue
27
+ - **Affected versions**: Which versions are affected
28
+ - **Proof of concept**: If applicable, include a proof of concept
29
+
30
+ ### 4. Response timeline
31
+
32
+ - **Initial response**: Within 48 hours
33
+ - **Status update**: Within 1 week
34
+ - **Fix timeline**: Depends on severity and complexity
35
+
36
+ ## Security Best Practices
37
+
38
+ ### For Users
39
+
40
+ 1. **Keep dependencies updated**: Regularly update to the latest version
41
+ 2. **Use HTTPS**: Always use HTTPS when making API calls
42
+ 3. **Validate inputs**: Validate all user inputs before passing to the library
43
+ 4. **Rate limiting**: Respect API rate limits to avoid being blocked
44
+ 5. **API key security**: Store API keys securely and never commit them to version control
45
+
46
+ ### For Contributors
47
+
48
+ 1. **Code review**: All code changes require security review
49
+ 2. **Dependency scanning**: Run `npm audit` before submitting PRs
50
+ 3. **Input validation**: Always validate and sanitize inputs
51
+ 4. **Error handling**: Don't expose sensitive information in error messages
52
+ 5. **Testing**: Include security-focused tests
53
+
54
+ ## Security Features
55
+
56
+ ### Input Validation
57
+
58
+ - URL validation and sanitization
59
+ - Parameter type checking
60
+ - Malformed response handling
61
+
62
+ ### Error Handling
63
+
64
+ - Safe error messages that don't expose internal details
65
+ - Graceful handling of malformed API responses
66
+ - Rate limiting error handling
67
+
68
+ ### API Security
69
+
70
+ - HTTPS-only communication
71
+ - API key validation
72
+ - Request parameter sanitization
73
+
74
+ ## Dependency Security
75
+
76
+ We regularly audit our dependencies for security vulnerabilities:
77
+
78
+ ```bash
79
+ # Check for vulnerabilities
80
+ npm audit
81
+
82
+ # Fix automatically fixable issues
83
+ npm audit fix
84
+
85
+ # Run security scan with Snyk
86
+ npm run security
87
+ ```
88
+
89
+ ## Disclosure Policy
90
+
91
+ When a security vulnerability is discovered:
92
+
93
+ 1. **Private disclosure**: Issue is reported privately
94
+ 2. **Investigation**: We investigate and validate the issue
95
+ 3. **Fix development**: We develop and test a fix
96
+ 4. **Release**: We release a patched version
97
+ 5. **Public disclosure**: We publicly disclose the vulnerability with details
98
+
99
+ ## Security Updates
100
+
101
+ Security updates are released as patch versions (e.g., 1.0.1, 1.0.2) and should be applied immediately.
102
+
103
+ ## Contact
104
+
105
+ For security-related questions or concerns:
106
+
107
+ - Email: `me@mtr.gg`
108
+ - GitHub: [@MattrAus](https://github.com/MattrAus)
109
+
110
+ ## Acknowledgments
111
+
112
+ We appreciate security researchers and users who responsibly disclose vulnerabilities. Contributors to security improvements will be acknowledged in our release notes.
@@ -0,0 +1,50 @@
1
+ # Examples
2
+
3
+ This directory contains example code showing how to use the `odesli.js` package.
4
+
5
+ ## Basic Usage
6
+
7
+ Run the basic example to see how to fetch song information:
8
+
9
+ ```bash
10
+ node examples/basic-usage.js
11
+ ```
12
+
13
+ This example shows:
14
+
15
+ - Initializing the Odesli client
16
+ - Fetching a song by URL
17
+ - Displaying song information
18
+ - Showing available streaming platforms
19
+
20
+ ## Advanced Usage
21
+
22
+ Run the advanced example to see more complex scenarios:
23
+
24
+ ```bash
25
+ node examples/advanced-usage.js
26
+ ```
27
+
28
+ - By default, this will run without an API key and is limited to 10 requests per minute.
29
+ - If you need to make more than 10 requests per minute, set your API key as an environment variable:
30
+
31
+ ```bash
32
+ export ODESLI_API_KEY=your-api-key-here
33
+ node examples/advanced-usage.js
34
+ ```
35
+
36
+ This example shows:
37
+
38
+ - Using an API key for higher rate limits (optional)
39
+ - Fetching songs for different countries
40
+ - Using different methods (fetch, getByParams, getById)
41
+ - Processing multiple songs in parallel
42
+ - Error handling
43
+
44
+ ## Getting an API Key
45
+
46
+ An API key is **not required** for most users or for running these examples. You only need an API key if you want to make more than 10 requests per minute (for production or high-volume use). To get an API key for higher rate limits, email `developers@song.link`.
47
+
48
+ ## Note
49
+
50
+ The examples use real API calls, so you may be rate-limited if you make more than 10 requests per minute without an API key. The basic example should work with the free tier (10 requests/minute).