import { S as SoundCloudTrack, a as SoundCloudPlaylist, b as SoundCloudToken, c as SoundCloudPaginatedResponse, d as SoundCloudMe, e as SoundCloudActivitiesResponse, f as SoundCloudUser, g as SoundCloudConnection, h as SoundCloudWebProfile, i as SoundCloudStreams, j as SoundCloudComment } from './index-DX6Anc1-.mjs'; export { k as SoundCloudActivity, l as SoundCloudCommentUser, m as SoundCloudError, n as SoundCloudQuota, o as SoundCloudSubscription, p as SoundCloudSubscriptionProduct } from './index-DX6Anc1-.mjs'; /** * Deduplicates concurrent in-flight requests with the same key. * * When multiple callers request the same resource simultaneously, * only one underlying promise is created — all callers share the result. * The key is cleaned up automatically once the promise settles. * * @example * ```ts * const deduper = new InFlightDeduper(); * * // Both calls share a single fetch: * const [a, b] = await Promise.all([ * deduper.add('track:123', () => fetchTrack(123)), * deduper.add('track:123', () => fetchTrack(123)), * ]); * // a === b (same resolved value) * ``` */ declare class InFlightDeduper { private inFlight; /** * Return an existing in-flight promise for `key`, or start a new one via `factory`. * The entry is removed from the map once the promise settles (resolve or reject). */ add(key: string, factory: () => Promise): Promise; /** Number of currently in-flight requests */ get size(): number; } /** * A cache entry with an expiration timestamp. */ interface SoundCloudCacheEntry { /** The cached value */ value: T; /** Unix timestamp (ms) when this entry expires */ expiresAt: number; } /** * Cache interface for SoundCloud API responses. * * Implement this interface to plug in any caching backend (in-memory, Redis, etc.). * Pass an instance as `cache` in {@link SoundCloudClientConfig} to enable caching. * * @example * ```ts * // Simple in-memory implementation * class SimpleCache implements SoundCloudCache { * private store = new Map>(); * * get(key: string): T | undefined { * const entry = this.store.get(key) as SoundCloudCacheEntry | undefined; * if (!entry || Date.now() > entry.expiresAt) return undefined; * return entry.value; * } * * set(key: string, value: T, { ttlMs }: { ttlMs: number }): void { * this.store.set(key, { value, expiresAt: Date.now() + ttlMs }); * } * * delete(key: string): void { * this.store.delete(key); * } * } * ``` */ interface SoundCloudCache { /** Retrieve a cached value by key, or `undefined` if missing or expired */ get(key: string): Promise | T | undefined; /** Store a value with a TTL in milliseconds */ set(key: string, value: T, options: { ttlMs: number; }): Promise | void; /** Remove a cached entry */ delete(key: string): Promise | void; } /** * Options for making a request to the SoundCloud API via {@link scFetch}. */ interface RequestOptions { /** API path relative to `https://api.soundcloud.com` (e.g. "/tracks/123"). Paths starting with `/oauth` are routed to `https://secure.soundcloud.com`. */ path: string; /** HTTP method */ method: "GET" | "POST" | "PUT" | "DELETE"; /** OAuth access token to include in the Authorization header */ token?: string; /** Request body — automatically serialized based on type */ body?: Record | FormData | URLSearchParams; /** Additional headers to include in the request */ headers?: Record; /** Override the Content-Type header (defaults to "application/json" for object bodies) */ contentType?: string; } /** * Structured telemetry emitted after every API request. */ interface SCRequestTelemetry { /** HTTP method used */ method: "GET" | "POST" | "PUT" | "DELETE"; /** API path or full URL */ path: string; /** Total duration including retries, in milliseconds */ durationMs: number; /** Final HTTP status code */ status: number; /** Number of retries performed (0 = succeeded on first attempt) */ retryCount: number; /** Error message if the request ultimately failed */ error?: string; } /** * Information passed to the `onRetry` callback on each retry attempt. */ interface RetryInfo { /** Which retry attempt this is (1-based) */ attempt: number; /** Delay in milliseconds before this retry fires */ delayMs: number; /** Human-readable reason (e.g. "429 Too Many Requests") */ reason: string; /** HTTP status that triggered the retry, if applicable */ status?: number; /** The URL that was requested */ url: string; } /** * Configuration for automatic retry with exponential backoff on transient errors. */ interface RetryConfig { /** Maximum number of retries on 429/5xx responses (default: 3) */ maxRetries: number; /** Base delay in milliseconds for exponential backoff (default: 1000) */ retryBaseDelay: number; /** Optional callback for debug logging of retry attempts */ onDebug?: (message: string) => void; /** Optional callback fired before each retry with structured retry info */ onRetry?: (info: RetryInfo) => void; } /** * Context for automatic token refresh when a request returns 401 Unauthorized. * Used internally by {@link SoundCloudClient} to transparently refresh expired tokens. */ interface AutoRefreshContext { /** Returns the current stored access token */ getToken: () => string | undefined; /** Called to obtain fresh tokens; if absent, 401 errors are thrown directly */ onTokenRefresh?: () => Promise<{ access_token: string; refresh_token?: string; }>; /** Callback to store the new tokens after a successful refresh */ setToken: (accessToken: string, refreshToken?: string) => void; /** Retry configuration for this context */ retry?: RetryConfig; /** Called after every API request with structured telemetry */ onRequest?: (telemetry: SCRequestTelemetry) => void; /** Custom fetch implementation (defaults to `globalThis.fetch`) */ fetchImpl?: typeof globalThis.fetch; /** Deduplicates concurrent identical GET requests when set */ deduper?: InFlightDeduper; /** Optional cache backend for GET responses */ cache?: SoundCloudCache; /** TTL in milliseconds for cached GET responses (default: 60000) */ cacheTtlMs?: number; } /** * Make a request to the SoundCloud API using native `fetch`. * * Handles JSON serialization, OAuth headers, automatic retries on 429/5xx, * and optional automatic token refresh on 401. For 302 redirects, returns * the `Location` header value. For 204 responses, returns `undefined`. * * @param options - Request configuration (path, method, token, body) * @param refreshCtx - Optional auto-refresh context for transparent token renewal * @returns Parsed JSON response, redirect URL, or undefined for empty responses * @throws {SoundCloudError} When the API returns a non-retryable error status * * @example * ```ts * import { scFetch } from 'soundcloud-api-ts'; * * const track = await scFetch({ * path: '/tracks/123456', * method: 'GET', * token: 'your-access-token', * }); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api */ declare function scFetch(options: RequestOptions, refreshCtx?: AutoRefreshContext, onRequest?: (telemetry: SCRequestTelemetry) => void): Promise; /** * Fetch an absolute URL (e.g. `next_href` from paginated responses). * * Used internally for pagination — follows the same retry logic as {@link scFetch}. * * @param url - Absolute URL to fetch (typically a `next_href` value) * @param token - OAuth access token to include in the Authorization header * @param retryConfig - Optional retry configuration override * @returns Parsed JSON response * @throws {SoundCloudError} When the API returns a non-retryable error status * * @example * ```ts * import { scFetchUrl } from 'soundcloud-api-ts'; * * const nextPage = await scFetchUrl>( * response.next_href, * 'your-access-token', * ); * ``` */ declare function scFetchUrl(url: string, token?: string, retryConfig?: RetryConfig, onRequest?: (telemetry: SCRequestTelemetry) => void, fetchImpl?: typeof globalThis.fetch): Promise; /** * Raw response from the SoundCloud API, including status code and headers. */ type RawResponse = { /** Parsed response body */ data: T; /** HTTP status code */ status: number; /** Response headers as a plain object */ headers: Record; }; /** * Low-level HTTP client that returns raw responses without throwing on non-2xx status codes. * Useful when you need access to status codes, headers, or want to handle errors manually. * * @example * ```ts * const raw = sc.raw; * const res = await raw.get('/tracks/123456'); * console.log(res.status, res.headers, res.data); * ``` */ declare class RawClient { private baseUrl; private getToken; private fetchFn; constructor(baseUrl: string, getToken: () => string | undefined, fetchFn: typeof fetch); /** * Make a raw HTTP request. Path template placeholders like `{id}` are substituted * from matching keys in `query` before the remaining query params are appended to * the URL as search parameters. */ request({ method, path, query, body, token, }: { method: string; path: string; query?: Record; body?: unknown; token?: string; }): Promise>; /** GET shorthand */ get(path: string, params?: Record): Promise>; /** POST shorthand */ post(path: string, body?: unknown): Promise>; /** PUT shorthand */ put(path: string, body?: unknown): Promise>; /** DELETE shorthand */ delete(path: string): Promise>; } /** * Parameters for updating a track's metadata via {@link updateTrack}. */ interface UpdateTrackParams { /** New track title */ title?: string; /** New track description */ description?: string; /** Music genre (e.g. "Electronic", "Hip-hop & Rap") */ genre?: string; /** Space-separated tags (tags with spaces should be wrapped in quotes) */ tag_list?: string; /** Visibility: "public" or "private" */ sharing?: "public" | "private"; /** Whether the track is downloadable */ downloadable?: boolean; /** External purchase URL */ purchase_url?: string; /** Label for the purchase/buy button */ purchase_title?: string; /** Release identifier string */ release?: string; /** Day of the release date (1-31) */ release_day?: number; /** Month of the release date (1-12) */ release_month?: number; /** Year of the release date */ release_year?: number; /** Record label name */ label_name?: string; /** Creative Commons license type (e.g. "all-rights-reserved", "cc-by") */ license?: string; /** International Standard Recording Code */ isrc?: string; /** Beats per minute */ bpm?: number; /** Musical key signature (e.g. "C major") */ key_signature?: string; } /** * Update a track's metadata. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @param params - Fields to update * @returns The updated track object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { updateTrack } from 'soundcloud-api-ts'; * * const updated = await updateTrack(token, 123456, { * title: 'New Title', * genre: 'Electronic', * }); * console.log(updated.title); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/put_tracks__track_id_ */ declare const updateTrack: (token: string, trackId: string | number, params: UpdateTrackParams) => Promise; /** * Parameters for creating a new playlist via {@link createPlaylist}. */ interface CreatePlaylistParams { /** Playlist title (required) */ title: string; /** Playlist description */ description?: string; /** Visibility: "public" or "private" */ sharing?: "public" | "private"; /** Tracks to include, specified by URN (e.g. `[{ urn: "soundcloud:tracks:123" }]`) */ tracks?: { urn: string; }[]; /** European Article Number (barcode) for the release */ ean?: string; /** Music genre */ genre?: string; /** Record label name */ label_name?: string; /** Creative Commons license type */ license?: string; /** Custom permalink slug */ permalink?: string; /** Label for the purchase/buy button */ purchase_title?: string; /** External purchase URL */ purchase_url?: string; /** Release identifier string */ release?: string; /** Release date in ISO 8601 format */ release_date?: string; /** Set type: "album" or "playlist" */ set_type?: "album" | "playlist"; /** Space-separated tags */ tag_list?: string; } /** * Create a new playlist. * * @param token - OAuth access token * @param params - Playlist creation parameters (title is required) * @returns The created playlist object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { createPlaylist } from 'soundcloud-api-ts'; * * const playlist = await createPlaylist(token, { * title: 'My Favorites', * sharing: 'public', * tracks: [{ urn: 'soundcloud:tracks:123' }], * }); * console.log(playlist.id, playlist.title); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/post_playlists */ declare const createPlaylist: (token: string, params: CreatePlaylistParams) => Promise; /** * Parameters for updating a playlist via {@link updatePlaylist}. */ interface UpdatePlaylistParams { /** New playlist title */ title?: string; /** New playlist description */ description?: string; /** Visibility: "public" or "private" */ sharing?: "public" | "private"; /** Replace the playlist's tracks (specified by URN) */ tracks?: { urn: string; }[]; /** European Article Number (barcode) */ ean?: string; /** Music genre */ genre?: string; /** Record label name */ label_name?: string; /** Creative Commons license type */ license?: string; /** Custom permalink slug */ permalink?: string; /** Label for the purchase/buy button */ purchase_title?: string; /** External purchase URL */ purchase_url?: string; /** Release identifier string */ release?: string; /** Release date in ISO 8601 format */ release_date?: string; /** Set type: "album" or "playlist" */ set_type?: "album" | "playlist"; /** Space-separated tags */ tag_list?: string; } /** * Update a playlist's metadata or track list. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @param params - Fields to update * @returns The updated playlist object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { updatePlaylist } from 'soundcloud-api-ts'; * * const updated = await updatePlaylist(token, 123456, { * title: 'Updated Title', * tracks: [{ urn: 'soundcloud:tracks:111' }, { urn: 'soundcloud:tracks:222' }], * }); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/put_playlists__playlist_id_ */ declare const updatePlaylist: (token: string, playlistId: string | number, params: UpdatePlaylistParams) => Promise; /** * Configuration options for creating a {@link SoundCloudClient} instance. */ interface SoundCloudClientConfig { /** Your SoundCloud application's OAuth client ID */ clientId: string; /** Your SoundCloud application's OAuth client secret */ clientSecret: string; /** OAuth redirect URI registered with your SoundCloud application (required for user auth flows) */ redirectUri?: string; /** * Called automatically when a request returns 401 Unauthorized. * Return new tokens to transparently retry the failed request. */ onTokenRefresh?: (client: SoundCloudClient) => Promise; /** Maximum number of retries on 429 (rate limit) and 5xx (server error) responses (default: 3) */ maxRetries?: number; /** Base delay in milliseconds for exponential backoff between retries (default: 1000) */ retryBaseDelay?: number; /** Optional debug logger callback for retry attempts and other internal events */ onDebug?: (message: string) => void; /** Called after every API request with structured telemetry (timing, status, retries) */ onRequest?: (telemetry: SCRequestTelemetry) => void; /** Custom fetch implementation (defaults to `globalThis.fetch`) */ fetch?: typeof globalThis.fetch; /** Deduplicate concurrent identical GET requests (default: true) */ dedupe?: boolean; /** Optional cache backend for GET responses */ cache?: SoundCloudCache; /** Default TTL in milliseconds for cached GET responses (default: 60000) */ cacheTtlMs?: number; /** Called before each retry attempt with structured retry info */ onRetry?: (info: RetryInfo) => void; } /** * Optional token override that can be passed as the last parameter to client methods. * When provided, the explicit token is used instead of the client's stored token. */ interface TokenOption { /** OAuth access token to use for this specific request */ token?: string; } /** Resolve a token: use explicit override, fall back to stored, or throw. */ type TokenGetter = () => string | undefined; /** * High-level SoundCloud API client with namespaced methods for all API areas. * * Provides automatic token management, retry with exponential backoff, * optional automatic token refresh on 401, and built-in pagination helpers. * * @example * ```ts * import { SoundCloudClient } from 'soundcloud-api-ts'; * * const sc = new SoundCloudClient({ * clientId: 'YOUR_CLIENT_ID', * clientSecret: 'YOUR_CLIENT_SECRET', * redirectUri: 'https://example.com/callback', * }); * * // Authenticate * const token = await sc.auth.getClientToken(); * sc.setToken(token.access_token); * * // Use the API * const track = await sc.tracks.getTrack(123456); * console.log(track.title); * * // Search with pagination * for await (const track of sc.paginateItems(() => sc.search.tracks('lofi'))) { * console.log(track.title); * } * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api */ declare class SoundCloudClient { private config; private _accessToken?; private _refreshToken?; /** Authentication methods (OAuth token grants, sign out) */ auth: SoundCloudClient.Auth; /** Authenticated user endpoints (/me) */ me: SoundCloudClient.Me; /** User profile endpoints (/users) */ users: SoundCloudClient.Users; /** Track endpoints (/tracks) */ tracks: SoundCloudClient.Tracks; /** Playlist endpoints (/playlists) */ playlists: SoundCloudClient.Playlists; /** Search endpoints */ search: SoundCloudClient.Search; /** URL resolution endpoint (/resolve) */ resolve: SoundCloudClient.Resolve; /** Like/unlike actions (/likes) */ likes: SoundCloudClient.Likes; /** Repost/unrepost actions (/reposts) */ reposts: SoundCloudClient.Reposts; /** Low-level raw HTTP client — returns status/headers without throwing on non-2xx */ raw: RawClient; /** * Creates a new SoundCloudClient instance. * * @param config - Client configuration including OAuth credentials and optional settings */ constructor(config: SoundCloudClientConfig); /** * Store an access token (and optionally refresh token) on this client instance. * * @param accessToken - The OAuth access token to store * @param refreshToken - Optional refresh token for automatic token renewal */ setToken(accessToken: string, refreshToken?: string): void; /** Clear all stored tokens from this client instance. */ clearToken(): void; /** Get the currently stored access token, or `undefined` if none is set. */ get accessToken(): string | undefined; /** Get the currently stored refresh token, or `undefined` if none is set. */ get refreshToken(): string | undefined; /** * Async generator that follows `next_href` automatically, yielding each page's `collection`. * * @param firstPage - Function that fetches the first page * @returns An async generator yielding arrays of items (one per page) * * @example * ```ts * for await (const page of sc.paginate(() => sc.search.tracks('lofi'))) { * console.log(page); // SoundCloudTrack[] * } * ``` */ paginate(firstPage: () => Promise>): AsyncGenerator; /** * Async generator that yields individual items across all pages. * * @param firstPage - Function that fetches the first page * @returns An async generator yielding individual items * * @example * ```ts * for await (const track of sc.paginateItems(() => sc.search.tracks('lofi'))) { * console.log(track.title); // single SoundCloudTrack * } * ``` */ paginateItems(firstPage: () => Promise>): AsyncGenerator; /** * Collects all pages into a single flat array. * * @param firstPage - Function that fetches the first page * @param options - Optional configuration * @param options.maxItems - Maximum number of items to collect * @returns A promise resolving to a flat array of all items * * @example * ```ts * const allTracks = await sc.fetchAll(() => sc.search.tracks('lofi'), { maxItems: 100 }); * console.log(allTracks.length); * ``` */ fetchAll(firstPage: () => Promise>, options?: { maxItems?: number; }): Promise; } declare namespace SoundCloudClient { /** * Authentication namespace — OAuth token grants and session management. * * @example * ```ts * const token = await sc.auth.getClientToken(); * sc.setToken(token.access_token); * ``` */ class Auth { private config; constructor(config: SoundCloudClientConfig); private fetch; /** * Build the authorization URL to redirect users to SoundCloud's OAuth login page. * * @param options - Optional parameters for the authorization request * @param options.state - Opaque state value for CSRF protection * @param options.codeChallenge - PKCE S256 code challenge for enhanced security * @returns The full authorization URL to redirect the user to * @throws {Error} If `redirectUri` was not provided in the client config * * @example * ```ts * const url = sc.auth.getAuthorizationUrl({ state: 'random-state' }); * // Redirect user to `url` * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2 */ getAuthorizationUrl(options?: { state?: string; codeChallenge?: string; }): string; /** * Exchange client credentials for an access token (machine-to-machine auth). * * @returns The OAuth token response * @throws {SoundCloudError} When authentication fails * * @example * ```ts * const token = await sc.auth.getClientToken(); * sc.setToken(token.access_token); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token */ getClientToken(): Promise; /** * Exchange an authorization code for user tokens (authorization_code grant). * * @param code - The authorization code received from the OAuth callback * @param codeVerifier - PKCE code verifier if a code challenge was used * @returns The OAuth token response including access and refresh tokens * @throws {SoundCloudError} When the code is invalid or expired * * @example * ```ts * const token = await sc.auth.getUserToken(code, codeVerifier); * sc.setToken(token.access_token, token.refresh_token); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token */ getUserToken(code: string, codeVerifier?: string): Promise; /** * Refresh an expired access token using a refresh token. * * @param refreshToken - The refresh token from a previous token response * @returns A new OAuth token response with fresh access and refresh tokens * @throws {SoundCloudError} When the refresh token is invalid or expired * * @example * ```ts * const newToken = await sc.auth.refreshUserToken(sc.refreshToken!); * sc.setToken(newToken.access_token, newToken.refresh_token); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token */ refreshUserToken(refreshToken: string): Promise; /** * Invalidate the session associated with an access token. * * **Note:** This hits `https://secure.soundcloud.com`, NOT the regular * `api.soundcloud.com` host used by all other endpoints. * * @param accessToken - The access token to invalidate * @throws {Error} When the sign-out request fails * * @example * ```ts * await sc.auth.signOut(sc.accessToken!); * sc.clearToken(); * ``` */ signOut(accessToken: string): Promise; } /** * Authenticated user namespace — endpoints for the currently logged-in user (/me). * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me */ class Me { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Get the authenticated user's profile. * * @param options - Optional token override * @returns The authenticated user's full profile * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const me = await sc.me.getMe(); * console.log(me.username, me.followers_count); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me */ getMe(options?: TokenOption): Promise; /** * Get the authenticated user's activity feed. * * @param limit - Maximum number of activities per page * @param options - Optional token override * @returns Paginated activities response with `future_href` for polling * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const activities = await sc.me.getActivities(25); * activities.collection.forEach(a => console.log(a.type, a.created_at)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities */ getActivities(limit?: number, options?: TokenOption): Promise; /** * Get the authenticated user's own activities (uploads, reposts). * * @param limit - Maximum number of activities per page * @param options - Optional token override * @returns Paginated activities response * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_all_own */ getActivitiesOwn(limit?: number, options?: TokenOption): Promise; /** * Get track-related activities in the authenticated user's feed. * * @param limit - Maximum number of activities per page * @param options - Optional token override * @returns Paginated activities response filtered to track activities * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_tracks */ getActivitiesTracks(limit?: number, options?: TokenOption): Promise; /** * Get tracks liked by the authenticated user. * * @param limit - Maximum number of tracks per page * @param options - Optional token override * @returns Paginated list of liked tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const likes = await sc.me.getLikesTracks(50); * likes.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_tracks */ getLikesTracks(limit?: number, options?: TokenOption): Promise>; /** * Get playlists liked by the authenticated user. * * @param limit - Maximum number of playlists per page * @param options - Optional token override * @returns Paginated list of liked playlists * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_playlists */ getLikesPlaylists(limit?: number, options?: TokenOption): Promise>; /** * Get users the authenticated user is following. * * @param limit - Maximum number of users per page * @param options - Optional token override * @returns Paginated list of followed users * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings */ getFollowings(limit?: number, options?: TokenOption): Promise>; /** * Get recent tracks from users the authenticated user is following. * * @param limit - Maximum number of tracks per page * @param options - Optional token override * @returns Paginated list of tracks from followed users * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings_tracks */ getFollowingsTracks(limit?: number, options?: TokenOption): Promise>; /** * Follow a user. * * @param userUrn - The user's ID or URN to follow * @param options - Optional token override * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * await sc.me.follow(123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/put_me_followings__user_id_ */ follow(userUrn: string | number, options?: TokenOption): Promise; /** * Unfollow a user. * * @param userUrn - The user's ID or URN to unfollow * @param options - Optional token override * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * await sc.me.unfollow(123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/delete_me_followings__user_id_ */ unfollow(userUrn: string | number, options?: TokenOption): Promise; /** * Get the authenticated user's followers. * * @param limit - Maximum number of users per page * @param options - Optional token override * @returns Paginated list of follower users * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followers */ getFollowers(limit?: number, options?: TokenOption): Promise>; /** * Get the authenticated user's playlists. * * @param limit - Maximum number of playlists per page * @param options - Optional token override * @returns Paginated list of playlists * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_playlists */ getPlaylists(limit?: number, options?: TokenOption): Promise>; /** * Get the authenticated user's tracks. * * @param limit - Maximum number of tracks per page * @param options - Optional token override * @returns Paginated list of tracks * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_tracks */ getTracks(limit?: number, options?: TokenOption): Promise>; /** * List the authenticated user's connected external social accounts. * * @param options - Optional token override * @returns Array of connection objects for linked social services (Twitter, Facebook, etc.) * @throws {SoundCloudError} When the API returns an error * * @remarks This endpoint may require elevated API access or app approval. * * @example * ```ts * const connections = await sc.me.getConnections(); * connections.forEach(c => console.log(c.service, c.display_name)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_connections */ getConnections(options?: TokenOption): Promise; } /** * User profile namespace — fetch public user data. * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users */ class Users { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Get a user's profile by ID. * * @param userId - The user's numeric ID or URN * @param options - Optional token override * @returns The user's public profile * @throws {SoundCloudError} When the user is not found or the API returns an error * * @example * ```ts * const user = await sc.users.getUser(123456); * console.log(user.username, user.followers_count); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id_ */ getUser(userId: string | number, options?: TokenOption): Promise; /** * Get a user's followers. * * @param userId - The user's numeric ID or URN * @param limit - Maximum number of followers per page * @param options - Optional token override * @returns Paginated list of follower users * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followers */ getFollowers(userId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Get users that a user is following. * * @param userId - The user's numeric ID or URN * @param limit - Maximum number of users per page * @param options - Optional token override * @returns Paginated list of followed users * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followings */ getFollowings(userId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Get a user's public tracks. * * @param userId - The user's numeric ID or URN * @param limit - Maximum number of tracks per page * @param options - Optional token override * @returns Paginated list of tracks * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__tracks */ getTracks(userId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Get a user's public playlists. * * @param userId - The user's numeric ID or URN * @param limit - Maximum number of playlists per page * @param options - Optional token override * @returns Paginated list of playlists (without full track data) * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__playlists */ getPlaylists(userId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Get tracks liked by a user. * * @param userId - The user's numeric ID or URN * @param limit - Maximum number of tracks per page * @param cursor - Pagination cursor from a previous response's `next_href` * @param options - Optional token override * @returns Paginated list of liked tracks * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_tracks */ getLikesTracks(userId: string | number, limit?: number, cursor?: string, options?: TokenOption): Promise>; /** * Get playlists liked by a user. * * @param userId - The user's numeric ID or URN * @param limit - Maximum number of playlists per page * @param options - Optional token override * @returns Paginated list of liked playlists * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_playlists */ getLikesPlaylists(userId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Get a user's external web profile links (Twitter, Instagram, etc.). * * @param userId - The user's numeric ID or URN * @param options - Optional token override * @returns Array of web profile objects * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const profiles = await sc.users.getWebProfiles(123456); * profiles.forEach(p => console.log(p.service, p.url)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__web_profiles */ getWebProfiles(userId: string | number, options?: TokenOption): Promise; } /** * Track namespace — fetch, update, delete tracks and their metadata. * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks */ class Tracks { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Get a track by ID. * * @param trackId - The track's numeric ID or URN * @param options - Optional token override * @returns The track object with full metadata * @throws {SoundCloudError} When the track is not found or the API returns an error * * @example * ```ts * const track = await sc.tracks.getTrack(123456); * console.log(track.title, track.duration); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id_ */ getTrack(trackId: string | number, options?: TokenOption): Promise; /** * Fetch multiple tracks by their IDs in a single request. * * @param ids - Array of track IDs (numeric or string URNs) * @param options - Optional token override * @returns Array of track objects (may be shorter than `ids` if some tracks are unavailable) * @throws {SoundCloudError} When the API returns an error * @throws {Error} When more than 200 IDs are provided * * @remarks * SoundCloud's API likely caps at ~200 IDs per request. Passing more than 200 IDs * will throw immediately without making a network request. * * @example * ```ts * const tracks = await sc.tracks.getTracks([123456, 234567, 345678]); * tracks.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks */ getTracks(ids: (string | number)[], options?: TokenOption): Promise; /** * Get stream URLs for a track. * * @param trackId - The track's numeric ID or URN * @param options - Optional token override * @returns Object containing available stream URLs (HLS, MP3, preview) * @throws {SoundCloudError} When the track is not found or not streamable * * @example * ```ts * const streams = await sc.tracks.getStreams(123456); * console.log(streams.hls_mp3_128_url); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__streams */ getStreams(trackId: string | number, options?: TokenOption): Promise; /** * Get comments on a track. * * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of comments per page * @param options - Optional token override * @returns Paginated list of comments * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__comments */ getComments(trackId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Post a comment on a track. * * @param trackId - The track's numeric ID or URN * @param body - The comment text * @param timestamp - Position in the track in milliseconds where the comment is placed * @param options - Optional token override * @returns The created comment object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const comment = await sc.tracks.createComment(123456, 'Great track!', 30000); * console.log(comment.id); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/post_tracks__track_id__comments */ createComment(trackId: string | number, body: string, timestamp?: number, options?: TokenOption): Promise; /** * Get users who have liked (favorited) a track. * * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of users per page * @param options - Optional token override * @returns Paginated list of users who liked the track * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__favoriters */ getLikes(trackId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Get users who have reposted a track. * * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of users per page * @param options - Optional token override * @returns Paginated list of users who reposted the track * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__reposters */ getReposts(trackId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Get tracks related to a given track. * * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of related tracks to return * @param options - Optional token override * @returns Array of related tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const related = await sc.tracks.getRelated(123456, 5); * related.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__related */ getRelated(trackId: string | number, limit?: number, options?: TokenOption): Promise; /** * Update a track's metadata. * * @param trackId - The track's numeric ID or URN * @param params - Fields to update (title, description, genre, etc.) * @param options - Optional token override * @returns The updated track object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const updated = await sc.tracks.update(123456, { title: 'New Title', genre: 'Electronic' }); * console.log(updated.title); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/put_tracks__track_id_ */ update(trackId: string | number, params: UpdateTrackParams, options?: TokenOption): Promise; /** * Delete a track. * * @param trackId - The track's numeric ID or URN * @param options - Optional token override * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * await sc.tracks.delete(123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/delete_tracks__track_id_ */ delete(trackId: string | number, options?: TokenOption): Promise; } /** * Playlist namespace — fetch, create, update, and delete playlists. * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists */ class Playlists { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Get a playlist by ID. * * @param playlistId - The playlist's numeric ID or URN * @param options - Optional token override * @returns The playlist object with track data * @throws {SoundCloudError} When the playlist is not found or the API returns an error * * @example * ```ts * const playlist = await sc.playlists.getPlaylist(123456); * console.log(playlist.title, playlist.track_count); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id_ */ getPlaylist(playlistId: string | number, options?: TokenOption): Promise; /** * Get tracks in a playlist. * * @param playlistId - The playlist's numeric ID or URN * @param limit - Maximum number of tracks per page * @param offset - Number of tracks to skip (for offset-based pagination) * @param options - Optional token override * @returns Paginated list of tracks * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__tracks */ getTracks(playlistId: string | number, limit?: number, offset?: number, options?: TokenOption): Promise>; /** * Get users who have reposted a playlist. * * @param playlistId - The playlist's numeric ID or URN * @param limit - Maximum number of users per page * @param options - Optional token override * @returns Paginated list of users who reposted the playlist * @throws {SoundCloudError} When the API returns an error * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__reposters */ getReposts(playlistId: string | number, limit?: number, options?: TokenOption): Promise>; /** * Create a new playlist. * * @param params - Playlist creation parameters (title is required) * @param options - Optional token override * @returns The created playlist object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const playlist = await sc.playlists.create({ * title: 'My Favorites', * sharing: 'public', * tracks: [{ urn: 'soundcloud:tracks:123' }], * }); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/post_playlists */ create(params: CreatePlaylistParams, options?: TokenOption): Promise; /** * Update a playlist's metadata or track list. * * @param playlistId - The playlist's numeric ID or URN * @param params - Fields to update * @param options - Optional token override * @returns The updated playlist object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const updated = await sc.playlists.update(123456, { title: 'Updated Title' }); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/put_playlists__playlist_id_ */ update(playlistId: string | number, params: UpdatePlaylistParams, options?: TokenOption): Promise; /** * Delete a playlist. * * @param playlistId - The playlist's numeric ID or URN * @param options - Optional token override * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * await sc.playlists.delete(123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/delete_playlists__playlist_id_ */ delete(playlistId: string | number, options?: TokenOption): Promise; } /** * Search namespace — search for tracks, users, and playlists. * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/search */ class Search { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Search for tracks by query string. * * @param query - Search query text * @param pageNumber - Zero-based page number (10 results per page) * @param options - Optional token override * @returns Paginated list of matching tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const results = await sc.search.tracks('lofi hip hop'); * results.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks */ tracks(query: string, pageNumber?: number, options?: TokenOption): Promise>; /** * Search for users by query string. * * @param query - Search query text * @param pageNumber - Zero-based page number (10 results per page) * @param options - Optional token override * @returns Paginated list of matching users * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const results = await sc.search.users('deadmau5'); * results.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users */ users(query: string, pageNumber?: number, options?: TokenOption): Promise>; /** * Search for playlists by query string. * * @param query - Search query text * @param pageNumber - Zero-based page number (10 results per page) * @param options - Optional token override * @returns Paginated list of matching playlists * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * const results = await sc.search.playlists('chill vibes'); * results.collection.forEach(p => console.log(p.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists */ playlists(query: string, pageNumber?: number, options?: TokenOption): Promise>; } /** * Resolve namespace — resolve SoundCloud URLs to API resources. * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/resolve */ class Resolve { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Resolve a SoundCloud URL to its API resource URL. * * @param url - A SoundCloud URL (e.g. "https://soundcloud.com/artist/track-name") * @param options - Optional token override * @returns The resolved API resource URL (via 302 redirect) * @throws {SoundCloudError} When the URL cannot be resolved * * @example * ```ts * const apiUrl = await sc.resolve.resolveUrl('https://soundcloud.com/deadmau5/strobe'); * console.log(apiUrl); // "https://api.soundcloud.com/tracks/..." * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/resolve/get_resolve */ resolveUrl(url: string, options?: TokenOption): Promise; } /** * Likes namespace — like and unlike tracks and playlists. * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes */ class Likes { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Like a track. * * @param trackId - The track's numeric ID or URN * @param options - Optional token override * @returns `true` if the like was successful, `false` on failure * * @example * ```ts * const success = await sc.likes.likeTrack(123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_tracks__track_id_ */ likeTrack(trackId: string | number, options?: TokenOption): Promise; /** * Unlike a track. * * @param trackId - The track's numeric ID or URN * @param options - Optional token override * @returns `true` if the unlike was successful, `false` on failure * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_tracks__track_id_ */ unlikeTrack(trackId: string | number, options?: TokenOption): Promise; /** * Like a playlist. * * @param playlistId - The playlist's numeric ID or URN * @param options - Optional token override * @returns `true` if the like was successful, `false` on failure * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_playlists__playlist_id_ */ likePlaylist(playlistId: string | number, options?: TokenOption): Promise; /** * Unlike a playlist. * * @param playlistId - The playlist's numeric ID or URN * @param options - Optional token override * @returns `true` if the unlike was successful, `false` on failure * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_playlists__playlist_id_ */ unlikePlaylist(playlistId: string | number, options?: TokenOption): Promise; } /** * Reposts namespace — repost and unrepost tracks and playlists. * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts */ class Reposts { private getToken; private refreshCtx?; constructor(getToken: TokenGetter, refreshCtx?: AutoRefreshContext | undefined); private fetch; /** * Repost a track to your profile. * * @param trackId - The track's numeric ID or URN * @param options - Optional token override * @returns `true` if the repost was successful, `false` on failure * * @example * ```ts * const success = await sc.reposts.repostTrack(123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_tracks__track_id_ */ repostTrack(trackId: string | number, options?: TokenOption): Promise; /** * Remove a track repost from your profile. * * @param trackId - The track's numeric ID or URN * @param options - Optional token override * @returns `true` if the unrepost was successful, `false` on failure * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_tracks__track_id_ */ unrepostTrack(trackId: string | number, options?: TokenOption): Promise; /** * Repost a playlist to your profile. * * @param playlistId - The playlist's numeric ID or URN * @param options - Optional token override * @returns `true` if the repost was successful, `false` on failure * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_playlists__playlist_id_ */ repostPlaylist(playlistId: string | number, options?: TokenOption): Promise; /** * Remove a playlist repost from your profile. * * @param playlistId - The playlist's numeric ID or URN * @param options - Optional token override * @returns `true` if the unrepost was successful, `false` on failure * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_playlists__playlist_id_ */ unrepostPlaylist(playlistId: string | number, options?: TokenOption): Promise; } } /** * List of operation IDs currently implemented by soundcloud-api-ts. * Used for OpenAPI coverage reporting. */ declare const IMPLEMENTED_OPERATIONS: string[]; /** * Async generator that automatically follows `next_href` pagination, * yielding each page's `collection` array. * * @param firstPage - Function that fetches the first page of results * @param fetchNext - Function that fetches subsequent pages given a `next_href` URL * @returns An async generator yielding arrays of items (one per page) * * @example * ```ts * import { paginate, searchTracks, scFetchUrl } from 'soundcloud-api-ts'; * * const pages = paginate( * () => searchTracks(token, 'lofi'), * (url) => scFetchUrl(url, token), * ); * * for await (const page of pages) { * console.log(`Got ${page.length} tracks`); * } * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api */ declare function paginate(firstPage: () => Promise>, fetchNext: (url: string) => Promise>): AsyncGenerator; /** * Async generator that yields individual items across all pages, * automatically following `next_href` pagination. * * @param firstPage - Function that fetches the first page of results * @param fetchNext - Function that fetches subsequent pages given a `next_href` URL * @returns An async generator yielding individual items * * @example * ```ts * import { paginateItems, searchTracks, scFetchUrl } from 'soundcloud-api-ts'; * * const tracks = paginateItems( * () => searchTracks(token, 'lofi'), * (url) => scFetchUrl(url, token), * ); * * for await (const track of tracks) { * console.log(track.title); * } * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api */ declare function paginateItems(firstPage: () => Promise>, fetchNext: (url: string) => Promise>): AsyncGenerator; /** * Collects all pages into a single flat array, with an optional maximum item limit. * * @param firstPage - Function that fetches the first page of results * @param fetchNext - Function that fetches subsequent pages given a `next_href` URL * @param options - Optional configuration * @param options.maxItems - Maximum number of items to collect (defaults to all) * @returns A promise that resolves to a flat array of all collected items * * @example * ```ts * import { fetchAll, searchTracks, scFetchUrl } from 'soundcloud-api-ts'; * * const allTracks = await fetchAll( * () => searchTracks(token, 'lofi'), * (url) => scFetchUrl(url, token), * { maxItems: 100 }, * ); * console.log(`Fetched ${allTracks.length} tracks`); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api */ declare function fetchAll(firstPage: () => Promise>, fetchNext: (url: string) => Promise>, options?: { maxItems?: number; }): Promise; /** * Exchange client credentials for an access token (client_credentials grant). * * This is a standalone function alternative to {@link SoundCloudClient.Auth.getClientToken}. * * @param clientId - Your SoundCloud application's OAuth client ID * @param clientSecret - Your SoundCloud application's OAuth client secret * @returns The OAuth token response * @throws {SoundCloudError} When authentication fails (e.g. invalid credentials) * * @example * ```ts * import { getClientToken } from 'soundcloud-api-ts'; * * const token = await getClientToken('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET'); * console.log(token.access_token); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token */ declare const getClientToken: (clientId: string, clientSecret: string) => Promise; /** * Exchange an authorization code for user tokens (authorization_code grant). * * This is a standalone function alternative to {@link SoundCloudClient.Auth.getUserToken}. * * @param clientId - Your SoundCloud application's OAuth client ID * @param clientSecret - Your SoundCloud application's OAuth client secret * @param redirectUri - The redirect URI registered with your SoundCloud application * @param code - The authorization code received from the OAuth callback * @param codeVerifier - PKCE code verifier if a code challenge was used during authorization * @returns The OAuth token response including access and refresh tokens * @throws {SoundCloudError} When the code is invalid, expired, or credentials are wrong * * @example * ```ts * import { getUserToken } from 'soundcloud-api-ts'; * * const token = await getUserToken( * 'YOUR_CLIENT_ID', * 'YOUR_CLIENT_SECRET', * 'https://example.com/callback', * authorizationCode, * codeVerifier, // optional, for PKCE * ); * console.log(token.access_token, token.refresh_token); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token */ declare const getUserToken: (clientId: string, clientSecret: string, redirectUri: string, code: string, codeVerifier?: string) => Promise; /** * Refresh an expired access token using a refresh token (refresh_token grant). * * This is a standalone function alternative to {@link SoundCloudClient.Auth.refreshUserToken}. * * @param clientId - Your SoundCloud application's OAuth client ID * @param clientSecret - Your SoundCloud application's OAuth client secret * @param redirectUri - The redirect URI registered with your SoundCloud application * @param refreshToken - The refresh token from a previous token response * @returns A new OAuth token response with fresh access and refresh tokens * @throws {SoundCloudError} When the refresh token is invalid or expired * * @example * ```ts * import { refreshUserToken } from 'soundcloud-api-ts'; * * const newToken = await refreshUserToken( * 'YOUR_CLIENT_ID', * 'YOUR_CLIENT_SECRET', * 'https://example.com/callback', * oldRefreshToken, * ); * console.log(newToken.access_token); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2/post_oauth2_token */ declare const refreshUserToken: (clientId: string, clientSecret: string, redirectUri: string, refreshToken: string) => Promise; /** * Invalidate the session associated with an access token. * * **Note:** This hits `https://secure.soundcloud.com`, NOT the regular * `api.soundcloud.com` host used by all other endpoints. * * @param accessToken - The OAuth access token to invalidate * @throws {Error} When the sign-out request fails * * @example * ```ts * import { signOut } from 'soundcloud-api-ts'; * * await signOut('your-access-token'); * ``` */ declare const signOut: (accessToken: string) => Promise; /** * Build the SoundCloud authorization URL for the OAuth 2.1 code flow. * * Redirect the user to this URL so they can grant access to your application. * * @param clientId - Your SoundCloud application's OAuth client ID * @param redirectUri - The redirect URI registered with your SoundCloud application * @param options - Optional parameters for the authorization request * @param options.state - Opaque state value for CSRF protection (round-tripped by SoundCloud) * @param options.codeChallenge - PKCE S256 code challenge for enhanced security * @returns The full authorization URL to redirect the user to * * @example * ```ts * import { getAuthorizationUrl, generateCodeVerifier, generateCodeChallenge } from 'soundcloud-api-ts'; * * const verifier = generateCodeVerifier(); * const challenge = await generateCodeChallenge(verifier); * const url = getAuthorizationUrl('YOUR_CLIENT_ID', 'https://example.com/callback', { * state: 'random-csrf-token', * codeChallenge: challenge, * }); * // Redirect user to `url` * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/oauth2 */ declare function getAuthorizationUrl(clientId: string, redirectUri: string, options?: { state?: string; codeChallenge?: string; }): string; /** * Generate a random PKCE code verifier (43+ characters, base64url-encoded). * * Uses the Web Crypto API (`globalThis.crypto`), compatible with Node 20+ and modern browsers. * * @returns A cryptographically random code verifier string * * @example * ```ts * import { generateCodeVerifier, generateCodeChallenge } from 'soundcloud-api-ts'; * * const verifier = generateCodeVerifier(); * const challenge = await generateCodeChallenge(verifier); * // Use `challenge` in getAuthorizationUrl, then `verifier` in getUserToken * ``` * * @see https://datatracker.ietf.org/doc/html/rfc7636 */ declare function generateCodeVerifier(): string; /** * Derive the S256 PKCE code challenge from a code verifier. * * Computes `BASE64URL(SHA256(verifier))` using the Web Crypto API (SubtleCrypto), * available in Node 20+ and modern browsers. * * @param verifier - The code verifier string (typically from {@link generateCodeVerifier}) * @returns The base64url-encoded SHA-256 hash of the verifier * * @example * ```ts * import { generateCodeVerifier, generateCodeChallenge } from 'soundcloud-api-ts'; * * const verifier = generateCodeVerifier(); * const challenge = await generateCodeChallenge(verifier); * console.log(challenge); // e.g. "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk" * ``` * * @see https://datatracker.ietf.org/doc/html/rfc7636#section-4.2 */ declare function generateCodeChallenge(verifier: string): Promise; /** * Contract for a pluggable token provider that manages OAuth token lifecycle. * * Implement this interface to integrate soundcloud-api-ts with your * framework's session management, e.g. NextAuth, Clerk, Redis, or a simple * in-memory store. * * @example * ```ts * class InMemoryTokenProvider implements TokenProvider { * private _accessToken?: string; * private _refreshToken?: string; * * getAccessToken() { return this._accessToken; } * setTokens(access: string, refresh?: string) { * this._accessToken = access; * this._refreshToken = refresh; * } * async refreshIfNeeded(client: SoundCloudClient) { * if (!this._refreshToken) throw new Error('No refresh token'); * const token = await client.auth.refreshUserToken(this._refreshToken); * this.setTokens(token.access_token, token.refresh_token); * return token.access_token; * } * } * ``` * * @see docs/auth-guide.md */ interface TokenProvider { /** Returns the current access token, or undefined if none is stored. */ getAccessToken(): string | undefined | Promise; /** Persist new tokens (called after a successful token grant or refresh). */ setTokens(accessToken: string, refreshToken?: string): void | Promise; /** * Ensure a valid access token is available, refreshing if necessary. * Called automatically when a request returns 401 Unauthorized. */ refreshIfNeeded(client: SoundCloudClient): Promise | string; } /** * Minimal synchronous key–value store for OAuth tokens. * * Useful for implementing a simple in-memory or cookie-backed token store * without the full async lifecycle of {@link TokenProvider}. * * @example * ```ts * class CookieTokenStore implements TokenStore { * getAccessToken() { return getCookie('sc_access_token') ?? undefined; } * getRefreshToken() { return getCookie('sc_refresh_token') ?? undefined; } * setTokens(a, r) { setCookie('sc_access_token', a); if (r) setCookie('sc_refresh_token', r); } * clearTokens() { deleteCookie('sc_access_token'); deleteCookie('sc_refresh_token'); } * } * ``` * * @see docs/auth-guide.md */ interface TokenStore { /** Returns the stored access token, or undefined if none. */ getAccessToken(): string | undefined; /** Returns the stored refresh token, or undefined if none. */ getRefreshToken(): string | undefined; /** Persist new tokens. */ setTokens(accessToken: string, refreshToken?: string): void; /** Remove all stored tokens (call on sign-out). */ clearTokens(): void; } /** * Fetch the authenticated user's profile. * * @param token - OAuth access token * @returns The authenticated user's full profile including private account details * @throws {SoundCloudError} When the token is invalid or the API returns an error * * @example * ```ts * import { getMe } from 'soundcloud-api-ts'; * * const me = await getMe(token); * console.log(me.username, me.private_tracks_count); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me */ declare const getMe: (token: string) => Promise; /** * Fetch a user's public profile by ID. * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @returns The user's public profile * @throws {SoundCloudError} When the user is not found or the API returns an error * * @example * ```ts * import { getUser } from 'soundcloud-api-ts'; * * const user = await getUser(token, 123456); * console.log(user.username); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id_ */ declare const getUser: (token: string, userId: string | number) => Promise; /** * Fetch a user's followers. * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @param limit - Maximum number of followers per page * @returns Paginated list of follower users * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getFollowers } from 'soundcloud-api-ts'; * * const result = await getFollowers(token, 123456, 50); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followers */ declare const getFollowers: (token: string, userId: string | number, limit?: number) => Promise>; /** * Fetch users that a given user is following. * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @param limit - Maximum number of users per page * @returns Paginated list of followed users * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getFollowings } from 'soundcloud-api-ts'; * * const result = await getFollowings(token, 123456, 50); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__followings */ declare const getFollowings: (token: string, userId: string | number, limit?: number) => Promise>; /** * Fetch a user's public tracks. * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @param limit - Maximum number of tracks per page * @returns Paginated list of tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getUserTracks } from 'soundcloud-api-ts'; * * const result = await getUserTracks(token, 123456, 25); * result.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__tracks */ declare const getUserTracks: (token: string, userId: string | number, limit?: number) => Promise>; /** * Fetch a user's public playlists (without full track data). * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @param limit - Maximum number of playlists per page * @returns Paginated list of playlists * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getUserPlaylists } from 'soundcloud-api-ts'; * * const result = await getUserPlaylists(token, 123456, 10); * result.collection.forEach(p => console.log(p.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__playlists */ declare const getUserPlaylists: (token: string, userId: string | number, limit?: number) => Promise>; /** * Fetch tracks liked by a user. * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @param limit - Maximum number of tracks per page * @param cursor - Pagination cursor from a previous response's `next_href` * @returns Paginated list of liked tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getUserLikesTracks } from 'soundcloud-api-ts'; * * const result = await getUserLikesTracks(token, 123456, 50); * result.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_tracks */ declare const getUserLikesTracks: (token: string, userId: string | number, limit?: number, cursor?: string) => Promise>; /** * Fetch playlists liked by a user. * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @param limit - Maximum number of playlists per page * @returns Paginated list of liked playlists * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getUserLikesPlaylists } from 'soundcloud-api-ts'; * * const result = await getUserLikesPlaylists(token, 123456, 10); * result.collection.forEach(p => console.log(p.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__likes_playlists */ declare const getUserLikesPlaylists: (token: string, userId: string | number, limit?: number) => Promise>; /** * Fetch a user's external web profile links (Twitter, Instagram, personal site, etc.). * * @param token - OAuth access token * @param userId - The user's numeric ID or URN * @returns Array of web profile objects * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getUserWebProfiles } from 'soundcloud-api-ts'; * * const profiles = await getUserWebProfiles(token, 123456); * profiles.forEach(p => console.log(p.service, p.url)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users__user_id__web_profiles */ declare const getUserWebProfiles: (token: string, userId: string | number) => Promise; /** * Fetch a track by ID. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @returns The track object with full metadata * @throws {SoundCloudError} When the track is not found or the API returns an error * * @example * ```ts * import { getTrack } from 'soundcloud-api-ts'; * * const track = await getTrack(token, 123456); * console.log(track.title, track.duration); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id_ */ declare const getTrack: (token: string, trackId: string | number) => Promise; /** * Fetch multiple tracks by their IDs in a single request. * * @param token - OAuth access token * @param ids - Array of track IDs (numeric or string URNs) * @returns Array of track objects (may be shorter than `ids` if some tracks are unavailable) * @throws {SoundCloudError} When the API returns an error * @throws {Error} When more than 200 IDs are provided * * @remarks * SoundCloud's API likely caps at ~200 IDs per request. Passing more than 200 IDs * will throw immediately without making a network request. * * @example * ```ts * import { getTracks } from 'soundcloud-api-ts'; * * const tracks = await getTracks(token, [123456, 234567, 345678]); * tracks.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks */ declare const getTracks: (token: string, ids: (string | number)[]) => Promise; /** * Fetch comments on a track. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of comments per page * @returns Paginated list of comments * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getTrackComments } from 'soundcloud-api-ts'; * * const result = await getTrackComments(token, 123456, 20); * result.collection.forEach(c => console.log(c.body)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__comments */ declare const getTrackComments: (token: string, trackId: string | number, limit?: number) => Promise>; /** * Post a comment on a track. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @param body - The comment text * @param timestamp - Position in the track in milliseconds where the comment is placed * @returns The created comment object * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { createTrackComment } from 'soundcloud-api-ts'; * * const comment = await createTrackComment(token, 123456, 'Great drop!', 60000); * console.log(comment.id); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/post_tracks__track_id__comments */ declare const createTrackComment: (token: string, trackId: string | number, body: string, timestamp?: number) => Promise; /** * Fetch users who have liked (favorited) a track. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of users per page * @returns Paginated list of users who liked the track * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getTrackLikes } from 'soundcloud-api-ts'; * * const result = await getTrackLikes(token, 123456, 50); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__favoriters */ declare const getTrackLikes: (token: string, trackId: string | number, limit?: number) => Promise>; /** * Fetch users who have reposted a track. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of users per page * @returns Paginated list of users who reposted the track * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getTrackReposts } from 'soundcloud-api-ts'; * * const result = await getTrackReposts(token, 123456, 50); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__reposters */ declare const getTrackReposts: (token: string, trackId: string | number, limit?: number) => Promise>; /** * Fetch tracks related to a given track. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @param limit - Maximum number of related tracks to return * @returns Array of related tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getRelatedTracks } from 'soundcloud-api-ts'; * * const related = await getRelatedTracks(token, 123456, 5); * related.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__related */ declare const getRelatedTracks: (token: string, trackId: string | number, limit?: number) => Promise; /** * Fetch stream URLs for a track (HLS, MP3, preview). * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @returns Object containing available stream URLs * @throws {SoundCloudError} When the track is not found or not streamable * * @example * ```ts * import { getTrackStreams } from 'soundcloud-api-ts'; * * const streams = await getTrackStreams(token, 123456); * console.log(streams.hls_mp3_128_url); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id__streams */ declare const getTrackStreams: (token: string, trackId: string | number) => Promise; /** * Like (favorite) a track as the authenticated user. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @returns `true` if the like was successful, `false` on failure * * @example * ```ts * import { likeTrack } from 'soundcloud-api-ts'; * * const success = await likeTrack(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_tracks__track_id_ */ declare const likeTrack: (token: string, trackId: string | number) => Promise; /** * Unlike (unfavorite) a track as the authenticated user. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @returns `true` if the unlike was successful, `false` on failure * * @example * ```ts * import { unlikeTrack } from 'soundcloud-api-ts'; * * const success = await unlikeTrack(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_tracks__track_id_ */ declare const unlikeTrack: (token: string, trackId: string | number) => Promise; /** * Delete a track. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { deleteTrack } from 'soundcloud-api-ts'; * * await deleteTrack(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/delete_tracks__track_id_ */ declare const deleteTrack: (token: string, trackId: string | number) => Promise; /** * Fetch a playlist by ID. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @returns The playlist object with track data * @throws {SoundCloudError} When the playlist is not found or the API returns an error * * @example * ```ts * import { getPlaylist } from 'soundcloud-api-ts'; * * const playlist = await getPlaylist(token, 123456); * console.log(playlist.title, playlist.track_count); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id_ */ declare const getPlaylist: (token: string, playlistId: string | number) => Promise; /** * Fetch tracks in a playlist. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @param limit - Maximum number of tracks per page * @param offset - Number of tracks to skip (for offset-based pagination) * @returns Paginated list of tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getPlaylistTracks } from 'soundcloud-api-ts'; * * const result = await getPlaylistTracks(token, 123456, 25); * result.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__tracks */ declare const getPlaylistTracks: (token: string, playlistId: string | number, limit?: number, offset?: number) => Promise>; /** * Fetch users who have reposted a playlist. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @param limit - Maximum number of users per page * @returns Paginated list of users who reposted the playlist * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getPlaylistReposts } from 'soundcloud-api-ts'; * * const result = await getPlaylistReposts(token, 123456, 50); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists__playlist_id__reposters */ declare const getPlaylistReposts: (token: string, playlistId: string | number, limit?: number) => Promise>; /** * Delete a playlist. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { deletePlaylist } from 'soundcloud-api-ts'; * * await deletePlaylist(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/delete_playlists__playlist_id_ */ declare const deletePlaylist: (token: string, playlistId: string | number) => Promise; /** * Search for tracks by query string. * * @param token - OAuth access token * @param query - Search query text * @param pageNumber - Zero-based page number (10 results per page) * @returns Paginated list of matching tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { searchTracks } from 'soundcloud-api-ts'; * * const result = await searchTracks(token, 'lofi hip hop'); * result.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks */ declare const searchTracks: (token: string, query: string, pageNumber?: number) => Promise>; /** * Search for users by query string. * * @param token - OAuth access token * @param query - Search query text * @param pageNumber - Zero-based page number (10 results per page) * @returns Paginated list of matching users * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { searchUsers } from 'soundcloud-api-ts'; * * const result = await searchUsers(token, 'deadmau5'); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/users/get_users */ declare const searchUsers: (token: string, query: string, pageNumber?: number) => Promise>; /** * Search for playlists by query string. * * @param token - OAuth access token * @param query - Search query text * @param pageNumber - Zero-based page number (10 results per page) * @returns Paginated list of matching playlists * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { searchPlaylists } from 'soundcloud-api-ts'; * * const result = await searchPlaylists(token, 'chill vibes'); * result.collection.forEach(p => console.log(p.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/playlists/get_playlists */ declare const searchPlaylists: (token: string, query: string, pageNumber?: number) => Promise>; /** * Resolve a SoundCloud URL to its API resource URL. * * SoundCloud returns a 302 redirect to the API resource; this function returns the redirect target URL. * * @param token - OAuth access token * @param url - A SoundCloud URL (e.g. "https://soundcloud.com/artist/track-name") * @returns The resolved API resource URL * @throws {SoundCloudError} When the URL cannot be resolved * * @example * ```ts * import { resolveUrl } from 'soundcloud-api-ts'; * * const apiUrl = await resolveUrl(token, 'https://soundcloud.com/deadmau5/strobe'); * console.log(apiUrl); // "https://api.soundcloud.com/tracks/..." * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/resolve/get_resolve */ declare const resolveUrl: (token: string, url: string) => Promise; /** * Fetch the authenticated user's activity feed. * * @param token - OAuth access token * @param limit - Maximum number of activities per page * @returns Activities response with `future_href` for polling * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeActivities } from 'soundcloud-api-ts'; * * const activities = await getMeActivities(token, 25); * activities.collection.forEach(a => console.log(a.type)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities */ declare const getMeActivities: (token: string, limit?: number) => Promise; /** * Fetch the authenticated user's own activities (uploads, reposts by the user). * * @param token - OAuth access token * @param limit - Maximum number of activities per page * @returns Activities response * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeActivitiesOwn } from 'soundcloud-api-ts'; * * const activities = await getMeActivitiesOwn(token, 25); * activities.collection.forEach(a => console.log(a.type)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_all_own */ declare const getMeActivitiesOwn: (token: string, limit?: number) => Promise; /** * Fetch track-related activities in the authenticated user's feed. * * @param token - OAuth access token * @param limit - Maximum number of activities per page * @returns Activities response filtered to track activities * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeActivitiesTracks } from 'soundcloud-api-ts'; * * const activities = await getMeActivitiesTracks(token, 25); * activities.collection.forEach(a => console.log(a.type)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_activities_tracks */ declare const getMeActivitiesTracks: (token: string, limit?: number) => Promise; /** * Fetch tracks liked by the authenticated user. * * @param token - OAuth access token * @param limit - Maximum number of tracks per page * @returns Paginated list of liked tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeLikesTracks } from 'soundcloud-api-ts'; * * const result = await getMeLikesTracks(token, 50); * result.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_tracks */ declare const getMeLikesTracks: (token: string, limit?: number) => Promise>; /** * Fetch playlists liked by the authenticated user. * * @param token - OAuth access token * @param limit - Maximum number of playlists per page * @returns Paginated list of liked playlists * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeLikesPlaylists } from 'soundcloud-api-ts'; * * const result = await getMeLikesPlaylists(token, 50); * result.collection.forEach(p => console.log(p.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_likes_playlists */ declare const getMeLikesPlaylists: (token: string, limit?: number) => Promise>; /** * Fetch users the authenticated user is following. * * @param token - OAuth access token * @param limit - Maximum number of users per page * @returns Paginated list of followed users * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeFollowings } from 'soundcloud-api-ts'; * * const result = await getMeFollowings(token, 50); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings */ declare const getMeFollowings: (token: string, limit?: number) => Promise>; /** * Fetch recent tracks from users the authenticated user is following. * * @param token - OAuth access token * @param limit - Maximum number of tracks per page * @returns Paginated list of tracks from followed users * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeFollowingsTracks } from 'soundcloud-api-ts'; * * const result = await getMeFollowingsTracks(token, 50); * result.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followings_tracks */ declare const getMeFollowingsTracks: (token: string, limit?: number) => Promise>; /** * Follow a user as the authenticated user. * * @param token - OAuth access token * @param userUrn - The user's ID or URN to follow * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { followUser } from 'soundcloud-api-ts'; * * await followUser(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/put_me_followings__user_id_ */ declare const followUser: (token: string, userUrn: string | number) => Promise; /** * Unfollow a user as the authenticated user. * * @param token - OAuth access token * @param userUrn - The user's ID or URN to unfollow * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { unfollowUser } from 'soundcloud-api-ts'; * * await unfollowUser(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/delete_me_followings__user_id_ */ declare const unfollowUser: (token: string, userUrn: string | number) => Promise; /** * Fetch the authenticated user's followers. * * @param token - OAuth access token * @param limit - Maximum number of users per page * @returns Paginated list of follower users * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeFollowers } from 'soundcloud-api-ts'; * * const result = await getMeFollowers(token, 50); * result.collection.forEach(u => console.log(u.username)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_followers */ declare const getMeFollowers: (token: string, limit?: number) => Promise>; /** * Fetch the authenticated user's playlists. * * @param token - OAuth access token * @param limit - Maximum number of playlists per page * @returns Paginated list of playlists * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMePlaylists } from 'soundcloud-api-ts'; * * const result = await getMePlaylists(token, 10); * result.collection.forEach(p => console.log(p.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_playlists */ declare const getMePlaylists: (token: string, limit?: number) => Promise>; /** * Fetch tracks uploaded by the authenticated user. * * @param token - OAuth access token * @param limit - Maximum number of tracks per page * @returns Paginated list of the user's tracks * @throws {SoundCloudError} When the API returns an error * * @example * ```ts * import { getMeTracks } from 'soundcloud-api-ts'; * * const result = await getMeTracks(token, 50); * result.collection.forEach(t => console.log(t.title)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_tracks */ declare const getMeTracks: (token: string, limit?: number) => Promise>; /** * List the authenticated user's connected external social accounts. * * @param token - OAuth access token (user token required) * @returns Array of connection objects for linked social services * @throws {SoundCloudError} When the API returns an error * * @remarks This endpoint may require elevated API access or app approval. * * @example * ```ts * import { getMeConnections } from 'soundcloud-api-ts'; * * const connections = await getMeConnections(token); * connections.forEach(c => console.log(c.service, c.display_name)); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_connections */ declare const getMeConnections: (token: string) => Promise; /** * Like a playlist as the authenticated user. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @returns `true` if the like was successful, `false` on failure * * @example * ```ts * import { likePlaylist } from 'soundcloud-api-ts'; * * const success = await likePlaylist(token, 789012); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/post_likes_playlists__playlist_id_ */ declare const likePlaylist: (token: string, playlistId: string | number) => Promise; /** * Unlike a playlist as the authenticated user. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @returns `true` if the unlike was successful, `false` on failure * * @example * ```ts * import { unlikePlaylist } from 'soundcloud-api-ts'; * * const success = await unlikePlaylist(token, 789012); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/likes/delete_likes_playlists__playlist_id_ */ declare const unlikePlaylist: (token: string, playlistId: string | number) => Promise; /** * Repost a track to your profile. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @returns `true` if the repost was successful, `false` on failure * * @example * ```ts * import { repostTrack } from 'soundcloud-api-ts'; * * const success = await repostTrack(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_tracks__track_id_ */ declare const repostTrack: (token: string, trackId: string | number) => Promise; /** * Remove a track repost from your profile. * * @param token - OAuth access token * @param trackId - The track's numeric ID or URN * @returns `true` if the unrepost was successful, `false` on failure * * @example * ```ts * import { unrepostTrack } from 'soundcloud-api-ts'; * * const success = await unrepostTrack(token, 123456); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_tracks__track_id_ */ declare const unrepostTrack: (token: string, trackId: string | number) => Promise; /** * Repost a playlist to your profile. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @returns `true` if the repost was successful, `false` on failure * * @example * ```ts * import { repostPlaylist } from 'soundcloud-api-ts'; * * const success = await repostPlaylist(token, 789012); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/post_reposts_playlists__playlist_id_ */ declare const repostPlaylist: (token: string, playlistId: string | number) => Promise; /** * Remove a playlist repost from your profile. * * @param token - OAuth access token * @param playlistId - The playlist's numeric ID or URN * @returns `true` if the unrepost was successful, `false` on failure * * @example * ```ts * import { unrepostPlaylist } from 'soundcloud-api-ts'; * * const success = await unrepostPlaylist(token, 789012); * ``` * * @see https://developers.soundcloud.com/docs/api/explorer/open-api#/reposts/delete_reposts_playlists__playlist_id_ */ declare const unrepostPlaylist: (token: string, playlistId: string | number) => Promise; /** * Returns an encoded SoundCloud widget embed URL for a given track ID. * * @param trackId - The track's numeric ID or string identifier * @returns URL-encoded widget embed URL string * * @example * ```ts * import { getSoundCloudWidgetUrl } from 'soundcloud-api-ts'; * * const widgetUrl = getSoundCloudWidgetUrl(123456); * console.log(widgetUrl); * ``` */ declare const getSoundCloudWidgetUrl: (trackId: string | number) => string; export { type CreatePlaylistParams, IMPLEMENTED_OPERATIONS, InFlightDeduper, RawClient, type RawResponse, type RequestOptions, type RetryConfig, type RetryInfo, type SCRequestTelemetry, SoundCloudActivitiesResponse, type SoundCloudCache, type SoundCloudCacheEntry, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudConnection, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type TokenProvider, type TokenStore, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeConnections, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getTracks, 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 };