soundcloud-api-ts - v1.9.0
    Preparing search index...

    Class SoundCloudClient

    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.

    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);
    }
    Index

    Constructors

    Properties

    auth: Auth

    Authentication methods (OAuth token grants, sign out)

    likes: Likes

    Like/unlike actions (/likes)

    me: Me

    Authenticated user endpoints (/me)

    playlists: Playlists

    Playlist endpoints (/playlists)

    reposts: Reposts

    Repost/unrepost actions (/reposts)

    resolve: Resolve

    URL resolution endpoint (/resolve)

    search: Search

    Search endpoints

    tracks: Tracks

    Track endpoints (/tracks)

    users: Users

    User profile endpoints (/users)

    Accessors

    • get accessToken(): string | undefined

      Get the currently stored access token, or undefined if none is set.

      Returns string | undefined

    • get refreshToken(): string | undefined

      Get the currently stored refresh token, or undefined if none is set.

      Returns string | undefined

    Methods

    • Collects all pages into a single flat array.

      Type Parameters

      • T

      Parameters

      • firstPage: () => Promise<SoundCloudPaginatedResponse<T>>

        Function that fetches the first page

      • Optionaloptions: { maxItems?: number }

        Optional configuration

        • OptionalmaxItems?: number

          Maximum number of items to collect

      Returns Promise<T[]>

      A promise resolving to a flat array of all items

      const allTracks = await sc.fetchAll(() => sc.search.tracks('lofi'), { maxItems: 100 });
      console.log(allTracks.length);
    • Async generator that follows next_href automatically, yielding each page's collection.

      Type Parameters

      • T

      Parameters

      Returns AsyncGenerator<T[], void, undefined>

      An async generator yielding arrays of items (one per page)

      for await (const page of sc.paginate(() => sc.search.tracks('lofi'))) {
      console.log(page); // SoundCloudTrack[]
      }
    • Async generator that yields individual items across all pages.

      Type Parameters

      • T

      Parameters

      Returns AsyncGenerator<T, void, undefined>

      An async generator yielding individual items

      for await (const track of sc.paginateItems(() => sc.search.tracks('lofi'))) {
      console.log(track.title); // single SoundCloudTrack
      }
    • Store an access token (and optionally refresh token) on this client instance.

      Parameters

      • accessToken: string

        The OAuth access token to store

      • OptionalrefreshToken: string

        Optional refresh token for automatic token renewal

      Returns void