Git Product home page Git Product logo

bridgestack's Introduction

BridgeStack

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.

Example Usage

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

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)
{
    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.

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.

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

The badges are then iterated, and their names are output to the console. Note that badges, while an IEnumerable<T>, contains valuable data other than the actual list items, like paging info, the actual response, exceptions that might have been thrown (and be the reason the enumeration is empty), etc.

About

I created this library as a way to give back to the StackOverflow 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.

BridgeStack is licensed under GNU/GPL.

bridgestack's People

Contributors

bevacqua 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.