<!-- thumbnail: https://i.sstatic.net/4dJqB.png -->
<!-- version: 2.0 -->
<!-- tag: library -->
<!-- excerpt: This is a StackExchange API v2.0 consumer library written under C#. It is heavily documented and designed to make it as easy as humanly possible to interact with the API. -->
![BridgeStack][1]
#BridgeStack


This is a [StackExchange][2] API v2.0 consumer library written under `C#`. It is heavily documented and designed to make it as easy as humanly possible to interact with the API.


##Example Usage


To get the name of each silver badge you've been awarded on [Stack Overflow][3]:

    var client = new StackClientFactory().Create(_appKey, _token);
    client.Default.Site = NetworkSiteEnum.StackOverflow;
    var parameters = new BadgesOnUserQuery
    {
        Sort = QuerySortEnum.BadgeRank,
        Min = BadgeRankEnum.Silver,
        Max = BadgeRankEnum.Silver
    };
    var badges = client.GetMyBadges(parameters);

    foreach (var badge in badges.Unsafe)
    {
        Console.WriteLine(badge.Name);
    }

##Line by Line Explanation:


    var client = new StackClientFactory().Create(_appKey, _token);
A `StackClient` instance is created, passing in your application's key and the user's access token.

    client.Default.Site = NetworkSiteEnum.StackOverflow;
A default is set so that all requests made through this client which require a target site use [Stack Overflow][4]

    var parameters = new BadgesOnUserQuery
    {
        Sort = QuerySortEnum.BadgeRank,
        Min = BadgeRankEnum.Silver,
        Max = BadgeRankEnum.Silver
    };
A query parameter object is created, using the `Rank` sort on badges, and setting the range to only `Silver` badges.

    var badges = client.GetMyBadges(parameters);
The API is accessed, and the user badges are received from [StackExchange][5].


    foreach (var badge in badges.Unsafe)
    {
        Console.WriteLine(badge.Name);
    }
The badges are then iterated, and their names are output to the console. Note that `Unsafe` only means that if a problem arises, `Unsafe` *can throw* an `Exception`. If we were using `Safe`, it would just have been `null`. This has to do with coding style, mostly.


##About

  
You can read the **wiki documentation on GitHub** [here][6].  
  
I created *BridgeStack* as a way to give back to the [StackOverflow][7] community, which has helped me out and taught me on countless ocassions.  
At all times I attempted to mantain the same philosophy in writting this library. I documented every method, reused as much code as possibly, mirrored the API as heavily as possible, and generally designed it with wrapping away complexity in mind.  
I would appreciate if you let me know what you think of it. I'm sure there's a lot of room for improvement.

###Download

*BridgeStack* can be downloaded following this [link][8] on GitHub.

###Platform

C# .NET 4.0

##Contact

[Nicolas Bevacqua][9]

##Code

*BridgeStack* was written under C# .NET 4.0, though I assume it wouldn't be a problem to port it to other plaforms if enough people were interested in it. You can find the full source code on [GitHub][10].


  [1]: https://i.sstatic.net/4dJqB.png
  [2]: http://stackexchange.com
  [3]: http://stackoverflow.com
  [4]: http://stackoverflow.com
  [5]: http://stackexchange.com
  [6]: https://github.com/bevacqua/BridgeStack/wiki
  [7]: http://stackoverflow.com
  [8]: https://github.com/bevacqua/BridgeStack/zipball/master
  [9]: https://github.com/bevacqua
  [10]: https://github.com/bevacqua/BridgeStack