Giter Club home page Giter Club logo

discogsclient's Introduction

DiscogsClient

Build status NuGet Badge MIT License

C# Client library for Discogs API v2.0

Features

  • Include API to authorize user (generating OAuth1.0 token and token secret)
  • Full support to DataBase API including image download
  • Support of identity API
  • Transparent support of rate limit
  • Asynchroneous and cancellable API using Tasks
  • Transparent management of pagination using none blocking API (Reactive IObservable) or IEnumerable

Sample usage

Create discogs client

  • Oauth authentication
  //Create authentication object using private and public keys: you should fournish real keys here
  var oAuthCompleteInformation = new OAuthCompleteInformation("consumerKey", 
                                  "consumerSecret", "token", "tokenSecret");
  //Create discogs client using the authentication
  var discogsClient = new DiscogsClient(oAuthCompleteInformation);
  • Token based authentication
  //Create authentication based on Discogs token
  var tokenInformation = new TokenAuthenticationInformation("my-token");
  //Create discogs client using the authentication
  var discogsClient = new DiscogsClient(tokenInformation);

Search The DataBase

Using IObservable:

var discogsSearch = new DiscogsSearch()
{
  artist = "Ornette Coleman",
  release_title = "The Shape Of Jazz To Come"
};
    
//Retrieve observable result from search
var observable = _DiscogsClient.Search(discogsSearch);

Using IEnumerable:

//Alternatively retreive same result as enumerable 
var enumerable = _DiscogsClient.SearchAsEnumerable(discogsSearch);

Get Release, Master, Artist or Label Information

var release = await _DiscogsClient.GetReleaseAsync(1704673);
var master = await _DiscogsClient.GetMasterAsync(47813);
var artist = await _DiscogsClient.GetArtistAsync(224506);
var label = await _DiscogsClient.GetLabelAsync(125);

Download Image

//Retrieve Release information
var res = await _DiscogsClient.GetMasterAsync(47813);
  
//Download the first image of the release
await _DiscogsClient.SaveImageAsync(res.images[0], Path.GetTempPath(), "Ornette-TSOAJTC");

OAuth: Authorize new user

//Create authentificator information: you should fournish real keys here
var oAuthConsumerInformation = new OAuthConsumerInformation("consumerKey", "consumerSecret");
  
//Create Authentifier client
var discogsAuthentifierClient = new DiscogsAuthentifierClient(oAuthConsumerInformation);

//Retreive Token and Token secret 
var oauth = discogsClient.Authorize(s => Task.FromResult(GetToken(s))).Result;

Authorize takes a Func< string, Task< string>> as parameter, receiving the authentication url and returning the corresponding access key. Trivial implementation:

private static string GetToken(string url)
{
  Console.WriteLine("Please authorize the application and enter the final key in the console");
  Process.Start(url);
  return Console.ReadLine();
}

See DiscogsClientTest and DiscogsAuthenticationConsole for full samples of available APIs.

discogsclient's People

Contributors

david-desmaisons avatar steven-r avatar

Watchers

 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.