Giter Site home page Giter Site logo

soundcloud.api's Introduction

SoundCloud.Api

Nuget

Full featured SoundCloud API wrapper written in C# using .NET Standard 2.0

Installation

Install it using NuGet:

Install-Package SoundCloud.Api

Information

SoundCloud.Api uses IHttpClientFactory to make Http requests under the hood.

Usage

With Dependency Injection

serviceCollection.AddSoundCloudClient(string.Empty, "clientId");

If you want to customize the used HttpClient:

var httpClientBuilder = serviceCollection.AddSingleton<SoundCloudClient>()
                                         .AddSoundCloudHttpClient(string.Empty, "clientId");
                                         
// httpClientBuilder.AddHttpMessageHandler(...)
// ...

Without Dependency Injection

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

How to obtain a ClientId and OAuth Token

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.

Lists

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

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

MIT License

soundcloud.api's People

Contributors

prayzzz avatar ryuzakih avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.