soundcloud-api-ts 1.2.0 → 1.4.0

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/dist/index.d.ts CHANGED
@@ -1,138 +1,396 @@
1
1
  import { SoundCloudTrack, SoundCloudPlaylist, SoundCloudToken, SoundCloudPaginatedResponse, SoundCloudMe, SoundCloudActivitiesResponse, SoundCloudUser, SoundCloudWebProfile, SoundCloudStreams, SoundCloudComment } from './types/index.js';
2
- export { SoundCloudActivity, SoundCloudCommentUser, SoundCloudQuota, SoundCloudSubscription, SoundCloudSubscriptionProduct } from './types/index.js';
2
+ export { SoundCloudActivity, SoundCloudCommentUser, SoundCloudError, SoundCloudQuota, SoundCloudSubscription, SoundCloudSubscriptionProduct } from './types/index.js';
3
3
 
4
+ /**
5
+ * Options for making a request to the SoundCloud API via {@link scFetch}.
6
+ */
4
7
  interface RequestOptions {
8
+ /** API path relative to `https://api.soundcloud.com` (e.g. "/tracks/123") */
5
9
  path: string;
10
+ /** HTTP method */
6
11
  method: "GET" | "POST" | "PUT" | "DELETE";
12
+ /** OAuth access token to include in the Authorization header */
7
13
  token?: string;
14
+ /** Request body — automatically serialized based on type */
8
15
  body?: Record<string, unknown> | FormData | URLSearchParams;
16
+ /** Override the Content-Type header (defaults to "application/json" for object bodies) */
9
17
  contentType?: string;
10
18
  }
19
+ /**
20
+ * Configuration for automatic retry with exponential backoff on transient errors.
21
+ */
22
+ interface RetryConfig {
23
+ /** Maximum number of retries on 429/5xx responses (default: 3) */
24
+ maxRetries: number;
25
+ /** Base delay in milliseconds for exponential backoff (default: 1000) */
26
+ retryBaseDelay: number;
27
+ /** Optional callback for debug logging of retry attempts */
28
+ onDebug?: (message: string) => void;
29
+ }
30
+ /**
31
+ * Context for automatic token refresh when a request returns 401 Unauthorized.
32
+ * Used internally by {@link SoundCloudClient} to transparently refresh expired tokens.
33
+ */
11
34
  interface AutoRefreshContext {
35
+ /** Returns the current stored access token */
12
36
  getToken: () => string | undefined;
37
+ /** Called to obtain fresh tokens; if absent, 401 errors are thrown directly */
13
38
  onTokenRefresh?: () => Promise<{
14
39
  access_token: string;
15
40
  refresh_token?: string;
16
41
  }>;
42
+ /** Callback to store the new tokens after a successful refresh */
17
43
  setToken: (accessToken: string, refreshToken?: string) => void;
44
+ /** Retry configuration for this context */
45
+ retry?: RetryConfig;
18
46
  }
19
47
  /**
20
- * Make a request to the SoundCloud API using native fetch.
21
- * Returns parsed JSON, or for 302 redirects returns the Location header.
48
+ * Make a request to the SoundCloud API using native `fetch`.
49
+ *
50
+ * Handles JSON serialization, OAuth headers, automatic retries on 429/5xx,
51
+ * and optional automatic token refresh on 401. For 302 redirects, returns
52
+ * the `Location` header value. For 204 responses, returns `undefined`.
53
+ *
54
+ * @param options - Request configuration (path, method, token, body)
55
+ * @param refreshCtx - Optional auto-refresh context for transparent token renewal
56
+ * @returns Parsed JSON response, redirect URL, or undefined for empty responses
57
+ * @throws {SoundCloudError} When the API returns a non-retryable error status
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { scFetch } from 'tsd-soundcloud';
62
+ *
63
+ * const track = await scFetch<SoundCloudTrack>({
64
+ * path: '/tracks/123456',
65
+ * method: 'GET',
66
+ * token: 'your-access-token',
67
+ * });
68
+ * ```
69
+ *
70
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api
22
71
  */
23
72
  declare function scFetch<T>(options: RequestOptions, refreshCtx?: AutoRefreshContext): Promise<T>;
24
73
  /**
25
- * Fetch an absolute URL (e.g. next_href from paginated responses).
26
- * Adds OAuth token if provided.
74
+ * Fetch an absolute URL (e.g. `next_href` from paginated responses).
75
+ *
76
+ * Used internally for pagination — follows the same retry logic as {@link scFetch}.
77
+ *
78
+ * @param url - Absolute URL to fetch (typically a `next_href` value)
79
+ * @param token - OAuth access token to include in the Authorization header
80
+ * @param retryConfig - Optional retry configuration override
81
+ * @returns Parsed JSON response
82
+ * @throws {SoundCloudError} When the API returns a non-retryable error status
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { scFetchUrl } from 'tsd-soundcloud';
87
+ *
88
+ * const nextPage = await scFetchUrl<SoundCloudPaginatedResponse<SoundCloudTrack>>(
89
+ * response.next_href,
90
+ * 'your-access-token',
91
+ * );
92
+ * ```
27
93
  */
28
- declare function scFetchUrl<T>(url: string, token?: string): Promise<T>;
94
+ declare function scFetchUrl<T>(url: string, token?: string, retryConfig?: RetryConfig): Promise<T>;
29
95
 
96
+ /**
97
+ * Parameters for updating a track's metadata via {@link updateTrack}.
98
+ */
30
99
  interface UpdateTrackParams {
100
+ /** New track title */
31
101
  title?: string;
102
+ /** New track description */
32
103
  description?: string;
104
+ /** Music genre (e.g. "Electronic", "Hip-hop & Rap") */
33
105
  genre?: string;
106
+ /** Space-separated tags (tags with spaces should be wrapped in quotes) */
34
107
  tag_list?: string;
108
+ /** Visibility: "public" or "private" */
35
109
  sharing?: "public" | "private";
110
+ /** Whether the track is downloadable */
36
111
  downloadable?: boolean;
112
+ /** External purchase URL */
37
113
  purchase_url?: string;
114
+ /** Label for the purchase/buy button */
38
115
  purchase_title?: string;
116
+ /** Release identifier string */
39
117
  release?: string;
118
+ /** Day of the release date (1-31) */
40
119
  release_day?: number;
120
+ /** Month of the release date (1-12) */
41
121
  release_month?: number;
122
+ /** Year of the release date */
42
123
  release_year?: number;
124
+ /** Record label name */
43
125
  label_name?: string;
126
+ /** Creative Commons license type (e.g. "all-rights-reserved", "cc-by") */
44
127
  license?: string;
128
+ /** International Standard Recording Code */
45
129
  isrc?: string;
130
+ /** Beats per minute */
46
131
  bpm?: number;
132
+ /** Musical key signature (e.g. "C major") */
47
133
  key_signature?: string;
48
134
  }
49
- /** PUT /tracks/:id — updates a track's metadata */
135
+ /**
136
+ * Update a track's metadata.
137
+ *
138
+ * @param token - OAuth access token
139
+ * @param trackId - The track's numeric ID or URN
140
+ * @param params - Fields to update
141
+ * @returns The updated track object
142
+ * @throws {SoundCloudError} When the API returns an error
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * import { updateTrack } from 'tsd-soundcloud';
147
+ *
148
+ * const updated = await updateTrack(token, 123456, {
149
+ * title: 'New Title',
150
+ * genre: 'Electronic',
151
+ * });
152
+ * console.log(updated.title);
153
+ * ```
154
+ *
155
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/put_tracks__track_id_
156
+ */
50
157
  declare const updateTrack: (token: string, trackId: string | number, params: UpdateTrackParams) => Promise<SoundCloudTrack>;
51
158
 
159
+ /**
160
+ * Parameters for creating a new playlist via {@link createPlaylist}.
161
+ */
52
162
  interface CreatePlaylistParams {
163
+ /** Playlist title (required) */
53
164
  title: string;
165
+ /** Playlist description */
54
166
  description?: string;
167
+ /** Visibility: "public" or "private" */
55
168
  sharing?: "public" | "private";
169
+ /** Tracks to include, specified by URN (e.g. `[{ urn: "soundcloud:tracks:123" }]`) */
56
170
  tracks?: {
57
171
  urn: string;
58
172
  }[];
173
+ /** European Article Number (barcode) for the release */
59
174
  ean?: string;
175
+ /** Music genre */
60
176
  genre?: string;
177
+ /** Record label name */
61
178
  label_name?: string;
179
+ /** Creative Commons license type */
62
180
  license?: string;
181
+ /** Custom permalink slug */
63
182
  permalink?: string;
183
+ /** Label for the purchase/buy button */
64
184
  purchase_title?: string;
185
+ /** External purchase URL */
65
186
  purchase_url?: string;
187
+ /** Release identifier string */
66
188
  release?: string;
189
+ /** Release date in ISO 8601 format */
67
190
  release_date?: string;
191
+ /** Set type: "album" or "playlist" */
68
192
  set_type?: "album" | "playlist";
193
+ /** Space-separated tags */
69
194
  tag_list?: string;
70
195
  }
71
- /** POST /playlists — creates a playlist */
196
+ /**
197
+ * Create a new playlist.
198
+ *
199
+ * @param token - OAuth access token
200
+ * @param params - Playlist creation parameters (title is required)
201
+ * @returns The created playlist object
202
+ * @throws {SoundCloudError} When the API returns an error
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * import { createPlaylist } from 'tsd-soundcloud';
207
+ *
208
+ * const playlist = await createPlaylist(token, {
209
+ * title: 'My Favorites',
210
+ * sharing: 'public',
211
+ * tracks: [{ urn: 'soundcloud:tracks:123' }],
212
+ * });
213
+ * console.log(playlist.id, playlist.title);
214
+ * ```
215
+ *
216
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/post_playlists
217
+ */
72
218
  declare const createPlaylist: (token: string, params: CreatePlaylistParams) => Promise<SoundCloudPlaylist>;
73
219
 
220
+ /**
221
+ * Parameters for updating a playlist via {@link updatePlaylist}.
222
+ */
74
223
  interface UpdatePlaylistParams {
224
+ /** New playlist title */
75
225
  title?: string;
226
+ /** New playlist description */
76
227
  description?: string;
228
+ /** Visibility: "public" or "private" */
77
229
  sharing?: "public" | "private";
230
+ /** Replace the playlist's tracks (specified by URN) */
78
231
  tracks?: {
79
232
  urn: string;
80
233
  }[];
234
+ /** European Article Number (barcode) */
81
235
  ean?: string;
236
+ /** Music genre */
82
237
  genre?: string;
238
+ /** Record label name */
83
239
  label_name?: string;
240
+ /** Creative Commons license type */
84
241
  license?: string;
242
+ /** Custom permalink slug */
85
243
  permalink?: string;
244
+ /** Label for the purchase/buy button */
86
245
  purchase_title?: string;
246
+ /** External purchase URL */
87
247
  purchase_url?: string;
248
+ /** Release identifier string */
88
249
  release?: string;
250
+ /** Release date in ISO 8601 format */
89
251
  release_date?: string;
252
+ /** Set type: "album" or "playlist" */
90
253
  set_type?: "album" | "playlist";
254
+ /** Space-separated tags */
91
255
  tag_list?: string;
92
256
  }
93
- /** PUT /playlists/:id — updates a playlist */
257
+ /**
258
+ * Update a playlist's metadata or track list.
259
+ *
260
+ * @param token - OAuth access token
261
+ * @param playlistId - The playlist's numeric ID or URN
262
+ * @param params - Fields to update
263
+ * @returns The updated playlist object
264
+ * @throws {SoundCloudError} When the API returns an error
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * import { updatePlaylist } from 'tsd-soundcloud';
269
+ *
270
+ * const updated = await updatePlaylist(token, 123456, {
271
+ * title: 'Updated Title',
272
+ * tracks: [{ urn: 'soundcloud:tracks:111' }, { urn: 'soundcloud:tracks:222' }],
273
+ * });
274
+ * ```
275
+ *
276
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/put_playlists__playlist_id_
277
+ */
94
278
  declare const updatePlaylist: (token: string, playlistId: string | number, params: UpdatePlaylistParams) => Promise<SoundCloudPlaylist>;
95
279
 
280
+ /**
281
+ * Configuration options for creating a {@link SoundCloudClient} instance.
282
+ */
96
283
  interface SoundCloudClientConfig {
284
+ /** Your SoundCloud application's OAuth client ID */
97
285
  clientId: string;
286
+ /** Your SoundCloud application's OAuth client secret */
98
287
  clientSecret: string;
288
+ /** OAuth redirect URI registered with your SoundCloud application (required for user auth flows) */
99
289
  redirectUri?: string;
100
- /** Called automatically when a request returns 401. Return new tokens to retry. */
290
+ /**
291
+ * Called automatically when a request returns 401 Unauthorized.
292
+ * Return new tokens to transparently retry the failed request.
293
+ */
101
294
  onTokenRefresh?: (client: SoundCloudClient) => Promise<SoundCloudToken>;
295
+ /** Maximum number of retries on 429 (rate limit) and 5xx (server error) responses (default: 3) */
296
+ maxRetries?: number;
297
+ /** Base delay in milliseconds for exponential backoff between retries (default: 1000) */
298
+ retryBaseDelay?: number;
299
+ /** Optional debug logger callback for retry attempts and other internal events */
300
+ onDebug?: (message: string) => void;
102
301
  }
103
- /** Optional token override, passed as the last parameter to client methods. */
302
+ /**
303
+ * Optional token override that can be passed as the last parameter to client methods.
304
+ * When provided, the explicit token is used instead of the client's stored token.
305
+ */
104
306
  interface TokenOption {
307
+ /** OAuth access token to use for this specific request */
105
308
  token?: string;
106
309
  }
107
310
  /** Resolve a token: use explicit override, fall back to stored, or throw. */
108
311
  type TokenGetter = () => string | undefined;
312
+ /**
313
+ * High-level SoundCloud API client with namespaced methods for all API areas.
314
+ *
315
+ * Provides automatic token management, retry with exponential backoff,
316
+ * optional automatic token refresh on 401, and built-in pagination helpers.
317
+ *
318
+ * @example
319
+ * ```ts
320
+ * import { SoundCloudClient } from 'tsd-soundcloud';
321
+ *
322
+ * const sc = new SoundCloudClient({
323
+ * clientId: 'YOUR_CLIENT_ID',
324
+ * clientSecret: 'YOUR_CLIENT_SECRET',
325
+ * redirectUri: 'https://example.com/callback',
326
+ * });
327
+ *
328
+ * // Authenticate
329
+ * const token = await sc.auth.getClientToken();
330
+ * sc.setToken(token.access_token);
331
+ *
332
+ * // Use the API
333
+ * const track = await sc.tracks.getTrack(123456);
334
+ * console.log(track.title);
335
+ *
336
+ * // Search with pagination
337
+ * for await (const track of sc.paginateItems(() => sc.search.tracks('lofi'))) {
338
+ * console.log(track.title);
339
+ * }
340
+ * ```
341
+ *
342
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api
343
+ */
109
344
  declare class SoundCloudClient {
110
345
  private config;
111
346
  private _accessToken?;
112
347
  private _refreshToken?;
348
+ /** Authentication methods (OAuth token grants, sign out) */
113
349
  auth: SoundCloudClient.Auth;
350
+ /** Authenticated user endpoints (/me) */
114
351
  me: SoundCloudClient.Me;
352
+ /** User profile endpoints (/users) */
115
353
  users: SoundCloudClient.Users;
354
+ /** Track endpoints (/tracks) */
116
355
  tracks: SoundCloudClient.Tracks;
356
+ /** Playlist endpoints (/playlists) */
117
357
  playlists: SoundCloudClient.Playlists;
358
+ /** Search endpoints */
118
359
  search: SoundCloudClient.Search;
360
+ /** URL resolution endpoint (/resolve) */
119
361
  resolve: SoundCloudClient.Resolve;
362
+ /** Like/unlike actions (/likes) */
120
363
  likes: SoundCloudClient.Likes;
364
+ /** Repost/unrepost actions (/reposts) */
121
365
  reposts: SoundCloudClient.Reposts;
366
+ /**
367
+ * Creates a new SoundCloudClient instance.
368
+ *
369
+ * @param config - Client configuration including OAuth credentials and optional settings
370
+ */
122
371
  constructor(config: SoundCloudClientConfig);
123
- /** Store an access token (and optionally refresh token) on this client instance. */
372
+ /**
373
+ * Store an access token (and optionally refresh token) on this client instance.
374
+ *
375
+ * @param accessToken - The OAuth access token to store
376
+ * @param refreshToken - Optional refresh token for automatic token renewal
377
+ */
124
378
  setToken(accessToken: string, refreshToken?: string): void;
125
- /** Clear stored tokens. */
379
+ /** Clear all stored tokens from this client instance. */
126
380
  clearToken(): void;
127
- /** Get the currently stored access token, if any. */
381
+ /** Get the currently stored access token, or `undefined` if none is set. */
128
382
  get accessToken(): string | undefined;
129
- /** Get the currently stored refresh token, if any. */
383
+ /** Get the currently stored refresh token, or `undefined` if none is set. */
130
384
  get refreshToken(): string | undefined;
131
385
  /**
132
386
  * Async generator that follows `next_href` automatically, yielding each page's `collection`.
133
387
  *
388
+ * @param firstPage - Function that fetches the first page
389
+ * @returns An async generator yielding arrays of items (one per page)
390
+ *
391
+ * @example
134
392
  * ```ts
135
- * for await (const page of sc.paginate(() => sc.search.tracks("lofi"))) {
393
+ * for await (const page of sc.paginate(() => sc.search.tracks('lofi'))) {
136
394
  * console.log(page); // SoundCloudTrack[]
137
395
  * }
138
396
  * ```
@@ -141,9 +399,13 @@ declare class SoundCloudClient {
141
399
  /**
142
400
  * Async generator that yields individual items across all pages.
143
401
  *
402
+ * @param firstPage - Function that fetches the first page
403
+ * @returns An async generator yielding individual items
404
+ *
405
+ * @example
144
406
  * ```ts
145
- * for await (const track of sc.paginateItems(() => sc.search.tracks("lofi"))) {
146
- * console.log(track); // single SoundCloudTrack
407
+ * for await (const track of sc.paginateItems(() => sc.search.tracks('lofi'))) {
408
+ * console.log(track.title); // single SoundCloudTrack
147
409
  * }
148
410
  * ```
149
411
  */
@@ -151,8 +413,15 @@ declare class SoundCloudClient {
151
413
  /**
152
414
  * Collects all pages into a single flat array.
153
415
  *
416
+ * @param firstPage - Function that fetches the first page
417
+ * @param options - Optional configuration
418
+ * @param options.maxItems - Maximum number of items to collect
419
+ * @returns A promise resolving to a flat array of all items
420
+ *
421
+ * @example
154
422
  * ```ts
155
- * const allTracks = await sc.fetchAll(() => sc.search.tracks("lofi"), { maxItems: 100 });
423
+ * const allTracks = await sc.fetchAll(() => sc.search.tracks('lofi'), { maxItems: 100 });
424
+ * console.log(allTracks.length);
156
425
  * ```
157
426
  */
158
427
  fetchAll<T>(firstPage: () => Promise<SoundCloudPaginatedResponse<T>>, options?: {
@@ -160,200 +429,1038 @@ declare class SoundCloudClient {
160
429
  }): Promise<T[]>;
161
430
  }
162
431
  declare namespace SoundCloudClient {
432
+ /**
433
+ * Authentication namespace — OAuth token grants and session management.
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * const token = await sc.auth.getClientToken();
438
+ * sc.setToken(token.access_token);
439
+ * ```
440
+ */
163
441
  class Auth {
164
442
  private config;
165
443
  constructor(config: SoundCloudClientConfig);
166
- /** Build the authorization URL to redirect users to SoundCloud's login. */
444
+ /**
445
+ * Build the authorization URL to redirect users to SoundCloud's OAuth login page.
446
+ *
447
+ * @param options - Optional parameters for the authorization request
448
+ * @param options.state - Opaque state value for CSRF protection
449
+ * @param options.codeChallenge - PKCE S256 code challenge for enhanced security
450
+ * @returns The full authorization URL to redirect the user to
451
+ * @throws {Error} If `redirectUri` was not provided in the client config
452
+ *
453
+ * @example
454
+ * ```ts
455
+ * const url = sc.auth.getAuthorizationUrl({ state: 'random-state' });
456
+ * // Redirect user to `url`
457
+ * ```
458
+ *
459
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2
460
+ */
167
461
  getAuthorizationUrl(options?: {
168
462
  state?: string;
169
463
  codeChallenge?: string;
170
464
  }): string;
171
- /** POST /oauth2/token — client_credentials grant */
465
+ /**
466
+ * Exchange client credentials for an access token (machine-to-machine auth).
467
+ *
468
+ * @returns The OAuth token response
469
+ * @throws {SoundCloudError} When authentication fails
470
+ *
471
+ * @example
472
+ * ```ts
473
+ * const token = await sc.auth.getClientToken();
474
+ * sc.setToken(token.access_token);
475
+ * ```
476
+ *
477
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token
478
+ */
172
479
  getClientToken(): Promise<SoundCloudToken>;
173
- /** POST /oauth2/token — authorization_code grant */
480
+ /**
481
+ * Exchange an authorization code for user tokens (authorization_code grant).
482
+ *
483
+ * @param code - The authorization code received from the OAuth callback
484
+ * @param codeVerifier - PKCE code verifier if a code challenge was used
485
+ * @returns The OAuth token response including access and refresh tokens
486
+ * @throws {SoundCloudError} When the code is invalid or expired
487
+ *
488
+ * @example
489
+ * ```ts
490
+ * const token = await sc.auth.getUserToken(code, codeVerifier);
491
+ * sc.setToken(token.access_token, token.refresh_token);
492
+ * ```
493
+ *
494
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token
495
+ */
174
496
  getUserToken(code: string, codeVerifier?: string): Promise<SoundCloudToken>;
175
- /** POST /oauth2/token — refresh_token grant */
497
+ /**
498
+ * Refresh an expired access token using a refresh token.
499
+ *
500
+ * @param refreshToken - The refresh token from a previous token response
501
+ * @returns A new OAuth token response with fresh access and refresh tokens
502
+ * @throws {SoundCloudError} When the refresh token is invalid or expired
503
+ *
504
+ * @example
505
+ * ```ts
506
+ * const newToken = await sc.auth.refreshUserToken(sc.refreshToken!);
507
+ * sc.setToken(newToken.access_token, newToken.refresh_token);
508
+ * ```
509
+ *
510
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token
511
+ */
176
512
  refreshUserToken(refreshToken: string): Promise<SoundCloudToken>;
177
513
  /**
178
- * POST /sign-out invalidates session.
514
+ * Invalidate the session associated with an access token.
179
515
  *
180
516
  * **Note:** This hits `https://secure.soundcloud.com`, NOT the regular
181
517
  * `api.soundcloud.com` host used by all other endpoints.
518
+ *
519
+ * @param accessToken - The access token to invalidate
520
+ * @throws {Error} When the sign-out request fails
521
+ *
522
+ * @example
523
+ * ```ts
524
+ * await sc.auth.signOut(sc.accessToken!);
525
+ * sc.clearToken();
526
+ * ```
182
527
  */
183
528
  signOut(accessToken: string): Promise<void>;
184
529
  }
530
+ /**
531
+ * Authenticated user namespace — endpoints for the currently logged-in user (/me).
532
+ *
533
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me
534
+ */
185
535
  class Me {
186
536
  private getToken;
187
537
  private refreshCtx?;
188
538
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
189
539
  private fetch;
190
- /** GET /me */
540
+ /**
541
+ * Get the authenticated user's profile.
542
+ *
543
+ * @param options - Optional token override
544
+ * @returns The authenticated user's full profile
545
+ * @throws {SoundCloudError} When the API returns an error
546
+ *
547
+ * @example
548
+ * ```ts
549
+ * const me = await sc.me.getMe();
550
+ * console.log(me.username, me.followers_count);
551
+ * ```
552
+ *
553
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me
554
+ */
191
555
  getMe(options?: TokenOption): Promise<SoundCloudMe>;
192
- /** GET /me/activities */
556
+ /**
557
+ * Get the authenticated user's activity feed.
558
+ *
559
+ * @param limit - Maximum number of activities per page
560
+ * @param options - Optional token override
561
+ * @returns Paginated activities response with `future_href` for polling
562
+ * @throws {SoundCloudError} When the API returns an error
563
+ *
564
+ * @example
565
+ * ```ts
566
+ * const activities = await sc.me.getActivities(25);
567
+ * activities.collection.forEach(a => console.log(a.type, a.created_at));
568
+ * ```
569
+ *
570
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities
571
+ */
193
572
  getActivities(limit?: number, options?: TokenOption): Promise<SoundCloudActivitiesResponse>;
194
- /** GET /me/activities/all/own */
573
+ /**
574
+ * Get the authenticated user's own activities (uploads, reposts).
575
+ *
576
+ * @param limit - Maximum number of activities per page
577
+ * @param options - Optional token override
578
+ * @returns Paginated activities response
579
+ * @throws {SoundCloudError} When the API returns an error
580
+ *
581
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_all_own
582
+ */
195
583
  getActivitiesOwn(limit?: number, options?: TokenOption): Promise<SoundCloudActivitiesResponse>;
196
- /** GET /me/activities/tracks */
584
+ /**
585
+ * Get track-related activities in the authenticated user's feed.
586
+ *
587
+ * @param limit - Maximum number of activities per page
588
+ * @param options - Optional token override
589
+ * @returns Paginated activities response filtered to track activities
590
+ * @throws {SoundCloudError} When the API returns an error
591
+ *
592
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_tracks
593
+ */
197
594
  getActivitiesTracks(limit?: number, options?: TokenOption): Promise<SoundCloudActivitiesResponse>;
198
- /** GET /me/likes/tracks */
595
+ /**
596
+ * Get tracks liked by the authenticated user.
597
+ *
598
+ * @param limit - Maximum number of tracks per page
599
+ * @param options - Optional token override
600
+ * @returns Paginated list of liked tracks
601
+ * @throws {SoundCloudError} When the API returns an error
602
+ *
603
+ * @example
604
+ * ```ts
605
+ * const likes = await sc.me.getLikesTracks(50);
606
+ * likes.collection.forEach(t => console.log(t.title));
607
+ * ```
608
+ *
609
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_tracks
610
+ */
199
611
  getLikesTracks(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
200
- /** GET /me/likes/playlists */
612
+ /**
613
+ * Get playlists liked by the authenticated user.
614
+ *
615
+ * @param limit - Maximum number of playlists per page
616
+ * @param options - Optional token override
617
+ * @returns Paginated list of liked playlists
618
+ * @throws {SoundCloudError} When the API returns an error
619
+ *
620
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_playlists
621
+ */
201
622
  getLikesPlaylists(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
202
- /** GET /me/followings */
623
+ /**
624
+ * Get users the authenticated user is following.
625
+ *
626
+ * @param limit - Maximum number of users per page
627
+ * @param options - Optional token override
628
+ * @returns Paginated list of followed users
629
+ * @throws {SoundCloudError} When the API returns an error
630
+ *
631
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings
632
+ */
203
633
  getFollowings(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
204
- /** GET /me/followings/tracks */
634
+ /**
635
+ * Get recent tracks from users the authenticated user is following.
636
+ *
637
+ * @param limit - Maximum number of tracks per page
638
+ * @param options - Optional token override
639
+ * @returns Paginated list of tracks from followed users
640
+ * @throws {SoundCloudError} When the API returns an error
641
+ *
642
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings_tracks
643
+ */
205
644
  getFollowingsTracks(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
206
- /** PUT /me/followings/:user_urn — follow a user */
645
+ /**
646
+ * Follow a user.
647
+ *
648
+ * @param userUrn - The user's ID or URN to follow
649
+ * @param options - Optional token override
650
+ * @throws {SoundCloudError} When the API returns an error
651
+ *
652
+ * @example
653
+ * ```ts
654
+ * await sc.me.follow(123456);
655
+ * ```
656
+ *
657
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/put_me_followings__user_id_
658
+ */
207
659
  follow(userUrn: string | number, options?: TokenOption): Promise<void>;
208
- /** DELETE /me/followings/:user_urn — unfollow a user */
660
+ /**
661
+ * Unfollow a user.
662
+ *
663
+ * @param userUrn - The user's ID or URN to unfollow
664
+ * @param options - Optional token override
665
+ * @throws {SoundCloudError} When the API returns an error
666
+ *
667
+ * @example
668
+ * ```ts
669
+ * await sc.me.unfollow(123456);
670
+ * ```
671
+ *
672
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/delete_me_followings__user_id_
673
+ */
209
674
  unfollow(userUrn: string | number, options?: TokenOption): Promise<void>;
210
- /** GET /me/followers */
675
+ /**
676
+ * Get the authenticated user's followers.
677
+ *
678
+ * @param limit - Maximum number of users per page
679
+ * @param options - Optional token override
680
+ * @returns Paginated list of follower users
681
+ * @throws {SoundCloudError} When the API returns an error
682
+ *
683
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followers
684
+ */
211
685
  getFollowers(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
212
- /** GET /me/playlists */
686
+ /**
687
+ * Get the authenticated user's playlists.
688
+ *
689
+ * @param limit - Maximum number of playlists per page
690
+ * @param options - Optional token override
691
+ * @returns Paginated list of playlists
692
+ * @throws {SoundCloudError} When the API returns an error
693
+ *
694
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_playlists
695
+ */
213
696
  getPlaylists(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
214
- /** GET /me/tracks */
697
+ /**
698
+ * Get the authenticated user's tracks.
699
+ *
700
+ * @param limit - Maximum number of tracks per page
701
+ * @param options - Optional token override
702
+ * @returns Paginated list of tracks
703
+ * @throws {SoundCloudError} When the API returns an error
704
+ *
705
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_tracks
706
+ */
215
707
  getTracks(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
216
708
  }
709
+ /**
710
+ * User profile namespace — fetch public user data.
711
+ *
712
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users
713
+ */
217
714
  class Users {
218
715
  private getToken;
219
716
  private refreshCtx?;
220
717
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
221
718
  private fetch;
222
- /** GET /users/:id */
719
+ /**
720
+ * Get a user's profile by ID.
721
+ *
722
+ * @param userId - The user's numeric ID or URN
723
+ * @param options - Optional token override
724
+ * @returns The user's public profile
725
+ * @throws {SoundCloudError} When the user is not found or the API returns an error
726
+ *
727
+ * @example
728
+ * ```ts
729
+ * const user = await sc.users.getUser(123456);
730
+ * console.log(user.username, user.followers_count);
731
+ * ```
732
+ *
733
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id_
734
+ */
223
735
  getUser(userId: string | number, options?: TokenOption): Promise<SoundCloudUser>;
224
- /** GET /users/:id/followers */
736
+ /**
737
+ * Get a user's followers.
738
+ *
739
+ * @param userId - The user's numeric ID or URN
740
+ * @param limit - Maximum number of followers per page
741
+ * @param options - Optional token override
742
+ * @returns Paginated list of follower users
743
+ * @throws {SoundCloudError} When the API returns an error
744
+ *
745
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followers
746
+ */
225
747
  getFollowers(userId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
226
- /** GET /users/:id/followings */
748
+ /**
749
+ * Get users that a user is following.
750
+ *
751
+ * @param userId - The user's numeric ID or URN
752
+ * @param limit - Maximum number of users per page
753
+ * @param options - Optional token override
754
+ * @returns Paginated list of followed users
755
+ * @throws {SoundCloudError} When the API returns an error
756
+ *
757
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followings
758
+ */
227
759
  getFollowings(userId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
228
- /** GET /users/:id/tracks */
760
+ /**
761
+ * Get a user's public tracks.
762
+ *
763
+ * @param userId - The user's numeric ID or URN
764
+ * @param limit - Maximum number of tracks per page
765
+ * @param options - Optional token override
766
+ * @returns Paginated list of tracks
767
+ * @throws {SoundCloudError} When the API returns an error
768
+ *
769
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__tracks
770
+ */
229
771
  getTracks(userId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
230
- /** GET /users/:id/playlists */
772
+ /**
773
+ * Get a user's public playlists.
774
+ *
775
+ * @param userId - The user's numeric ID or URN
776
+ * @param limit - Maximum number of playlists per page
777
+ * @param options - Optional token override
778
+ * @returns Paginated list of playlists (without full track data)
779
+ * @throws {SoundCloudError} When the API returns an error
780
+ *
781
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__playlists
782
+ */
231
783
  getPlaylists(userId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
232
- /** GET /users/:id/likes/tracks */
784
+ /**
785
+ * Get tracks liked by a user.
786
+ *
787
+ * @param userId - The user's numeric ID or URN
788
+ * @param limit - Maximum number of tracks per page
789
+ * @param cursor - Pagination cursor from a previous response's `next_href`
790
+ * @param options - Optional token override
791
+ * @returns Paginated list of liked tracks
792
+ * @throws {SoundCloudError} When the API returns an error
793
+ *
794
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_tracks
795
+ */
233
796
  getLikesTracks(userId: string | number, limit?: number, cursor?: string, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
234
- /** GET /users/:id/likes/playlists */
797
+ /**
798
+ * Get playlists liked by a user.
799
+ *
800
+ * @param userId - The user's numeric ID or URN
801
+ * @param limit - Maximum number of playlists per page
802
+ * @param options - Optional token override
803
+ * @returns Paginated list of liked playlists
804
+ * @throws {SoundCloudError} When the API returns an error
805
+ *
806
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_playlists
807
+ */
235
808
  getLikesPlaylists(userId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
236
- /** GET /users/:id/web-profiles */
809
+ /**
810
+ * Get a user's external web profile links (Twitter, Instagram, etc.).
811
+ *
812
+ * @param userId - The user's numeric ID or URN
813
+ * @param options - Optional token override
814
+ * @returns Array of web profile objects
815
+ * @throws {SoundCloudError} When the API returns an error
816
+ *
817
+ * @example
818
+ * ```ts
819
+ * const profiles = await sc.users.getWebProfiles(123456);
820
+ * profiles.forEach(p => console.log(p.service, p.url));
821
+ * ```
822
+ *
823
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__web_profiles
824
+ */
237
825
  getWebProfiles(userId: string | number, options?: TokenOption): Promise<SoundCloudWebProfile[]>;
238
826
  }
827
+ /**
828
+ * Track namespace — fetch, update, delete tracks and their metadata.
829
+ *
830
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks
831
+ */
239
832
  class Tracks {
240
833
  private getToken;
241
834
  private refreshCtx?;
242
835
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
243
836
  private fetch;
244
- /** GET /tracks/:id */
837
+ /**
838
+ * Get a track by ID.
839
+ *
840
+ * @param trackId - The track's numeric ID or URN
841
+ * @param options - Optional token override
842
+ * @returns The track object with full metadata
843
+ * @throws {SoundCloudError} When the track is not found or the API returns an error
844
+ *
845
+ * @example
846
+ * ```ts
847
+ * const track = await sc.tracks.getTrack(123456);
848
+ * console.log(track.title, track.duration);
849
+ * ```
850
+ *
851
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id_
852
+ */
245
853
  getTrack(trackId: string | number, options?: TokenOption): Promise<SoundCloudTrack>;
246
- /** GET /tracks/:id/streams */
854
+ /**
855
+ * Get stream URLs for a track.
856
+ *
857
+ * @param trackId - The track's numeric ID or URN
858
+ * @param options - Optional token override
859
+ * @returns Object containing available stream URLs (HLS, MP3, preview)
860
+ * @throws {SoundCloudError} When the track is not found or not streamable
861
+ *
862
+ * @example
863
+ * ```ts
864
+ * const streams = await sc.tracks.getStreams(123456);
865
+ * console.log(streams.hls_mp3_128_url);
866
+ * ```
867
+ *
868
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__streams
869
+ */
247
870
  getStreams(trackId: string | number, options?: TokenOption): Promise<SoundCloudStreams>;
248
- /** GET /tracks/:id/comments */
871
+ /**
872
+ * Get comments on a track.
873
+ *
874
+ * @param trackId - The track's numeric ID or URN
875
+ * @param limit - Maximum number of comments per page
876
+ * @param options - Optional token override
877
+ * @returns Paginated list of comments
878
+ * @throws {SoundCloudError} When the API returns an error
879
+ *
880
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__comments
881
+ */
249
882
  getComments(trackId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudComment>>;
250
- /** POST /tracks/:id/comments */
883
+ /**
884
+ * Post a comment on a track.
885
+ *
886
+ * @param trackId - The track's numeric ID or URN
887
+ * @param body - The comment text
888
+ * @param timestamp - Position in the track in milliseconds where the comment is placed
889
+ * @param options - Optional token override
890
+ * @returns The created comment object
891
+ * @throws {SoundCloudError} When the API returns an error
892
+ *
893
+ * @example
894
+ * ```ts
895
+ * const comment = await sc.tracks.createComment(123456, 'Great track!', 30000);
896
+ * console.log(comment.id);
897
+ * ```
898
+ *
899
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/post_tracks__track_id__comments
900
+ */
251
901
  createComment(trackId: string | number, body: string, timestamp?: number, options?: TokenOption): Promise<SoundCloudComment>;
252
- /** GET /tracks/:id/favoriters */
902
+ /**
903
+ * Get users who have liked (favorited) a track.
904
+ *
905
+ * @param trackId - The track's numeric ID or URN
906
+ * @param limit - Maximum number of users per page
907
+ * @param options - Optional token override
908
+ * @returns Paginated list of users who liked the track
909
+ * @throws {SoundCloudError} When the API returns an error
910
+ *
911
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__favoriters
912
+ */
253
913
  getLikes(trackId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
254
- /** GET /tracks/:id/reposters */
914
+ /**
915
+ * Get users who have reposted a track.
916
+ *
917
+ * @param trackId - The track's numeric ID or URN
918
+ * @param limit - Maximum number of users per page
919
+ * @param options - Optional token override
920
+ * @returns Paginated list of users who reposted the track
921
+ * @throws {SoundCloudError} When the API returns an error
922
+ *
923
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__reposters
924
+ */
255
925
  getReposts(trackId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
256
- /** GET /tracks/:id/related */
926
+ /**
927
+ * Get tracks related to a given track.
928
+ *
929
+ * @param trackId - The track's numeric ID or URN
930
+ * @param limit - Maximum number of related tracks to return
931
+ * @param options - Optional token override
932
+ * @returns Array of related tracks
933
+ * @throws {SoundCloudError} When the API returns an error
934
+ *
935
+ * @example
936
+ * ```ts
937
+ * const related = await sc.tracks.getRelated(123456, 5);
938
+ * related.forEach(t => console.log(t.title));
939
+ * ```
940
+ *
941
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__related
942
+ */
257
943
  getRelated(trackId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudTrack[]>;
258
- /** PUT /tracks/:id — update track metadata */
944
+ /**
945
+ * Update a track's metadata.
946
+ *
947
+ * @param trackId - The track's numeric ID or URN
948
+ * @param params - Fields to update (title, description, genre, etc.)
949
+ * @param options - Optional token override
950
+ * @returns The updated track object
951
+ * @throws {SoundCloudError} When the API returns an error
952
+ *
953
+ * @example
954
+ * ```ts
955
+ * const updated = await sc.tracks.update(123456, { title: 'New Title', genre: 'Electronic' });
956
+ * console.log(updated.title);
957
+ * ```
958
+ *
959
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/put_tracks__track_id_
960
+ */
259
961
  update(trackId: string | number, params: UpdateTrackParams, options?: TokenOption): Promise<SoundCloudTrack>;
260
- /** DELETE /tracks/:id */
962
+ /**
963
+ * Delete a track.
964
+ *
965
+ * @param trackId - The track's numeric ID or URN
966
+ * @param options - Optional token override
967
+ * @throws {SoundCloudError} When the API returns an error
968
+ *
969
+ * @example
970
+ * ```ts
971
+ * await sc.tracks.delete(123456);
972
+ * ```
973
+ *
974
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/delete_tracks__track_id_
975
+ */
261
976
  delete(trackId: string | number, options?: TokenOption): Promise<void>;
262
977
  }
978
+ /**
979
+ * Playlist namespace — fetch, create, update, and delete playlists.
980
+ *
981
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists
982
+ */
263
983
  class Playlists {
264
984
  private getToken;
265
985
  private refreshCtx?;
266
986
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
267
987
  private fetch;
268
- /** GET /playlists/:id */
988
+ /**
989
+ * Get a playlist by ID.
990
+ *
991
+ * @param playlistId - The playlist's numeric ID or URN
992
+ * @param options - Optional token override
993
+ * @returns The playlist object with track data
994
+ * @throws {SoundCloudError} When the playlist is not found or the API returns an error
995
+ *
996
+ * @example
997
+ * ```ts
998
+ * const playlist = await sc.playlists.getPlaylist(123456);
999
+ * console.log(playlist.title, playlist.track_count);
1000
+ * ```
1001
+ *
1002
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id_
1003
+ */
269
1004
  getPlaylist(playlistId: string | number, options?: TokenOption): Promise<SoundCloudPlaylist>;
270
- /** GET /playlists/:id/tracks */
1005
+ /**
1006
+ * Get tracks in a playlist.
1007
+ *
1008
+ * @param playlistId - The playlist's numeric ID or URN
1009
+ * @param limit - Maximum number of tracks per page
1010
+ * @param offset - Number of tracks to skip (for offset-based pagination)
1011
+ * @param options - Optional token override
1012
+ * @returns Paginated list of tracks
1013
+ * @throws {SoundCloudError} When the API returns an error
1014
+ *
1015
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__tracks
1016
+ */
271
1017
  getTracks(playlistId: string | number, limit?: number, offset?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
272
- /** GET /playlists/:id/reposters */
1018
+ /**
1019
+ * Get users who have reposted a playlist.
1020
+ *
1021
+ * @param playlistId - The playlist's numeric ID or URN
1022
+ * @param limit - Maximum number of users per page
1023
+ * @param options - Optional token override
1024
+ * @returns Paginated list of users who reposted the playlist
1025
+ * @throws {SoundCloudError} When the API returns an error
1026
+ *
1027
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__reposters
1028
+ */
273
1029
  getReposts(playlistId: string | number, limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
274
- /** POST /playlists — create a playlist */
1030
+ /**
1031
+ * Create a new playlist.
1032
+ *
1033
+ * @param params - Playlist creation parameters (title is required)
1034
+ * @param options - Optional token override
1035
+ * @returns The created playlist object
1036
+ * @throws {SoundCloudError} When the API returns an error
1037
+ *
1038
+ * @example
1039
+ * ```ts
1040
+ * const playlist = await sc.playlists.create({
1041
+ * title: 'My Favorites',
1042
+ * sharing: 'public',
1043
+ * tracks: [{ urn: 'soundcloud:tracks:123' }],
1044
+ * });
1045
+ * ```
1046
+ *
1047
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/post_playlists
1048
+ */
275
1049
  create(params: CreatePlaylistParams, options?: TokenOption): Promise<SoundCloudPlaylist>;
276
- /** PUT /playlists/:id — update a playlist */
277
- update(playlistId: string | number, params: UpdatePlaylistParams, options?: TokenOption): Promise<SoundCloudPlaylist>;
278
- /** DELETE /playlists/:id */
279
- delete(playlistId: string | number, options?: TokenOption): Promise<void>;
1050
+ /**
1051
+ * Update a playlist's metadata or track list.
1052
+ *
1053
+ * @param playlistId - The playlist's numeric ID or URN
1054
+ * @param params - Fields to update
1055
+ * @param options - Optional token override
1056
+ * @returns The updated playlist object
1057
+ * @throws {SoundCloudError} When the API returns an error
1058
+ *
1059
+ * @example
1060
+ * ```ts
1061
+ * const updated = await sc.playlists.update(123456, { title: 'Updated Title' });
1062
+ * ```
1063
+ *
1064
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/put_playlists__playlist_id_
1065
+ */
1066
+ update(playlistId: string | number, params: UpdatePlaylistParams, options?: TokenOption): Promise<SoundCloudPlaylist>;
1067
+ /**
1068
+ * Delete a playlist.
1069
+ *
1070
+ * @param playlistId - The playlist's numeric ID or URN
1071
+ * @param options - Optional token override
1072
+ * @throws {SoundCloudError} When the API returns an error
1073
+ *
1074
+ * @example
1075
+ * ```ts
1076
+ * await sc.playlists.delete(123456);
1077
+ * ```
1078
+ *
1079
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/delete_playlists__playlist_id_
1080
+ */
1081
+ delete(playlistId: string | number, options?: TokenOption): Promise<void>;
280
1082
  }
1083
+ /**
1084
+ * Search namespace — search for tracks, users, and playlists.
1085
+ *
1086
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/search
1087
+ */
281
1088
  class Search {
282
1089
  private getToken;
283
1090
  private refreshCtx?;
284
1091
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
285
1092
  private fetch;
286
- /** GET /tracks?q= */
1093
+ /**
1094
+ * Search for tracks by query string.
1095
+ *
1096
+ * @param query - Search query text
1097
+ * @param pageNumber - Zero-based page number (10 results per page)
1098
+ * @param options - Optional token override
1099
+ * @returns Paginated list of matching tracks
1100
+ * @throws {SoundCloudError} When the API returns an error
1101
+ *
1102
+ * @example
1103
+ * ```ts
1104
+ * const results = await sc.search.tracks('lofi hip hop');
1105
+ * results.collection.forEach(t => console.log(t.title));
1106
+ * ```
1107
+ *
1108
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks
1109
+ */
287
1110
  tracks(query: string, pageNumber?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
288
- /** GET /users?q= */
1111
+ /**
1112
+ * Search for users by query string.
1113
+ *
1114
+ * @param query - Search query text
1115
+ * @param pageNumber - Zero-based page number (10 results per page)
1116
+ * @param options - Optional token override
1117
+ * @returns Paginated list of matching users
1118
+ * @throws {SoundCloudError} When the API returns an error
1119
+ *
1120
+ * @example
1121
+ * ```ts
1122
+ * const results = await sc.search.users('deadmau5');
1123
+ * results.collection.forEach(u => console.log(u.username));
1124
+ * ```
1125
+ *
1126
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users
1127
+ */
289
1128
  users(query: string, pageNumber?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
290
- /** GET /playlists?q= */
1129
+ /**
1130
+ * Search for playlists by query string.
1131
+ *
1132
+ * @param query - Search query text
1133
+ * @param pageNumber - Zero-based page number (10 results per page)
1134
+ * @param options - Optional token override
1135
+ * @returns Paginated list of matching playlists
1136
+ * @throws {SoundCloudError} When the API returns an error
1137
+ *
1138
+ * @example
1139
+ * ```ts
1140
+ * const results = await sc.search.playlists('chill vibes');
1141
+ * results.collection.forEach(p => console.log(p.title));
1142
+ * ```
1143
+ *
1144
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists
1145
+ */
291
1146
  playlists(query: string, pageNumber?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
292
1147
  }
1148
+ /**
1149
+ * Resolve namespace — resolve SoundCloud URLs to API resources.
1150
+ *
1151
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/resolve
1152
+ */
293
1153
  class Resolve {
294
1154
  private getToken;
295
1155
  private refreshCtx?;
296
1156
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
297
1157
  private fetch;
298
- /** GET /resolve?url= */
1158
+ /**
1159
+ * Resolve a SoundCloud URL to its API resource URL.
1160
+ *
1161
+ * @param url - A SoundCloud URL (e.g. "https://soundcloud.com/artist/track-name")
1162
+ * @param options - Optional token override
1163
+ * @returns The resolved API resource URL (via 302 redirect)
1164
+ * @throws {SoundCloudError} When the URL cannot be resolved
1165
+ *
1166
+ * @example
1167
+ * ```ts
1168
+ * const apiUrl = await sc.resolve.resolveUrl('https://soundcloud.com/deadmau5/strobe');
1169
+ * console.log(apiUrl); // "https://api.soundcloud.com/tracks/..."
1170
+ * ```
1171
+ *
1172
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/resolve/get_resolve
1173
+ */
299
1174
  resolveUrl(url: string, options?: TokenOption): Promise<string>;
300
1175
  }
1176
+ /**
1177
+ * Likes namespace — like and unlike tracks and playlists.
1178
+ *
1179
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes
1180
+ */
301
1181
  class Likes {
302
1182
  private getToken;
303
1183
  private refreshCtx?;
304
1184
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
305
1185
  private fetch;
306
- /** POST /likes/tracks/:id */
1186
+ /**
1187
+ * Like a track.
1188
+ *
1189
+ * @param trackId - The track's numeric ID or URN
1190
+ * @param options - Optional token override
1191
+ * @returns `true` if the like was successful, `false` on failure
1192
+ *
1193
+ * @example
1194
+ * ```ts
1195
+ * const success = await sc.likes.likeTrack(123456);
1196
+ * ```
1197
+ *
1198
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_tracks__track_id_
1199
+ */
307
1200
  likeTrack(trackId: string | number, options?: TokenOption): Promise<boolean>;
308
- /** DELETE /likes/tracks/:id */
1201
+ /**
1202
+ * Unlike a track.
1203
+ *
1204
+ * @param trackId - The track's numeric ID or URN
1205
+ * @param options - Optional token override
1206
+ * @returns `true` if the unlike was successful, `false` on failure
1207
+ *
1208
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_tracks__track_id_
1209
+ */
309
1210
  unlikeTrack(trackId: string | number, options?: TokenOption): Promise<boolean>;
310
- /** POST /likes/playlists/:id */
1211
+ /**
1212
+ * Like a playlist.
1213
+ *
1214
+ * @param playlistId - The playlist's numeric ID or URN
1215
+ * @param options - Optional token override
1216
+ * @returns `true` if the like was successful, `false` on failure
1217
+ *
1218
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_playlists__playlist_id_
1219
+ */
311
1220
  likePlaylist(playlistId: string | number, options?: TokenOption): Promise<boolean>;
312
- /** DELETE /likes/playlists/:id */
1221
+ /**
1222
+ * Unlike a playlist.
1223
+ *
1224
+ * @param playlistId - The playlist's numeric ID or URN
1225
+ * @param options - Optional token override
1226
+ * @returns `true` if the unlike was successful, `false` on failure
1227
+ *
1228
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_playlists__playlist_id_
1229
+ */
313
1230
  unlikePlaylist(playlistId: string | number, options?: TokenOption): Promise<boolean>;
314
1231
  }
1232
+ /**
1233
+ * Reposts namespace — repost and unrepost tracks and playlists.
1234
+ *
1235
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts
1236
+ */
315
1237
  class Reposts {
316
1238
  private getToken;
317
1239
  private refreshCtx?;
318
1240
  constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined);
319
1241
  private fetch;
320
- /** POST /reposts/tracks/:id */
1242
+ /**
1243
+ * Repost a track to your profile.
1244
+ *
1245
+ * @param trackId - The track's numeric ID or URN
1246
+ * @param options - Optional token override
1247
+ * @returns `true` if the repost was successful, `false` on failure
1248
+ *
1249
+ * @example
1250
+ * ```ts
1251
+ * const success = await sc.reposts.repostTrack(123456);
1252
+ * ```
1253
+ *
1254
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_tracks__track_id_
1255
+ */
321
1256
  repostTrack(trackId: string | number, options?: TokenOption): Promise<boolean>;
322
- /** DELETE /reposts/tracks/:id */
1257
+ /**
1258
+ * Remove a track repost from your profile.
1259
+ *
1260
+ * @param trackId - The track's numeric ID or URN
1261
+ * @param options - Optional token override
1262
+ * @returns `true` if the unrepost was successful, `false` on failure
1263
+ *
1264
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_tracks__track_id_
1265
+ */
323
1266
  unrepostTrack(trackId: string | number, options?: TokenOption): Promise<boolean>;
324
- /** POST /reposts/playlists/:id */
1267
+ /**
1268
+ * Repost a playlist to your profile.
1269
+ *
1270
+ * @param playlistId - The playlist's numeric ID or URN
1271
+ * @param options - Optional token override
1272
+ * @returns `true` if the repost was successful, `false` on failure
1273
+ *
1274
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_playlists__playlist_id_
1275
+ */
325
1276
  repostPlaylist(playlistId: string | number, options?: TokenOption): Promise<boolean>;
326
- /** DELETE /reposts/playlists/:id */
1277
+ /**
1278
+ * Remove a playlist repost from your profile.
1279
+ *
1280
+ * @param playlistId - The playlist's numeric ID or URN
1281
+ * @param options - Optional token override
1282
+ * @returns `true` if the unrepost was successful, `false` on failure
1283
+ *
1284
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_playlists__playlist_id_
1285
+ */
327
1286
  unrepostPlaylist(playlistId: string | number, options?: TokenOption): Promise<boolean>;
328
1287
  }
329
1288
  }
330
1289
 
331
1290
  /**
332
- * Async generator that follows `next_href` automatically, yielding each page's `collection`.
1291
+ * Async generator that automatically follows `next_href` pagination,
1292
+ * yielding each page's `collection` array.
1293
+ *
1294
+ * @param firstPage - Function that fetches the first page of results
1295
+ * @param fetchNext - Function that fetches subsequent pages given a `next_href` URL
1296
+ * @returns An async generator yielding arrays of items (one per page)
1297
+ *
1298
+ * @example
1299
+ * ```ts
1300
+ * import { paginate, searchTracks, scFetchUrl } from 'tsd-soundcloud';
1301
+ *
1302
+ * const pages = paginate(
1303
+ * () => searchTracks(token, 'lofi'),
1304
+ * (url) => scFetchUrl(url, token),
1305
+ * );
1306
+ *
1307
+ * for await (const page of pages) {
1308
+ * console.log(`Got ${page.length} tracks`);
1309
+ * }
1310
+ * ```
1311
+ *
1312
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api
333
1313
  */
334
1314
  declare function paginate<T>(firstPage: () => Promise<SoundCloudPaginatedResponse<T>>, fetchNext: (url: string) => Promise<SoundCloudPaginatedResponse<T>>): AsyncGenerator<T[], void, undefined>;
335
1315
  /**
336
- * Async generator that yields individual items across all pages.
1316
+ * Async generator that yields individual items across all pages,
1317
+ * automatically following `next_href` pagination.
1318
+ *
1319
+ * @param firstPage - Function that fetches the first page of results
1320
+ * @param fetchNext - Function that fetches subsequent pages given a `next_href` URL
1321
+ * @returns An async generator yielding individual items
1322
+ *
1323
+ * @example
1324
+ * ```ts
1325
+ * import { paginateItems, searchTracks, scFetchUrl } from 'tsd-soundcloud';
1326
+ *
1327
+ * const tracks = paginateItems(
1328
+ * () => searchTracks(token, 'lofi'),
1329
+ * (url) => scFetchUrl(url, token),
1330
+ * );
1331
+ *
1332
+ * for await (const track of tracks) {
1333
+ * console.log(track.title);
1334
+ * }
1335
+ * ```
1336
+ *
1337
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api
337
1338
  */
338
1339
  declare function paginateItems<T>(firstPage: () => Promise<SoundCloudPaginatedResponse<T>>, fetchNext: (url: string) => Promise<SoundCloudPaginatedResponse<T>>): AsyncGenerator<T, void, undefined>;
339
1340
  /**
340
- * Collects all pages into a single flat array with an optional max items limit.
1341
+ * Collects all pages into a single flat array, with an optional maximum item limit.
1342
+ *
1343
+ * @param firstPage - Function that fetches the first page of results
1344
+ * @param fetchNext - Function that fetches subsequent pages given a `next_href` URL
1345
+ * @param options - Optional configuration
1346
+ * @param options.maxItems - Maximum number of items to collect (defaults to all)
1347
+ * @returns A promise that resolves to a flat array of all collected items
1348
+ *
1349
+ * @example
1350
+ * ```ts
1351
+ * import { fetchAll, searchTracks, scFetchUrl } from 'tsd-soundcloud';
1352
+ *
1353
+ * const allTracks = await fetchAll(
1354
+ * () => searchTracks(token, 'lofi'),
1355
+ * (url) => scFetchUrl(url, token),
1356
+ * { maxItems: 100 },
1357
+ * );
1358
+ * console.log(`Fetched ${allTracks.length} tracks`);
1359
+ * ```
1360
+ *
1361
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api
341
1362
  */
342
1363
  declare function fetchAll<T>(firstPage: () => Promise<SoundCloudPaginatedResponse<T>>, fetchNext: (url: string) => Promise<SoundCloudPaginatedResponse<T>>, options?: {
343
1364
  maxItems?: number;
344
1365
  }): Promise<T[]>;
345
1366
 
1367
+ /**
1368
+ * Exchange client credentials for an access token (client_credentials grant).
1369
+ *
1370
+ * This is a standalone function alternative to {@link SoundCloudClient.Auth.getClientToken}.
1371
+ *
1372
+ * @param clientId - Your SoundCloud application's OAuth client ID
1373
+ * @param clientSecret - Your SoundCloud application's OAuth client secret
1374
+ * @returns The OAuth token response
1375
+ * @throws {SoundCloudError} When authentication fails (e.g. invalid credentials)
1376
+ *
1377
+ * @example
1378
+ * ```ts
1379
+ * import { getClientToken } from 'tsd-soundcloud';
1380
+ *
1381
+ * const token = await getClientToken('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
1382
+ * console.log(token.access_token);
1383
+ * ```
1384
+ *
1385
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token
1386
+ */
346
1387
  declare const getClientToken: (clientId: string, clientSecret: string) => Promise<SoundCloudToken>;
347
1388
 
1389
+ /**
1390
+ * Exchange an authorization code for user tokens (authorization_code grant).
1391
+ *
1392
+ * This is a standalone function alternative to {@link SoundCloudClient.Auth.getUserToken}.
1393
+ *
1394
+ * @param clientId - Your SoundCloud application's OAuth client ID
1395
+ * @param clientSecret - Your SoundCloud application's OAuth client secret
1396
+ * @param redirectUri - The redirect URI registered with your SoundCloud application
1397
+ * @param code - The authorization code received from the OAuth callback
1398
+ * @param codeVerifier - PKCE code verifier if a code challenge was used during authorization
1399
+ * @returns The OAuth token response including access and refresh tokens
1400
+ * @throws {SoundCloudError} When the code is invalid, expired, or credentials are wrong
1401
+ *
1402
+ * @example
1403
+ * ```ts
1404
+ * import { getUserToken } from 'tsd-soundcloud';
1405
+ *
1406
+ * const token = await getUserToken(
1407
+ * 'YOUR_CLIENT_ID',
1408
+ * 'YOUR_CLIENT_SECRET',
1409
+ * 'https://example.com/callback',
1410
+ * authorizationCode,
1411
+ * codeVerifier, // optional, for PKCE
1412
+ * );
1413
+ * console.log(token.access_token, token.refresh_token);
1414
+ * ```
1415
+ *
1416
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token
1417
+ */
348
1418
  declare const getUserToken: (clientId: string, clientSecret: string, redirectUri: string, code: string, codeVerifier?: string) => Promise<SoundCloudToken>;
349
1419
 
1420
+ /**
1421
+ * Refresh an expired access token using a refresh token (refresh_token grant).
1422
+ *
1423
+ * This is a standalone function alternative to {@link SoundCloudClient.Auth.refreshUserToken}.
1424
+ *
1425
+ * @param clientId - Your SoundCloud application's OAuth client ID
1426
+ * @param clientSecret - Your SoundCloud application's OAuth client secret
1427
+ * @param redirectUri - The redirect URI registered with your SoundCloud application
1428
+ * @param refreshToken - The refresh token from a previous token response
1429
+ * @returns A new OAuth token response with fresh access and refresh tokens
1430
+ * @throws {SoundCloudError} When the refresh token is invalid or expired
1431
+ *
1432
+ * @example
1433
+ * ```ts
1434
+ * import { refreshUserToken } from 'tsd-soundcloud';
1435
+ *
1436
+ * const newToken = await refreshUserToken(
1437
+ * 'YOUR_CLIENT_ID',
1438
+ * 'YOUR_CLIENT_SECRET',
1439
+ * 'https://example.com/callback',
1440
+ * oldRefreshToken,
1441
+ * );
1442
+ * console.log(newToken.access_token);
1443
+ * ```
1444
+ *
1445
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token
1446
+ */
350
1447
  declare const refreshUserToken: (clientId: string, clientSecret: string, redirectUri: string, refreshToken: string) => Promise<SoundCloudToken>;
351
1448
 
352
1449
  /**
353
- * POST /sign-out — invalidates session associated with current token.
1450
+ * Invalidate the session associated with an access token.
354
1451
  *
355
1452
  * **Note:** This hits `https://secure.soundcloud.com`, NOT the regular
356
1453
  * `api.soundcloud.com` host used by all other endpoints.
1454
+ *
1455
+ * @param accessToken - The OAuth access token to invalidate
1456
+ * @throws {Error} When the sign-out request fails
1457
+ *
1458
+ * @example
1459
+ * ```ts
1460
+ * import { signOut } from 'tsd-soundcloud';
1461
+ *
1462
+ * await signOut('your-access-token');
1463
+ * ```
357
1464
  */
358
1465
  declare const signOut: (accessToken: string) => Promise<void>;
359
1466
 
@@ -361,6 +1468,28 @@ declare const signOut: (accessToken: string) => Promise<void>;
361
1468
  * Build the SoundCloud authorization URL for the OAuth 2.0 code flow.
362
1469
  *
363
1470
  * Redirect the user to this URL so they can grant access to your application.
1471
+ *
1472
+ * @param clientId - Your SoundCloud application's OAuth client ID
1473
+ * @param redirectUri - The redirect URI registered with your SoundCloud application
1474
+ * @param options - Optional parameters for the authorization request
1475
+ * @param options.state - Opaque state value for CSRF protection (round-tripped by SoundCloud)
1476
+ * @param options.codeChallenge - PKCE S256 code challenge for enhanced security
1477
+ * @returns The full authorization URL to redirect the user to
1478
+ *
1479
+ * @example
1480
+ * ```ts
1481
+ * import { getAuthorizationUrl, generateCodeVerifier, generateCodeChallenge } from 'tsd-soundcloud';
1482
+ *
1483
+ * const verifier = generateCodeVerifier();
1484
+ * const challenge = await generateCodeChallenge(verifier);
1485
+ * const url = getAuthorizationUrl('YOUR_CLIENT_ID', 'https://example.com/callback', {
1486
+ * state: 'random-csrf-token',
1487
+ * codeChallenge: challenge,
1488
+ * });
1489
+ * // Redirect user to `url`
1490
+ * ```
1491
+ *
1492
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2
364
1493
  */
365
1494
  declare function getAuthorizationUrl(clientId: string, redirectUri: string, options?: {
366
1495
  state?: string;
@@ -368,118 +1497,838 @@ declare function getAuthorizationUrl(clientId: string, redirectUri: string, opti
368
1497
  }): string;
369
1498
 
370
1499
  /**
371
- * Generate a random PKCE code verifier (43 chars, base64url).
372
- * Works in Node 18+ and modern browsers via globalThis.crypto.
1500
+ * Generate a random PKCE code verifier (43+ characters, base64url-encoded).
1501
+ *
1502
+ * Uses the Web Crypto API (`globalThis.crypto`), compatible with Node 18+ and modern browsers.
1503
+ *
1504
+ * @returns A cryptographically random code verifier string
1505
+ *
1506
+ * @example
1507
+ * ```ts
1508
+ * import { generateCodeVerifier, generateCodeChallenge } from 'tsd-soundcloud';
1509
+ *
1510
+ * const verifier = generateCodeVerifier();
1511
+ * const challenge = await generateCodeChallenge(verifier);
1512
+ * // Use `challenge` in getAuthorizationUrl, then `verifier` in getUserToken
1513
+ * ```
1514
+ *
1515
+ * @see https://datatracker.ietf.org/doc/html/rfc7636
373
1516
  */
374
1517
  declare function generateCodeVerifier(): string;
375
1518
  /**
376
- * Derive the S256 code challenge from a code verifier.
377
- * Uses the Web Crypto API (SubtleCrypto) available in Node 18+ and browsers.
1519
+ * Derive the S256 PKCE code challenge from a code verifier.
1520
+ *
1521
+ * Computes `BASE64URL(SHA256(verifier))` using the Web Crypto API (SubtleCrypto),
1522
+ * available in Node 18+ and modern browsers.
1523
+ *
1524
+ * @param verifier - The code verifier string (typically from {@link generateCodeVerifier})
1525
+ * @returns The base64url-encoded SHA-256 hash of the verifier
1526
+ *
1527
+ * @example
1528
+ * ```ts
1529
+ * import { generateCodeVerifier, generateCodeChallenge } from 'tsd-soundcloud';
1530
+ *
1531
+ * const verifier = generateCodeVerifier();
1532
+ * const challenge = await generateCodeChallenge(verifier);
1533
+ * console.log(challenge); // e.g. "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
1534
+ * ```
1535
+ *
1536
+ * @see https://datatracker.ietf.org/doc/html/rfc7636#section-4.2
378
1537
  */
379
1538
  declare function generateCodeChallenge(verifier: string): Promise<string>;
380
1539
 
1540
+ /**
1541
+ * Fetch the authenticated user's profile.
1542
+ *
1543
+ * @param token - OAuth access token
1544
+ * @returns The authenticated user's full profile including private account details
1545
+ * @throws {SoundCloudError} When the token is invalid or the API returns an error
1546
+ *
1547
+ * @example
1548
+ * ```ts
1549
+ * import { getMe } from 'tsd-soundcloud';
1550
+ *
1551
+ * const me = await getMe(token);
1552
+ * console.log(me.username, me.private_tracks_count);
1553
+ * ```
1554
+ *
1555
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me
1556
+ */
381
1557
  declare const getMe: (token: string) => Promise<SoundCloudMe>;
382
1558
 
1559
+ /**
1560
+ * Fetch a user's public profile by ID.
1561
+ *
1562
+ * @param token - OAuth access token
1563
+ * @param userId - The user's numeric ID or URN
1564
+ * @returns The user's public profile
1565
+ * @throws {SoundCloudError} When the user is not found or the API returns an error
1566
+ *
1567
+ * @example
1568
+ * ```ts
1569
+ * import { getUser } from 'tsd-soundcloud';
1570
+ *
1571
+ * const user = await getUser(token, 123456);
1572
+ * console.log(user.username);
1573
+ * ```
1574
+ *
1575
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id_
1576
+ */
383
1577
  declare const getUser: (token: string, userId: string | number) => Promise<SoundCloudUser>;
384
1578
 
1579
+ /**
1580
+ * Fetch a user's followers.
1581
+ *
1582
+ * @param token - OAuth access token
1583
+ * @param userId - The user's numeric ID or URN
1584
+ * @param limit - Maximum number of followers per page
1585
+ * @returns Paginated list of follower users
1586
+ * @throws {SoundCloudError} When the API returns an error
1587
+ *
1588
+ * @example
1589
+ * ```ts
1590
+ * import { getFollowers } from 'tsd-soundcloud';
1591
+ *
1592
+ * const result = await getFollowers(token, 123456, 50);
1593
+ * result.collection.forEach(u => console.log(u.username));
1594
+ * ```
1595
+ *
1596
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followers
1597
+ */
385
1598
  declare const getFollowers: (token: string, userId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
386
1599
 
1600
+ /**
1601
+ * Fetch users that a given user is following.
1602
+ *
1603
+ * @param token - OAuth access token
1604
+ * @param userId - The user's numeric ID or URN
1605
+ * @param limit - Maximum number of users per page
1606
+ * @returns Paginated list of followed users
1607
+ * @throws {SoundCloudError} When the API returns an error
1608
+ *
1609
+ * @example
1610
+ * ```ts
1611
+ * import { getFollowings } from 'tsd-soundcloud';
1612
+ *
1613
+ * const result = await getFollowings(token, 123456, 50);
1614
+ * result.collection.forEach(u => console.log(u.username));
1615
+ * ```
1616
+ *
1617
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followings
1618
+ */
387
1619
  declare const getFollowings: (token: string, userId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
388
1620
 
1621
+ /**
1622
+ * Fetch a user's public tracks.
1623
+ *
1624
+ * @param token - OAuth access token
1625
+ * @param userId - The user's numeric ID or URN
1626
+ * @param limit - Maximum number of tracks per page
1627
+ * @returns Paginated list of tracks
1628
+ * @throws {SoundCloudError} When the API returns an error
1629
+ *
1630
+ * @example
1631
+ * ```ts
1632
+ * import { getUserTracks } from 'tsd-soundcloud';
1633
+ *
1634
+ * const result = await getUserTracks(token, 123456, 25);
1635
+ * result.collection.forEach(t => console.log(t.title));
1636
+ * ```
1637
+ *
1638
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__tracks
1639
+ */
389
1640
  declare const getUserTracks: (token: string, userId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
390
1641
 
1642
+ /**
1643
+ * Fetch a user's public playlists (without full track data).
1644
+ *
1645
+ * @param token - OAuth access token
1646
+ * @param userId - The user's numeric ID or URN
1647
+ * @param limit - Maximum number of playlists per page
1648
+ * @returns Paginated list of playlists
1649
+ * @throws {SoundCloudError} When the API returns an error
1650
+ *
1651
+ * @example
1652
+ * ```ts
1653
+ * import { getUserPlaylists } from 'tsd-soundcloud';
1654
+ *
1655
+ * const result = await getUserPlaylists(token, 123456, 10);
1656
+ * result.collection.forEach(p => console.log(p.title));
1657
+ * ```
1658
+ *
1659
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__playlists
1660
+ */
391
1661
  declare const getUserPlaylists: (token: string, userId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
392
1662
 
1663
+ /**
1664
+ * Fetch tracks liked by a user.
1665
+ *
1666
+ * @param token - OAuth access token
1667
+ * @param userId - The user's numeric ID or URN
1668
+ * @param limit - Maximum number of tracks per page
1669
+ * @param cursor - Pagination cursor from a previous response's `next_href`
1670
+ * @returns Paginated list of liked tracks
1671
+ * @throws {SoundCloudError} When the API returns an error
1672
+ *
1673
+ * @example
1674
+ * ```ts
1675
+ * import { getUserLikesTracks } from 'tsd-soundcloud';
1676
+ *
1677
+ * const result = await getUserLikesTracks(token, 123456, 50);
1678
+ * result.collection.forEach(t => console.log(t.title));
1679
+ * ```
1680
+ *
1681
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_tracks
1682
+ */
393
1683
  declare const getUserLikesTracks: (token: string, userId: string | number, limit?: number, cursor?: string) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
394
1684
 
1685
+ /**
1686
+ * Fetch playlists liked by a user.
1687
+ *
1688
+ * @param token - OAuth access token
1689
+ * @param userId - The user's numeric ID or URN
1690
+ * @param limit - Maximum number of playlists per page
1691
+ * @returns Paginated list of liked playlists
1692
+ * @throws {SoundCloudError} When the API returns an error
1693
+ *
1694
+ * @example
1695
+ * ```ts
1696
+ * import { getUserLikesPlaylists } from 'tsd-soundcloud';
1697
+ *
1698
+ * const result = await getUserLikesPlaylists(token, 123456, 10);
1699
+ * result.collection.forEach(p => console.log(p.title));
1700
+ * ```
1701
+ *
1702
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_playlists
1703
+ */
395
1704
  declare const getUserLikesPlaylists: (token: string, userId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
396
1705
 
397
- /** GET /users/:id/web-profiles — returns user's external links */
1706
+ /**
1707
+ * Fetch a user's external web profile links (Twitter, Instagram, personal site, etc.).
1708
+ *
1709
+ * @param token - OAuth access token
1710
+ * @param userId - The user's numeric ID or URN
1711
+ * @returns Array of web profile objects
1712
+ * @throws {SoundCloudError} When the API returns an error
1713
+ *
1714
+ * @example
1715
+ * ```ts
1716
+ * import { getUserWebProfiles } from 'tsd-soundcloud';
1717
+ *
1718
+ * const profiles = await getUserWebProfiles(token, 123456);
1719
+ * profiles.forEach(p => console.log(p.service, p.url));
1720
+ * ```
1721
+ *
1722
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__web_profiles
1723
+ */
398
1724
  declare const getUserWebProfiles: (token: string, userId: string | number) => Promise<SoundCloudWebProfile[]>;
399
1725
 
1726
+ /**
1727
+ * Fetch a track by ID.
1728
+ *
1729
+ * @param token - OAuth access token
1730
+ * @param trackId - The track's numeric ID or URN
1731
+ * @returns The track object with full metadata
1732
+ * @throws {SoundCloudError} When the track is not found or the API returns an error
1733
+ *
1734
+ * @example
1735
+ * ```ts
1736
+ * import { getTrack } from 'tsd-soundcloud';
1737
+ *
1738
+ * const track = await getTrack(token, 123456);
1739
+ * console.log(track.title, track.duration);
1740
+ * ```
1741
+ *
1742
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id_
1743
+ */
400
1744
  declare const getTrack: (token: string, trackId: string | number) => Promise<SoundCloudTrack>;
401
1745
 
1746
+ /**
1747
+ * Fetch comments on a track.
1748
+ *
1749
+ * @param token - OAuth access token
1750
+ * @param trackId - The track's numeric ID or URN
1751
+ * @param limit - Maximum number of comments per page
1752
+ * @returns Paginated list of comments
1753
+ * @throws {SoundCloudError} When the API returns an error
1754
+ *
1755
+ * @example
1756
+ * ```ts
1757
+ * import { getTrackComments } from 'tsd-soundcloud';
1758
+ *
1759
+ * const result = await getTrackComments(token, 123456, 20);
1760
+ * result.collection.forEach(c => console.log(c.body));
1761
+ * ```
1762
+ *
1763
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__comments
1764
+ */
402
1765
  declare const getTrackComments: (token: string, trackId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudComment>>;
403
1766
 
404
- /** POST /tracks/:id/comments — creates a comment on a track */
1767
+ /**
1768
+ * Post a comment on a track.
1769
+ *
1770
+ * @param token - OAuth access token
1771
+ * @param trackId - The track's numeric ID or URN
1772
+ * @param body - The comment text
1773
+ * @param timestamp - Position in the track in milliseconds where the comment is placed
1774
+ * @returns The created comment object
1775
+ * @throws {SoundCloudError} When the API returns an error
1776
+ *
1777
+ * @example
1778
+ * ```ts
1779
+ * import { createTrackComment } from 'tsd-soundcloud';
1780
+ *
1781
+ * const comment = await createTrackComment(token, 123456, 'Great drop!', 60000);
1782
+ * console.log(comment.id);
1783
+ * ```
1784
+ *
1785
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/post_tracks__track_id__comments
1786
+ */
405
1787
  declare const createTrackComment: (token: string, trackId: string | number, body: string, timestamp?: number) => Promise<SoundCloudComment>;
406
1788
 
1789
+ /**
1790
+ * Fetch users who have liked (favorited) a track.
1791
+ *
1792
+ * @param token - OAuth access token
1793
+ * @param trackId - The track's numeric ID or URN
1794
+ * @param limit - Maximum number of users per page
1795
+ * @returns Paginated list of users who liked the track
1796
+ * @throws {SoundCloudError} When the API returns an error
1797
+ *
1798
+ * @example
1799
+ * ```ts
1800
+ * import { getTrackLikes } from 'tsd-soundcloud';
1801
+ *
1802
+ * const result = await getTrackLikes(token, 123456, 50);
1803
+ * result.collection.forEach(u => console.log(u.username));
1804
+ * ```
1805
+ *
1806
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__favoriters
1807
+ */
407
1808
  declare const getTrackLikes: (token: string, trackId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
408
1809
 
1810
+ /**
1811
+ * Fetch users who have reposted a track.
1812
+ *
1813
+ * @param token - OAuth access token
1814
+ * @param trackId - The track's numeric ID or URN
1815
+ * @param limit - Maximum number of users per page
1816
+ * @returns Paginated list of users who reposted the track
1817
+ * @throws {SoundCloudError} When the API returns an error
1818
+ *
1819
+ * @example
1820
+ * ```ts
1821
+ * import { getTrackReposts } from 'tsd-soundcloud';
1822
+ *
1823
+ * const result = await getTrackReposts(token, 123456, 50);
1824
+ * result.collection.forEach(u => console.log(u.username));
1825
+ * ```
1826
+ *
1827
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__reposters
1828
+ */
409
1829
  declare const getTrackReposts: (token: string, trackId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
410
1830
 
1831
+ /**
1832
+ * Fetch tracks related to a given track.
1833
+ *
1834
+ * @param token - OAuth access token
1835
+ * @param trackId - The track's numeric ID or URN
1836
+ * @param limit - Maximum number of related tracks to return
1837
+ * @returns Array of related tracks
1838
+ * @throws {SoundCloudError} When the API returns an error
1839
+ *
1840
+ * @example
1841
+ * ```ts
1842
+ * import { getRelatedTracks } from 'tsd-soundcloud';
1843
+ *
1844
+ * const related = await getRelatedTracks(token, 123456, 5);
1845
+ * related.forEach(t => console.log(t.title));
1846
+ * ```
1847
+ *
1848
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__related
1849
+ */
411
1850
  declare const getRelatedTracks: (token: string, trackId: string | number, limit?: number) => Promise<SoundCloudTrack[]>;
412
1851
 
413
- /** GET /tracks/:id/streams — returns streamable URLs */
1852
+ /**
1853
+ * Fetch stream URLs for a track (HLS, MP3, preview).
1854
+ *
1855
+ * @param token - OAuth access token
1856
+ * @param trackId - The track's numeric ID or URN
1857
+ * @returns Object containing available stream URLs
1858
+ * @throws {SoundCloudError} When the track is not found or not streamable
1859
+ *
1860
+ * @example
1861
+ * ```ts
1862
+ * import { getTrackStreams } from 'tsd-soundcloud';
1863
+ *
1864
+ * const streams = await getTrackStreams(token, 123456);
1865
+ * console.log(streams.hls_mp3_128_url);
1866
+ * ```
1867
+ *
1868
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__streams
1869
+ */
414
1870
  declare const getTrackStreams: (token: string, trackId: string | number) => Promise<SoundCloudStreams>;
415
1871
 
1872
+ /**
1873
+ * Like (favorite) a track as the authenticated user.
1874
+ *
1875
+ * @param token - OAuth access token
1876
+ * @param trackId - The track's numeric ID or URN
1877
+ * @returns `true` if the like was successful, `false` on failure
1878
+ *
1879
+ * @example
1880
+ * ```ts
1881
+ * import { likeTrack } from 'tsd-soundcloud';
1882
+ *
1883
+ * const success = await likeTrack(token, 123456);
1884
+ * ```
1885
+ *
1886
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_tracks__track_id_
1887
+ */
416
1888
  declare const likeTrack: (token: string, trackId: string | number) => Promise<boolean>;
417
1889
 
418
- /** DELETE /likes/tracks/:id — unlikes a track */
1890
+ /**
1891
+ * Unlike (unfavorite) a track as the authenticated user.
1892
+ *
1893
+ * @param token - OAuth access token
1894
+ * @param trackId - The track's numeric ID or URN
1895
+ * @returns `true` if the unlike was successful, `false` on failure
1896
+ *
1897
+ * @example
1898
+ * ```ts
1899
+ * import { unlikeTrack } from 'tsd-soundcloud';
1900
+ *
1901
+ * const success = await unlikeTrack(token, 123456);
1902
+ * ```
1903
+ *
1904
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_tracks__track_id_
1905
+ */
419
1906
  declare const unlikeTrack: (token: string, trackId: string | number) => Promise<boolean>;
420
1907
 
421
- /** DELETE /tracks/:id — deletes a track */
1908
+ /**
1909
+ * Delete a track.
1910
+ *
1911
+ * @param token - OAuth access token
1912
+ * @param trackId - The track's numeric ID or URN
1913
+ * @throws {SoundCloudError} When the API returns an error
1914
+ *
1915
+ * @example
1916
+ * ```ts
1917
+ * import { deleteTrack } from 'tsd-soundcloud';
1918
+ *
1919
+ * await deleteTrack(token, 123456);
1920
+ * ```
1921
+ *
1922
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/delete_tracks__track_id_
1923
+ */
422
1924
  declare const deleteTrack: (token: string, trackId: string | number) => Promise<void>;
423
1925
 
1926
+ /**
1927
+ * Fetch a playlist by ID.
1928
+ *
1929
+ * @param token - OAuth access token
1930
+ * @param playlistId - The playlist's numeric ID or URN
1931
+ * @returns The playlist object with track data
1932
+ * @throws {SoundCloudError} When the playlist is not found or the API returns an error
1933
+ *
1934
+ * @example
1935
+ * ```ts
1936
+ * import { getPlaylist } from 'tsd-soundcloud';
1937
+ *
1938
+ * const playlist = await getPlaylist(token, 123456);
1939
+ * console.log(playlist.title, playlist.track_count);
1940
+ * ```
1941
+ *
1942
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id_
1943
+ */
424
1944
  declare const getPlaylist: (token: string, playlistId: string | number) => Promise<SoundCloudPlaylist>;
425
1945
 
1946
+ /**
1947
+ * Fetch tracks in a playlist.
1948
+ *
1949
+ * @param token - OAuth access token
1950
+ * @param playlistId - The playlist's numeric ID or URN
1951
+ * @param limit - Maximum number of tracks per page
1952
+ * @param offset - Number of tracks to skip (for offset-based pagination)
1953
+ * @returns Paginated list of tracks
1954
+ * @throws {SoundCloudError} When the API returns an error
1955
+ *
1956
+ * @example
1957
+ * ```ts
1958
+ * import { getPlaylistTracks } from 'tsd-soundcloud';
1959
+ *
1960
+ * const result = await getPlaylistTracks(token, 123456, 25);
1961
+ * result.collection.forEach(t => console.log(t.title));
1962
+ * ```
1963
+ *
1964
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__tracks
1965
+ */
426
1966
  declare const getPlaylistTracks: (token: string, playlistId: string | number, limit?: number, offset?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
427
1967
 
1968
+ /**
1969
+ * Fetch users who have reposted a playlist.
1970
+ *
1971
+ * @param token - OAuth access token
1972
+ * @param playlistId - The playlist's numeric ID or URN
1973
+ * @param limit - Maximum number of users per page
1974
+ * @returns Paginated list of users who reposted the playlist
1975
+ * @throws {SoundCloudError} When the API returns an error
1976
+ *
1977
+ * @example
1978
+ * ```ts
1979
+ * import { getPlaylistReposts } from 'tsd-soundcloud';
1980
+ *
1981
+ * const result = await getPlaylistReposts(token, 123456, 50);
1982
+ * result.collection.forEach(u => console.log(u.username));
1983
+ * ```
1984
+ *
1985
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__reposters
1986
+ */
428
1987
  declare const getPlaylistReposts: (token: string, playlistId: string | number, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
429
1988
 
430
- /** DELETE /playlists/:id — deletes a playlist */
1989
+ /**
1990
+ * Delete a playlist.
1991
+ *
1992
+ * @param token - OAuth access token
1993
+ * @param playlistId - The playlist's numeric ID or URN
1994
+ * @throws {SoundCloudError} When the API returns an error
1995
+ *
1996
+ * @example
1997
+ * ```ts
1998
+ * import { deletePlaylist } from 'tsd-soundcloud';
1999
+ *
2000
+ * await deletePlaylist(token, 123456);
2001
+ * ```
2002
+ *
2003
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/delete_playlists__playlist_id_
2004
+ */
431
2005
  declare const deletePlaylist: (token: string, playlistId: string | number) => Promise<void>;
432
2006
 
2007
+ /**
2008
+ * Search for tracks by query string.
2009
+ *
2010
+ * @param token - OAuth access token
2011
+ * @param query - Search query text
2012
+ * @param pageNumber - Zero-based page number (10 results per page)
2013
+ * @returns Paginated list of matching tracks
2014
+ * @throws {SoundCloudError} When the API returns an error
2015
+ *
2016
+ * @example
2017
+ * ```ts
2018
+ * import { searchTracks } from 'tsd-soundcloud';
2019
+ *
2020
+ * const result = await searchTracks(token, 'lofi hip hop');
2021
+ * result.collection.forEach(t => console.log(t.title));
2022
+ * ```
2023
+ *
2024
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks
2025
+ */
433
2026
  declare const searchTracks: (token: string, query: string, pageNumber?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
434
2027
 
2028
+ /**
2029
+ * Search for users by query string.
2030
+ *
2031
+ * @param token - OAuth access token
2032
+ * @param query - Search query text
2033
+ * @param pageNumber - Zero-based page number (10 results per page)
2034
+ * @returns Paginated list of matching users
2035
+ * @throws {SoundCloudError} When the API returns an error
2036
+ *
2037
+ * @example
2038
+ * ```ts
2039
+ * import { searchUsers } from 'tsd-soundcloud';
2040
+ *
2041
+ * const result = await searchUsers(token, 'deadmau5');
2042
+ * result.collection.forEach(u => console.log(u.username));
2043
+ * ```
2044
+ *
2045
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users
2046
+ */
435
2047
  declare const searchUsers: (token: string, query: string, pageNumber?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
436
2048
 
2049
+ /**
2050
+ * Search for playlists by query string.
2051
+ *
2052
+ * @param token - OAuth access token
2053
+ * @param query - Search query text
2054
+ * @param pageNumber - Zero-based page number (10 results per page)
2055
+ * @returns Paginated list of matching playlists
2056
+ * @throws {SoundCloudError} When the API returns an error
2057
+ *
2058
+ * @example
2059
+ * ```ts
2060
+ * import { searchPlaylists } from 'tsd-soundcloud';
2061
+ *
2062
+ * const result = await searchPlaylists(token, 'chill vibes');
2063
+ * result.collection.forEach(p => console.log(p.title));
2064
+ * ```
2065
+ *
2066
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists
2067
+ */
437
2068
  declare const searchPlaylists: (token: string, query: string, pageNumber?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
438
2069
 
2070
+ /**
2071
+ * Resolve a SoundCloud URL to its API resource URL.
2072
+ *
2073
+ * SoundCloud returns a 302 redirect to the API resource; this function returns the redirect target URL.
2074
+ *
2075
+ * @param token - OAuth access token
2076
+ * @param url - A SoundCloud URL (e.g. "https://soundcloud.com/artist/track-name")
2077
+ * @returns The resolved API resource URL
2078
+ * @throws {SoundCloudError} When the URL cannot be resolved
2079
+ *
2080
+ * @example
2081
+ * ```ts
2082
+ * import { resolveUrl } from 'tsd-soundcloud';
2083
+ *
2084
+ * const apiUrl = await resolveUrl(token, 'https://soundcloud.com/deadmau5/strobe');
2085
+ * console.log(apiUrl); // "https://api.soundcloud.com/tracks/..."
2086
+ * ```
2087
+ *
2088
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/resolve/get_resolve
2089
+ */
439
2090
  declare const resolveUrl: (token: string, url: string) => Promise<string>;
440
2091
 
441
- /** GET /me/activities */
2092
+ /**
2093
+ * Fetch the authenticated user's activity feed.
2094
+ *
2095
+ * @param token - OAuth access token
2096
+ * @param limit - Maximum number of activities per page
2097
+ * @returns Activities response with `future_href` for polling
2098
+ * @throws {SoundCloudError} When the API returns an error
2099
+ *
2100
+ * @example
2101
+ * ```ts
2102
+ * import { getMeActivities } from 'tsd-soundcloud';
2103
+ *
2104
+ * const activities = await getMeActivities(token, 25);
2105
+ * activities.collection.forEach(a => console.log(a.type));
2106
+ * ```
2107
+ *
2108
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities
2109
+ */
442
2110
  declare const getMeActivities: (token: string, limit?: number) => Promise<SoundCloudActivitiesResponse>;
443
- /** GET /me/activities/all/own */
2111
+ /**
2112
+ * Fetch the authenticated user's own activities (uploads, reposts by the user).
2113
+ *
2114
+ * @param token - OAuth access token
2115
+ * @param limit - Maximum number of activities per page
2116
+ * @returns Activities response
2117
+ * @throws {SoundCloudError} When the API returns an error
2118
+ *
2119
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_all_own
2120
+ */
444
2121
  declare const getMeActivitiesOwn: (token: string, limit?: number) => Promise<SoundCloudActivitiesResponse>;
445
- /** GET /me/activities/tracks */
2122
+ /**
2123
+ * Fetch track-related activities in the authenticated user's feed.
2124
+ *
2125
+ * @param token - OAuth access token
2126
+ * @param limit - Maximum number of activities per page
2127
+ * @returns Activities response filtered to track activities
2128
+ * @throws {SoundCloudError} When the API returns an error
2129
+ *
2130
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_tracks
2131
+ */
446
2132
  declare const getMeActivitiesTracks: (token: string, limit?: number) => Promise<SoundCloudActivitiesResponse>;
447
2133
 
448
- /** GET /me/likes/tracks */
2134
+ /**
2135
+ * Fetch tracks liked by the authenticated user.
2136
+ *
2137
+ * @param token - OAuth access token
2138
+ * @param limit - Maximum number of tracks per page
2139
+ * @returns Paginated list of liked tracks
2140
+ * @throws {SoundCloudError} When the API returns an error
2141
+ *
2142
+ * @example
2143
+ * ```ts
2144
+ * import { getMeLikesTracks } from 'tsd-soundcloud';
2145
+ *
2146
+ * const result = await getMeLikesTracks(token, 50);
2147
+ * result.collection.forEach(t => console.log(t.title));
2148
+ * ```
2149
+ *
2150
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_tracks
2151
+ */
449
2152
  declare const getMeLikesTracks: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
450
- /** GET /me/likes/playlists */
2153
+ /**
2154
+ * Fetch playlists liked by the authenticated user.
2155
+ *
2156
+ * @param token - OAuth access token
2157
+ * @param limit - Maximum number of playlists per page
2158
+ * @returns Paginated list of liked playlists
2159
+ * @throws {SoundCloudError} When the API returns an error
2160
+ *
2161
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_playlists
2162
+ */
451
2163
  declare const getMeLikesPlaylists: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
452
2164
 
453
- /** GET /me/followings */
2165
+ /**
2166
+ * Fetch users the authenticated user is following.
2167
+ *
2168
+ * @param token - OAuth access token
2169
+ * @param limit - Maximum number of users per page
2170
+ * @returns Paginated list of followed users
2171
+ * @throws {SoundCloudError} When the API returns an error
2172
+ *
2173
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings
2174
+ */
454
2175
  declare const getMeFollowings: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
455
- /** GET /me/followings/tracks */
2176
+ /**
2177
+ * Fetch recent tracks from users the authenticated user is following.
2178
+ *
2179
+ * @param token - OAuth access token
2180
+ * @param limit - Maximum number of tracks per page
2181
+ * @returns Paginated list of tracks from followed users
2182
+ * @throws {SoundCloudError} When the API returns an error
2183
+ *
2184
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings_tracks
2185
+ */
456
2186
  declare const getMeFollowingsTracks: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
457
- /** PUT /me/followings/:user_urn — follow a user */
2187
+ /**
2188
+ * Follow a user as the authenticated user.
2189
+ *
2190
+ * @param token - OAuth access token
2191
+ * @param userUrn - The user's ID or URN to follow
2192
+ * @throws {SoundCloudError} When the API returns an error
2193
+ *
2194
+ * @example
2195
+ * ```ts
2196
+ * import { followUser } from 'tsd-soundcloud';
2197
+ *
2198
+ * await followUser(token, 123456);
2199
+ * ```
2200
+ *
2201
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/put_me_followings__user_id_
2202
+ */
458
2203
  declare const followUser: (token: string, userUrn: string | number) => Promise<void>;
459
- /** DELETE /me/followings/:user_urn — unfollow a user */
2204
+ /**
2205
+ * Unfollow a user as the authenticated user.
2206
+ *
2207
+ * @param token - OAuth access token
2208
+ * @param userUrn - The user's ID or URN to unfollow
2209
+ * @throws {SoundCloudError} When the API returns an error
2210
+ *
2211
+ * @example
2212
+ * ```ts
2213
+ * import { unfollowUser } from 'tsd-soundcloud';
2214
+ *
2215
+ * await unfollowUser(token, 123456);
2216
+ * ```
2217
+ *
2218
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/delete_me_followings__user_id_
2219
+ */
460
2220
  declare const unfollowUser: (token: string, userUrn: string | number) => Promise<void>;
461
2221
 
462
- /** GET /me/followers */
2222
+ /**
2223
+ * Fetch the authenticated user's followers.
2224
+ *
2225
+ * @param token - OAuth access token
2226
+ * @param limit - Maximum number of users per page
2227
+ * @returns Paginated list of follower users
2228
+ * @throws {SoundCloudError} When the API returns an error
2229
+ *
2230
+ * @example
2231
+ * ```ts
2232
+ * import { getMeFollowers } from 'tsd-soundcloud';
2233
+ *
2234
+ * const result = await getMeFollowers(token, 50);
2235
+ * result.collection.forEach(u => console.log(u.username));
2236
+ * ```
2237
+ *
2238
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followers
2239
+ */
463
2240
  declare const getMeFollowers: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudUser>>;
464
2241
 
465
- /** GET /me/playlists */
2242
+ /**
2243
+ * Fetch the authenticated user's playlists.
2244
+ *
2245
+ * @param token - OAuth access token
2246
+ * @param limit - Maximum number of playlists per page
2247
+ * @returns Paginated list of playlists
2248
+ * @throws {SoundCloudError} When the API returns an error
2249
+ *
2250
+ * @example
2251
+ * ```ts
2252
+ * import { getMePlaylists } from 'tsd-soundcloud';
2253
+ *
2254
+ * const result = await getMePlaylists(token, 10);
2255
+ * result.collection.forEach(p => console.log(p.title));
2256
+ * ```
2257
+ *
2258
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_playlists
2259
+ */
466
2260
  declare const getMePlaylists: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudPlaylist>>;
467
2261
 
468
2262
  /** GET /me/tracks */
469
2263
  declare const getMeTracks: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
470
2264
 
471
- /** POST /likes/playlists/:id */
2265
+ /**
2266
+ * Like a playlist as the authenticated user.
2267
+ *
2268
+ * @param token - OAuth access token
2269
+ * @param playlistId - The playlist's numeric ID or URN
2270
+ * @returns `true` if the like was successful, `false` on failure
2271
+ *
2272
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_playlists__playlist_id_
2273
+ */
472
2274
  declare const likePlaylist: (token: string, playlistId: string | number) => Promise<boolean>;
473
- /** DELETE /likes/playlists/:id */
2275
+ /**
2276
+ * Unlike a playlist as the authenticated user.
2277
+ *
2278
+ * @param token - OAuth access token
2279
+ * @param playlistId - The playlist's numeric ID or URN
2280
+ * @returns `true` if the unlike was successful, `false` on failure
2281
+ *
2282
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_playlists__playlist_id_
2283
+ */
474
2284
  declare const unlikePlaylist: (token: string, playlistId: string | number) => Promise<boolean>;
475
2285
 
476
- /** POST /reposts/tracks/:id */
2286
+ /**
2287
+ * Repost a track to your profile.
2288
+ *
2289
+ * @param token - OAuth access token
2290
+ * @param trackId - The track's numeric ID or URN
2291
+ * @returns `true` if the repost was successful, `false` on failure
2292
+ *
2293
+ * @example
2294
+ * ```ts
2295
+ * import { repostTrack } from 'tsd-soundcloud';
2296
+ *
2297
+ * const success = await repostTrack(token, 123456);
2298
+ * ```
2299
+ *
2300
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_tracks__track_id_
2301
+ */
477
2302
  declare const repostTrack: (token: string, trackId: string | number) => Promise<boolean>;
478
- /** DELETE /reposts/tracks/:id */
2303
+ /**
2304
+ * Remove a track repost from your profile.
2305
+ *
2306
+ * @param token - OAuth access token
2307
+ * @param trackId - The track's numeric ID or URN
2308
+ * @returns `true` if the unrepost was successful, `false` on failure
2309
+ *
2310
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_tracks__track_id_
2311
+ */
479
2312
  declare const unrepostTrack: (token: string, trackId: string | number) => Promise<boolean>;
480
- /** POST /reposts/playlists/:id */
2313
+ /**
2314
+ * Repost a playlist to your profile.
2315
+ *
2316
+ * @param token - OAuth access token
2317
+ * @param playlistId - The playlist's numeric ID or URN
2318
+ * @returns `true` if the repost was successful, `false` on failure
2319
+ *
2320
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_playlists__playlist_id_
2321
+ */
481
2322
  declare const repostPlaylist: (token: string, playlistId: string | number) => Promise<boolean>;
482
- /** DELETE /reposts/playlists/:id */
2323
+ /**
2324
+ * Remove a playlist repost from your profile.
2325
+ *
2326
+ * @param token - OAuth access token
2327
+ * @param playlistId - The playlist's numeric ID or URN
2328
+ * @returns `true` if the unrepost was successful, `false` on failure
2329
+ *
2330
+ * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_playlists__playlist_id_
2331
+ */
483
2332
  declare const unrepostPlaylist: (token: string, playlistId: string | number) => Promise<boolean>;
484
2333
 
485
2334
  /**
@@ -487,4 +2336,4 @@ declare const unrepostPlaylist: (token: string, playlistId: string | number) =>
487
2336
  */
488
2337
  declare const getSoundCloudWidgetUrl: (trackId: string | number) => string;
489
2338
 
490
- export { type CreatePlaylistParams, type RequestOptions, SoundCloudActivitiesResponse, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
2339
+ export { type CreatePlaylistParams, type RequestOptions, type RetryConfig, SoundCloudActivitiesResponse, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };