Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

Stacky - A .NET Client Library

The same great library now supports the 2.0 API!

https://bitbucket.org/lfoust/stacky

Sample Code

IUrlClient urlClient = new UrlClient();
IProtocol protocol = new JsonProtocol();

var client = new StackyClient(version, apiKey, Sites.StackOverflow, urlClient, protocol);
var questions = client.GetQuestions();
foreach (var question in questions)
{
    Console.WriteLine(question.Title);
}

Silverlight and Windows Phone

IUrlClient urlClient = new UrlClient();
IProtocol protocol = new JsonProtocol();

var client = new StackyClient(version, apiKey, Sites.StackOverflow, urlClient, protocol);
client.GetQuestions(questions =>
{
    foreach (var question in questions)
    {
        Console.WriteLine(question.Title);
    }
});

You can view more detailed documentation in Getting Started.

About

Stacky is a .NET client library for the Stack Apps API. It is a simple library and to supports a variety of platforms such as Silverlight and Windows Phone 7, .NET 4 and .NET 3.5.

License

MSPL

Download

http://stacky.codeplex.com

Source

https://bitbucket.org/lfoust/stacky

Platform

.NET (Windows, Windows Phone 7). Not tested on Mono.

Contact

Luke Foust - Feel free to contact through CodePlex site

Code

.NET 4, .NET 3.5, C#, Silverlight 4, Windows Phone 7

share|improve this question
    
How would one retrieve a tags FAQs? e.g: stackoverflow.com/tags/forms/faq –  user5408 Feb 22 '11 at 21:57
    
@eth0 - I am not aware of an easy way to get tag FAQs in the current API. You can get questions by tag and you can get linked questions but I don't know of a way to link them together and sort them. –  lfoust Feb 23 '11 at 1:08
1  
Is there any way to get a user's badges (the /user/badges route)? See this SO question: stackoverflow.com/questions/5091513/… –  Bill the Lizard Feb 23 '11 at 13:37
    
I didn't see a nuget package for version 2, and I built the 2.0 branch from source, it complains about "Sites.Stackoverflow doesn't contain a definition for "APiEndpoint" or "Description". –  George Stocker Jun 15 '12 at 0:16
    
@GeorgeStocker - Sorry, I need to do some branch merging back into main. If you build the V2 branch it should build fine. And you are right, I haven't updated the nuget package to v2 yet. –  lfoust Jun 15 '12 at 5:41
    
Any consideration of porting this over to the WinRT or as a Portable Class Library? –  KronoS Oct 10 '12 at 5:42
    
@KronoS I have considered porting to WinRT but just don't have the time. If you are interested in tackling it let me know ;) –  lfoust Oct 16 '12 at 20:45
    
@lfoust lemme get through my first build of my app and then I'll see if I can dedicate some time to port this over. If I decide to do so, I'll let you know. –  KronoS Oct 16 '12 at 22:25
    
Your bitbucket source code isn't complete. Missing some sites in sites.cs. Can I suggest that you either use the bitbucket or the codeplex as it's quite confusing which is the most up to date. –  KronoS Feb 7 '13 at 4:32
    
Also I'm working on a WinRT derivative of this. When I'm done, I'll let you know so you can approve ;) –  KronoS Feb 7 '13 at 5:03
add comment

6 Answers

Feature Request

The active questions queue shows posts that have been edited. I like to watch that. But I can't get a List of Answers sorted by activity, only Questions. I am looking for something like this

var o = new PostOptions();
o.SortBy = Sort.Activity;                
o.SortDirection = SortDirection.Descending;                
o.FromDate = DateTime.UtcNow.AddMinutes(-10);
var list = client.GetPosts(o);
share|improve this answer
add comment

With the way the API is currently set up (lots of caching the info page says) is it possible to update the information on a question you've already looked at? I have a list of questions but, as time goes on, the information changes (# of answers, votes, etc) and I would like to be able to update the questions with the new info.

share|improve this answer
    
I am not sure I understand what you mean. If you do: Question q = client.GetQuestion(12324); ...Then some time passes... and you do q = client.GetQuestion(12324); wouldn't that do the trick? Are you asking if there is a way to bypass the cache? –  lfoust Aug 4 '11 at 4:26
1  
@lfoust Yeah, but I need it to work when not very much time passes. So yeah, is there a way to bypass the cache basically. –  Seth Carnegie Aug 4 '11 at 4:39
add comment

In the StackyClient.GetQuestions function, for the tags parameter, will you get questions with any of the tags in the array, or questions that have all of the tags in the array?

Also I don't see really any documentation except for the page with a few examples, which don't explain what exactly the parameters do and stuff. If anyone could link me to a thorough documentation or tell me where to find one it would be much appreciated.

Also, this is an excellent library, and very reliable. Good job OP.

share|improve this answer
1  
Since the methods and parameters pretty much exactly mirror that of the actual stack exchange API, I decided to not repeat that work. You can view their awesome documentation here: api.stackoverflow.com/1.1/usage. Let me know if you think there would be some value in making a comprehensive documentation for Stacky which is kept in sync with the official stack exchange API documentation. –  lfoust May 25 '11 at 17:24
add comment

Thanks for this super library!

I've used it for overflow 7 - http://bit.ly/overflow7

I've put a few detailed comments on the codeplex discussion site - http://stacky.codeplex.com/Thread/View.aspx?ThreadId=242369 - hope these help.

Thanks again

Stuart

share|improve this answer
add comment

Just wanted to let everybody know that I just made a new release of the library here. This release includes tons of bug fixes as well as some breaking changes which shouldn't be a problem if you have been running off the trunk.

Also, by popular demand, I added a .Net 3.5 version of the library to this release. The hope here is to eventually have a mono version and possibly an Silverlight 3 version if there is any interest.

Please feel free to leave any feedback on the codeplex site or submit any bugs here.

Thanks for helping me make this great release!

share|improve this answer
4  
Awesome library! I'm hoping to release an "alpha" of my first app based off your library in a few days :-) –  codeka Jun 2 '10 at 23:17
    
May I suggest that you update the links in this post at least to reflect the libraries new CodePlex site stacky.codeplex.com as this might confuse new users (and defeats SEO btw. ;) –  Steffen Opel Jul 28 '10 at 9:18
    
+1 ... for mentioning the mono name :) –  explorer Feb 3 '11 at 22:44
add comment

Feature Request

If you look at my other question over here, I figured out that by specifying min&max I can get a basic "exact match" feature working for user name searches. The main problem is that StackOverflow.Net doesn't support string min and max parameters. I've added the following overloads to my own copy of UserMethods.cs:

public virtual IPagedList<User> GetUsers(string min, string max, UserSort sortBy = UserSort.Reputation, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null, string filter = null, DateTime? fromDate = null, DateTime? toDate = null)
{
    var response = MakeRequest<UserResponse>("users", null, new
    {
        key = apiKey,
        page = page ?? null,
        pagesize = pageSize ?? null,
        filter = filter,
        sort = sortBy.ToString().ToLower(),
        order = GetSortDirection(sortDirection),
        fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
        todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
        min = min ?? null,
        max = max ?? null
    });
    return new PagedList<User>(response.Users, response);
}

public virtual IPagedList<User> GetUsers(IEnumerable<int> userIds, string min, string max, UserSort sortBy = UserSort.Reputation, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null, string filter = null, DateTime? fromDate = null, DateTime? toDate = null)
{
    var response = MakeRequest<UserResponse>("users", new string[] { userIds.Vectorize() }, new
    {
        key = apiKey,
        page = page ?? null,
        pagesize = pageSize ?? null,
        filter = filter,
        sort = sortBy.ToString().ToLower(),
        order = GetSortDirection(sortDirection),
        fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
        todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
        min = min ?? null,
        max = max ?? null
    });
    return new PagedList<User>(response.Users, response);
}

Note in this overload, I had to make min and max not take default values (otherwise the overload resolution got confused if you didn't specify either of them). Not sure if that's the best way, but it works for me :)

share|improve this answer
    
I'll have to give some thought to this. I think I would prefer to just add a boolean matchExact (like you originally suggested in your question) to the method and then in the implementation I could translate that to using the min and max parameters. Exposing this min and max wierdness directly to the API consumers seems confusing to me. –  lfoust Jun 7 '10 at 15:37
    
@lfoust: Fair enough. I'd prefer the exactMatch=true way as well... –  codeka Jun 7 '10 at 20:55
    
@lfoust and codeka - the min/max parameters are still incorrectly documented as dates when in fact they should be treated as a variant string that is contextually bound to sort. see stackapps.com/questions/671 –  Sky Sanders Jun 27 '10 at 17:34
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .