Full featured SoundCloud API wrapper written in C# using .NET Standard 2.0
Install it using NuGet:
Install-Package SoundCloud.Api
SoundCloud.Api uses IHttpClientFactory
to make Http requests under the hood.
serviceCollection.AddSoundCloudClient(string.Empty, "clientId");
If you want to customize the used HttpClient:
var httpClientBuilder = serviceCollection.AddSingleton<SoundCloudClient>()
.AddSoundCloudHttpClient(string.Empty, "clientId");
// httpClientBuilder.AddHttpMessageHandler(...)
// ...
Use the SoundCloudClient to access the resources provided by SoundCloud:
string accessToken = "your access token here";
ISoundCloudClient client = SoundCloudClient.CreateAuthorized(accessToken);
IEnumerable<Tracks> myTracks = client.Me.GetTracks();
If you don't want to perfom a login, you can also access the resources by only providing your ClientId. Use this instead:
string clientId = "your client id here";
ISoundCloudClient client = SoundCloudClient.CreateUnauthorized(clientId);
As of March 2019 it's not possible to register new apps on soundcloud.com.
Due to that, there's no offical way to obtain a clientId
or OAuth token
.
But you can get the clientId
of your Browser using the DevTools (F12) and investigate the XHR requests.
If you're logged in, you can get an OAuth token
from your cookie.
If you're in possession of a ClientId
and ClientSecret
, you can use SoundCloudOAuth
to obtain a AccessToken
before creating the SoundCloudClient
.
Refreshing the AccessToken
has to be done by you. Use the OAuth Endpoint and replace the AccessToken
in yourClientInstance.AuthInfo.AccessToken
.
SoundClouds search / list APIs use linked_partitioning
.
Every response contains a URI to the next page.
SoundCloudList
maps this behavior:
var tracks = await client.Tracks.GetAllAsync();
while(true)
{
foreach (var track in tracks)
{
Console.WriteLine(track.Title);
}
if (tracks.HasNextPage)
{
tracks = await tracks.GetNextPageAsync();
}
else
{
break;
}
}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request