PHPackages                             janyksteenbeek/soundcloud - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. janyksteenbeek/soundcloud

ActiveLibrary

janyksteenbeek/soundcloud
=========================

PHP SDK for Soundcloud API

v0.1.1(1y ago)181MITPHP

Since Apr 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/janyksteenbeek/soundcloud-php)[ Packagist](https://packagist.org/packages/janyksteenbeek/soundcloud)[ GitHub Sponsors](https://github.com/janyksteenbeek)[ RSS](/packages/janyksteenbeek-soundcloud/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

PHP Soundcloud API SDK
======================

[](#php-soundcloud-api-sdk)

A PHP SDK for the Soundcloud API, built on [Saloon](https://github.com/saloonphp/saloon).

Installation
------------

[](#installation)

```
composer require janyksteenbeek/soundcloud
```

Basic Usage
-----------

[](#basic-usage)

```
use Janyk\Soundcloud\Soundcloud;
use Saloon\Http\Auth\TokenAuthenticator;
use Saloon\Http\Auth\QueryAuthenticator;

// Create a new Soundcloud client
$client = new Soundcloud();

// Authenticate with OAuth token (for API endpoints requiring user authentication)
$client->authenticate(new TokenAuthenticator('YOUR_ACCESS_TOKEN'));

// Or authenticate with client ID for endpoints that only require API key
// $client->authenticate(new QueryAuthenticator('client_id', 'YOUR_CLIENT_ID'));

// Get information about the authenticated user (requires OAuth authentication)
$me = $client->me()->getMyProfile();

// Get a track by ID (can work with just client ID authentication)
$track = $client->tracks()->getTrack(123456789, null);

// Search for tracks
$searchResults = $client->search()->tracks('query', null, null, 10, null, true);

// Get user likes (requires OAuth authentication)
$likes = $client->likes()->getMyLikes(10, true);

// Get a user's public profile (can work with just client ID)
$user = $client->users()->getUser(123456789);
```

Internal Mode
-------------

[](#internal-mode)

Soundcloud has an alternative API endpoint that allows more functionality with just a client ID. The SDK provides a simple way to enable this "internal" mode:

```
use Janyk\Soundcloud\Soundcloud;

$client = new Soundcloud();

// Enable internal mode with your client ID
// This automatically sets the base URL to api-v2.soundcloud.com and authenticates with your client ID
$client->enableInternalMode('YOUR_CLIENT_ID');

// Now you can access endpoints that would normally require OAuth with just your client ID
$track = $client->tracks()->getTrack(123456789, null);

// Check if internal mode is enabled
if ($client->isInternalModeEnabled()) {
    // do something specific to internal mode
}

// You can disable internal mode if needed
$client->disableInternalMode();
```

When internal mode is enabled:

- The base URL changes to `api-v2.soundcloud.com`
- The client automatically uses Query Authentication with your client ID
- Some endpoints that normally require OAuth authentication become accessible with just the client ID

This is useful for building applications that need to access certain Soundcloud features without requiring user authentication.

Authentication
--------------

[](#authentication)

### OAuth Authentication

[](#oauth-authentication)

The Soundcloud API uses OAuth 2.0 for authentication. This SDK provides methods to handle the OAuth flow.

#### Authorization Flow

[](#authorization-flow)

```
use Janyk\Soundcloud\Soundcloud;
use Saloon\Http\Auth\TokenAuthenticator;

// Step 1: Create a client for authorization
$soundcloud = new Soundcloud();

// Step 2: Get the authorization URL to redirect the user
$clientId = 'YOUR_CLIENT_ID';
$redirectUri = 'YOUR_REDIRECT_URI';
$responseType = 'code';
$state = bin2hex(random_bytes(16)); // Generate a random state for CSRF protection

// Store the state in the session for validation later
$_SESSION['oauth_state'] = $state;

// Get the authorization URL
$response = $soundcloud->oauth()->deprecatedUseSecureConnect(
    $clientId,
    $redirectUri,
    $responseType,
    $state
);

// Redirect the user to the authorization URL
// This is normally done with a proper redirect in your framework
$authUrl = $response->body();
// header('Location: ' . $authUrl);
```

#### Token Exchange and Using the API with Authentication

[](#token-exchange-and-using-the-api-with-authentication)

```
use Janyk\Soundcloud\Soundcloud;
use Saloon\Http\Auth\TokenAuthenticator;

// Step 3: After the user is redirected back to your app
// Exchange the authorization code for an access token
// This would typically be done in a separate callback route

// Verify state parameter to prevent CSRF attacks
if ($_GET['state'] !== $_SESSION['oauth_state']) {
    die('Invalid state parameter');
}

// The code will be in the query parameters after redirect
$code = $_GET['code'];

// Exchange code for token (this would be implemented by you using the token endpoint)
// $tokenResponse = $yourHttpClient->post('https://api.soundcloud.com/oauth2/token', [
//     'client_id' => 'YOUR_CLIENT_ID',
//     'client_secret' => 'YOUR_CLIENT_SECRET',
//     'grant_type' => 'authorization_code',
//     'code' => $code,
//     'redirect_uri' => 'YOUR_REDIRECT_URI'
// ]);
// $accessToken = $tokenResponse->json()['access_token'];

// For demonstration purposes only:
$accessToken = 'YOUR_ACCESS_TOKEN';

// Step 4: Create a new authenticated client
$soundcloud = new Soundcloud();
$soundcloud->authenticate(new TokenAuthenticator($accessToken));

// Now you can make authenticated requests
$myProfile = $soundcloud->me()->getMyProfile();
$myPlaylists = $soundcloud->me()->getMyPlaylists(10, true);
```

### Simple API Key Authentication

[](#simple-api-key-authentication)

For some endpoints, you can use just the client ID as an API key:

```
use Janyk\Soundcloud\Soundcloud;
use Saloon\Http\Auth\QueryAuthenticator;

// Create client with API key auth
$soundcloud = new Soundcloud();
$soundcloud->authenticate(new QueryAuthenticator('client_id', 'YOUR_CLIENT_ID'));

// Now you can make requests that only require client_id
$track = $soundcloud->tracks()->getTrack(123456789, null);
```

Available Resources
-------------------

[](#available-resources)

The SDK provides access to the following Soundcloud API resources:

### Tracks

[](#tracks)

Access and manage tracks on Soundcloud:

```
// Get a track
$track = $client->tracks()->getTrack($trackId, $secretToken);

// Upload a track
$response = $client->tracks()->uploadTrack();

// Update a track
$response = $client->tracks()->updateTrack($trackId);

// Delete a track
$response = $client->tracks()->deleteTrack($trackId);

// Get track comments
$comments = $client->tracks()->getTrackComments($trackId, $limit, $offset, $linkedPartitioning);

// Create a comment on a track
$response = $client->tracks()->createComment($trackId);

// Get track favoriters
$favoriters = $client->tracks()->trackFavoriters($trackId, $limit, $linkedPartitioning);

// Get track reposters
$reposters = $client->tracks()->trackReposters($trackId, $limit);

// Get track streams
$streams = $client->tracks()->trackStreams($trackId, $secretToken);

// Get related tracks
$related = $client->tracks()->relatedTracks($trackId, $access, $limit, $offset, $linkedPartitioning);
```

### Users

[](#users)

Access and manage user information:

```
// Get a user by ID
$user = $client->users()->getUser($userId);

// Get user playlists
$playlists = $client->users()->getUserPlaylists($userId, $limit, $linkedPartitioning);

// Get user tracks
$tracks = $client->users()->getUserTracks($userId, $limit, $linkedPartitioning);

// Get user followers
$followers = $client->users()->getUserFollowers($userId, $limit, $linkedPartitioning);

// Get users followed by a user
$followings = $client->users()->getUserFollowings($userId, $limit, $linkedPartitioning);
```

### Playlists

[](#playlists)

Access and manage playlists:

```
// Get a playlist
$playlist = $client->playlists()->getPlaylist($playlistId, $secretToken);

// Get playlist tracks
$tracks = $client->playlists()->getPlaylistTracks($playlistId, $secretToken);
```

### Me (Current User)

[](#me-current-user)

Access and manage the authenticated user's information:

```
// Get current user's profile
$profile = $client->me()->getMyProfile();

// Get current user's playlists
$playlists = $client->me()->getMyPlaylists($limit, $linkedPartitioning);

// Get current user's tracks
$tracks = $client->me()->getMyTracks($limit, $linkedPartitioning);

// Get current user's followers
$followers = $client->me()->getMyFollowers($limit, $linkedPartitioning);

// Get users followed by current user
$followings = $client->me()->getMyFollowings($limit, $linkedPartitioning);
```

### Search

[](#search)

Search for resources on Soundcloud:

```
// Search for tracks
$tracks = $client->search()->tracks($query, $tags, $genres, $limit, $offset, $linkedPartitioning);

// Search for playlists
$playlists = $client->search()->playlists($query, $limit, $offset, $linkedPartitioning);

// Search for users
$users = $client->search()->users($query, $limit, $offset, $linkedPartitioning);
```

### Likes

[](#likes)

Access and manage likes:

```
// Get user likes
$likes = $client->likes()->getUserLikes($userId, $limit, $linkedPartitioning);

// Get current user's likes
$likes = $client->likes()->getMyLikes($limit, $linkedPartitioning);
```

### Reposts

[](#reposts)

Access and manage reposts:

```
// Get user reposts
$reposts = $client->reposts()->getUserReposts($userId, $limit, $linkedPartitioning);

// Get current user's reposts
$reposts = $client->reposts()->getMyReposts($limit, $linkedPartitioning);
```

### OAuth

[](#oauth)

Handle OAuth authentication:

```
// Get OAuth token
$token = $client->oauth()->getToken();
```

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance46

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

401d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ff89bdcd628dcd42b4add24d5d88618df658f974c6909c54da30447bcc4faffc?d=identicon)[janyksteenbeek](/maintainers/janyksteenbeek)

---

Top Contributors

[![janyksteenbeek](https://avatars.githubusercontent.com/u/3578636?v=4)](https://github.com/janyksteenbeek "janyksteenbeek (4 commits)")

---

Tags

phpsaloonsdksoundcloud

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/janyksteenbeek-soundcloud/health.svg)

```
[![Health](https://phpackages.com/badges/janyksteenbeek-soundcloud/health.svg)](https://phpackages.com/packages/janyksteenbeek-soundcloud)
```

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[saloonphp/laravel-plugin

The official Laravel plugin for Saloon

765.7M125](/packages/saloonphp-laravel-plugin)[ohdearapp/ohdear-php-sdk

An SDK to easily work with the Oh Dear API

742.6M13](/packages/ohdearapp-ohdear-php-sdk)[saloonphp/rate-limit-plugin

Handle rate limits beautifully in your Saloon API integrations or SDKs

201.3M44](/packages/saloonphp-rate-limit-plugin)[saloonphp/cache-plugin

Official plugin for caching Saloon responses

122.0M64](/packages/saloonphp-cache-plugin)[myoutdeskllc/salesforce-php

salesforce library for php8+

1560.8k](/packages/myoutdeskllc-salesforce-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
