Smack my BitSharp!

Posted by on

Open Source

Its an open source .NET client for the BandsInTown API.

TBODA currently have a number of web projects that focus on Live music, such as, and through these projects I have worked very closely with a lot of gig guide APIs. So i thought I'd make some of my code reusable but not just by me, thus BitSharp was born.

Now I'm a big fan of RestSharp (The .NET Rest Client) so BitSharp uses it for all the API requests and Responses. BitSharp is still in early development but most of the event and artist functions are working.

Now for the code to us it:

var client = new BitClient("API_KEY_HERE");

Artist artist = null;
    artist = client.Artists_Get("de11b037-d880-40e0-8901-0397c768c457");
catch (BitException ex)
    Console.WriteLine("BandsInTown Error:" + ex.Message);

Console.WriteLine("Bytes received: " + client.DataCount);

Starting by creating an instance of the BitClient with the APIKey this object is then what we use to make all the requests to the API so its a good idea to keep this at the global level that way you only need 1 instance.

Then inside the Try/Catch is where we call the Artists_Get function (this function simply gets artist info given the MusicBrainz ID). All the API Functions throw a BitException if an error is returned from the API so this exception is then caught.

Now that we have called the Artists_Get function we get an Artist object returned and its as easy as that.

The other BitSharp functions currently implemented include: (Updated)

  • Events_Search (Search for events either by artist(s), location or date)
  • Events_Daily (Returns a list of events that have been created updated or deleted in the last day)
  • Events_Recommended (Gets recommended events either by artist(s), location or date)
  • Artists_Events (Returns an artists upcoming events)
  • Artists_Get (Gets information on a single Artist)
  • Venues_Search (Search for venues by name and/or location)
  • Venues_Events (Returns a venues upcoming events)

You can find the source for BitSharp @ Github.