##Soapi.CS Full API Coverage
##Soapi.CS Full API Coverage
Soapi.CS Full API Coverage
// instantiate a context
ApiContext ctx = new ApiContext("qgAq_KfDu0KYzlNG-qaTuw");
ctx.Initialize().AsyncWaitHandle.WaitOne();
// get a site
Site sofu = ctx.Official.StackOverflow;
// or
Site stackapps = ctx.Sites.First(s=>s.ApiEndpoint == "http://api.stackapps.com");
---
// StackAuth Routes
// /sites
ctx.Sites.ToList();
// /users/{id}/associated
sofu.Users.ById(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).Associated.ToList();
// /answers/{id}
sofu.Answers.ById(2917525).ToList();
// /answers/{id}/comments
sofu.Answers.ById(2907216).Comments.ToList();
// /badges
sofu.Badges.ToList();
// /badges/{id}
sofu.Badges.ById(9).ToList();
// /badges/name
// /badges/tags
sofu.Badges.Tags.ToList();
// /comments/{id}
sofu.Comments(2917319).ToList();
// /posts/{id}/comments
sofu.PostComments(2912300).ToList();
// /questions
sofu.Questions.ToList();
// /questions/{id}
sofu.Questions.ById(2912300).ToList();
// /questions/{id}/answers
sofu.Questions.ById(2912300).Answers.ToList();
// /questions/{id}/comments
sofu.Questions.ById(2912300).Comments.ToList();
// /questions/{id}/timeline
sofu.Questions.ById(2912300).Timeline.ToList();
// /questions/unanswered
sofu.Questions.Unanswered.ToList();
// /revisions/{id}
sofu.Revisions.ById(2350874).ToList();
// /revisions/{id}/{revisionguid}
sofu.Revisions.ById(2350874).RevisionIdByRevisionGuid(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).ToList();
// /search
sofu.Search.InTitle("sqlite").ToList();
// /stats
sofu.Statistics;
// /tags
sofu.Tags.ToList();
// /users
sofu.Users.ToList();
// /users/{id}
sofu.Users.ById(242897).ToList();
// /users/{id}/answers
sofu.Users.ById(242897).Answers.ToList();
// /users/{id}/badges
sofu.Users.ById(242897).Badges.ToList();
// /users/{id}/comments
sofu.Users.ById(242897).Comments.ToList();
// /users/{id}/comments/{toid}
sofu.Users.ById(242897).Comments.To(160173).ToList();
// /users/{id}/favorites
sofu.Users.ById(242897).Favorites.ToList();
// /users/{id}/mentioned
sofu.Users.ById(242897).Mentioned.ToList();
// /users/{id}/questions
sofu.Users.ById(242897).Questions.ToList();
// /users/{id}/reputation
sofu.Users.ById(242897).Reputation.ToList();
// /users/{id}/tags
sofu.Users.ById(242897).Tags.ToList();
// /users/{id}/timeline
sofu.Users.ById(242897).Timeline.ToList();
// /users/moderators
sofu.Users.Moderators.ToList();
// from the perspective of a user
sofu.User(242897).Answers.ToList();
sofu.User(242897).Badges.ToList();
sofu.User(242897).Comments.ToList();
sofu.User(242897).CommentsTo(160173).ToList();
sofu.User(242897).Favorites.ToList();
sofu.User(242897).Mentioned.ToList();
sofu.User(242897).Questions.ToList();
sofu.User(242897).RepChanges.ToList();
sofu.User(242897).Tags.ToList();
sofu.User(242897).Timeline.ToList();
// instantiate a context
ApiContext ctx = new ApiContext("qgAq_KfDu0KYzlNG-qaTuw");
ctx.Initialize().AsyncWaitHandle.WaitOne();
// get a site
Site sofu = ctx.Official.StackOverflow;
// or
Site stackapps = ctx.Sites.First(s=>s.ApiEndpoint == "http://api.stackapps.com");
---
// StackAuth Routes
// /sites
ctx.Sites.ToList();
// /users/{id}/associated
sofu.Users.ById(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).Associated.ToList();
// /answers/{id}
sofu.Answers(2917525).ToList();
// /answers/{id}/comments
sofu.Answers(2907216).Comments.ToList();
// /badges
sofu.Badges.ToList();
// /badges/{id}
sofu.Badges.ById(9).ToList();
// /badges/name
// /badges/tags
sofu.Badges.Tags.ToList();
// /comments/{id}
sofu.Comments(2917319).ToList();
// /posts/{id}/comments
sofu.PostComments(2912300).ToList();
// /questions
sofu.Questions.ToList();
// /questions/{id}
sofu.Questions.ById(2912300).ToList();
// /questions/{id}/answers
sofu.Questions.ById(2912300).Answers.ToList();
// /questions/{id}/comments
sofu.Questions.ById(2912300).Comments.ToList();
// /questions/{id}/timeline
sofu.Questions.ById(2912300).Timeline.ToList();
// /questions/unanswered
sofu.Questions.Unanswered.ToList();
// /revisions/{id}
sofu.Revisions(2350874).ToList();
// /revisions/{id}/{revisionguid}
sofu.Revisions(2350874).RevisionId(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).ToList();
// /search
sofu.Search.InTitle("sqlite").ToList();
// /stats
sofu.Statistics;
// /tags
sofu.Tags.ToList();
// /users
sofu.Users.ToList();
// /users/{id}
sofu.Users.ById(242897).ToList();
// /users/{id}/answers
sofu.Users.ById(242897).Answers.ToList();
// /users/{id}/badges
sofu.Users.ById(242897).Badges.ToList();
// /users/{id}/comments
sofu.Users.ById(242897).Comments.ToList();
// /users/{id}/comments/{toid}
sofu.Users.ById(242897).Comments.To(160173).ToList();
// /users/{id}/favorites
sofu.Users.ById(242897).Favorites.ToList();
// /users/{id}/mentioned
sofu.Users.ById(242897).Mentioned.ToList();
// /users/{id}/questions
sofu.Users.ById(242897).Questions.ToList();
// /users/{id}/reputation
sofu.Users.ById(242897).Reputation.ToList();
// /users/{id}/tags
sofu.Users.ById(242897).Tags.ToList();
// /users/{id}/timeline
sofu.Users.ById(242897).Timeline.ToList();
// /users/moderators
sofu.Users.Moderators.ToList();
// from the perspective of a user
sofu.User(242897).Answers.ToList();
sofu.User(242897).Badges.ToList();
sofu.User(242897).Comments.ToList();
sofu.User(242897).CommentsTo(160173).ToList();
sofu.User(242897).Favorites.ToList();
sofu.User(242897).Mentioned.ToList();
sofu.User(242897).Questions.ToList();
sofu.User(242897).RepChanges.ToList();
sofu.User(242897).Tags.ToList();
sofu.User(242897).Timeline.ToList();
// instantiate a context
ApiContext ctx = new ApiContext("qgAq_KfDu0KYzlNG-qaTuw");
ctx.Initialize().AsyncWaitHandle.WaitOne();
// get a site
Site sofu = ctx.Official.StackOverflow;
// or
Site stackapps = ctx.Sites.First(s=>s.ApiEndpoint == "http://api.stackapps.com");
---
// StackAuth Routes
// /sites
ctx.Sites.ToList();
// /users/{id}/associated
sofu.Users.ById(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).Associated.ToList();
// /answers/{id}
sofu.Answers.ById(2917525).ToList();
// /answers/{id}/comments
sofu.Answers.ById(2907216).Comments.ToList();
// /badges
sofu.Badges.ToList();
// /badges/{id}
sofu.Badges.ById(9).ToList();
// /badges/name
// /badges/tags
sofu.Badges.Tags.ToList();
// /comments/{id}
sofu.Comments(2917319).ToList();
// /posts/{id}/comments
sofu.PostComments(2912300).ToList();
// /questions
sofu.Questions.ToList();
// /questions/{id}
sofu.Questions.ById(2912300).ToList();
// /questions/{id}/answers
sofu.Questions.ById(2912300).Answers.ToList();
// /questions/{id}/comments
sofu.Questions.ById(2912300).Comments.ToList();
// /questions/{id}/timeline
sofu.Questions.ById(2912300).Timeline.ToList();
// /questions/unanswered
sofu.Questions.Unanswered.ToList();
// /revisions/{id}
sofu.Revisions.ById(2350874).ToList();
// /revisions/{id}/{revisionguid}
sofu.Revisions.ById(2350874).ByRevisionGuid(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).ToList();
// /search
sofu.Search.InTitle("sqlite").ToList();
// /stats
sofu.Statistics;
// /tags
sofu.Tags.ToList();
// /users
sofu.Users.ToList();
// /users/{id}
sofu.Users.ById(242897).ToList();
// /users/{id}/answers
sofu.Users.ById(242897).Answers.ToList();
// /users/{id}/badges
sofu.Users.ById(242897).Badges.ToList();
// /users/{id}/comments
sofu.Users.ById(242897).Comments.ToList();
// /users/{id}/comments/{toid}
sofu.Users.ById(242897).Comments.To(160173).ToList();
// /users/{id}/favorites
sofu.Users.ById(242897).Favorites.ToList();
// /users/{id}/mentioned
sofu.Users.ById(242897).Mentioned.ToList();
// /users/{id}/questions
sofu.Users.ById(242897).Questions.ToList();
// /users/{id}/reputation
sofu.Users.ById(242897).Reputation.ToList();
// /users/{id}/tags
sofu.Users.ById(242897).Tags.ToList();
// /users/{id}/timeline
sofu.Users.ById(242897).Timeline.ToList();
// /users/moderators
sofu.Users.Moderators.ToList();
// from the perspective of a user
sofu.User(242897).Answers.ToList();
sofu.User(242897).Badges.ToList();
sofu.User(242897).Comments.ToList();
sofu.User(242897).CommentsTo(160173).ToList();
sofu.User(242897).Favorites.ToList();
sofu.User(242897).Mentioned.ToList();
sofu.User(242897).Questions.ToList();
sofu.User(242897).RepChanges.ToList();
sofu.User(242897).Tags.ToList();
sofu.User(242897).Timeline.ToList();
##Soapi.CS Basic UsageFull API Coverage
static// Various()instantiate a context
{
ApiContext ctx = wl("setupnew ApiContext one time"("qgAq_KfDu0KYzlNG-qaTuw");
ApiContextctx.Initialize(ApiKey).AsyncWaitHandle.WaitOne();
// get a site
Site sofu = ctx.Official.StackOverflow;
// or
Site stackapps = ctx.AsyncWaitHandleSites.WaitOneFirst(s=>s.ApiEndpoint == "http://api.stackapps.com");
}
public static---
// voidStackAuth ContextUsage()
{Routes
// /sites wl("Once initialized, the static ApiContext can be used to create context instances that can be used to access the API"
ctx.Sites.ToList();
// /users/{id}/associated var ctx = ApiContext
sofu.CreateUsers.ById(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).Associated.ToList();
// /answers/{id} wl("'Official' sites have statically typed accessors
sofu."Answers(2917525).ToList();
// /answers/{id}/comments Site sof = ctx.StackOverflow;
Console
sofu.WriteLineAnswers(sof2907216).NameComments.ToList();
// /badges wl("Area 51 sites in incubation can be accessed usingthe api endpoint.");
Site web = ctx.FindSite("http://api.webapps.stackexchange.com");
Console
sofu.WriteLine(webBadges.NameToList();
// wl("you/badges/{id} may discover available sites on the context .Sites collection");
ctx.Sites.ForEach(s => Console.WriteLine(s.Name + " " + s
sofu.ApiEndpointBadges.ById(9).ToList();
// /badges/name wl("Each site exposes it's own properties, as listed on /sites");
Console.WriteLine("sofu link color is {0}", sof.Styling.LinkColor);
// /badges/tags wl("as well as lazy loaded statistics.");
Console.WriteLine("sofu answers per minute: {0}", sof
sofu.StatisticsBadges.AnswersPerMinuteTags.ToList();
// /comments/{id} wl("as well as collections that correspond to API paths");
wl("/users - the poets");
sofsofu.UsersComments(filter: "poet"2917319).ForEach(u => Console.WriteLineToList(u.DisplayName));
// wl("/usersposts/{id}/comments - the gurus"
sofu.PostComments(2912300).ToList();
// /questions sof.Users(22656, 23354, 95810, 18393)
.ForEach(u => Console.WriteLine("{0} - {1}", u.DisplayName, u
sofu.Reputation)Questions.ToList();
// /questions/{id} wl("and then there is me. ;-\\");
User codePoet = sof
sofu.UserQuestions.ById(2428972912300).ToList();
// /questions/{id}/answers Console
sofu.WriteLineQuestions.ById("2912300).Answers.ToList();
// /questions/{0id}/comments - {1}", codePoet.DisplayName, codePoet
sofu.ReputationQuestions.ById(2912300).Comments.ToList();
// /questions/{id}/timeline wl("Various objects, such as User, expose
sofu.Questions.ById(2912300).Timeline.ToList();
// lazy/questions/unanswered loaded properties and eager loading collections that correspond to API paths
sofu."Questions.Unanswered.ToList();
// /revisions/{id} Answer myLeastPopularAnswer = codePoet.Answers(sort: PostSort.Votes, order: SortOrder.Asc, pagesize: 1
sofu.Revisions(2350874).FirstToList();
// /revisions/{id}/{revisionguid}
sofu.Revisions(2350874).RevisionId(new ConsoleGuid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).WriteLineToList("My);
// least/search popular ({0}) answer was to {1}", myLeastPopularAnswer.Score, myLeastPopularAnswer.Title);
wl("an example of lazy loading would be the question that this answer belongs to
sofu.Search."InTitle("sqlite").ToList();
// /stats Question theQuestion = myLeastPopularAnswer.Question;
Console.WriteLine("the q was related to {0}", string.Join(" ", theQuestion.Tags));
wl("I wonder what questions where
sofu.Statistics;
// asked/tags by the author of this question?");
theQuestion.Owner.Questions().ForEach(q => Console.WriteLine(q.Title));
wl("Ok, talking about me is making me feel silly"
sofu.Tags.ToList();
// /users wl("lets fall back on skeet's sofu user account for the rest of this walk-through");
User skeet = ctx
sofu.StackOverflowUsers.UserToList(22656);
// /users/{id} wl("lets get jon's globally aggregated reputation");
Console.WriteLine("Skeet's Global Rep: {0}",
skeet.Associated
sofu.Users.SumById(u => u.Reputation242897).ToList();
// /users/{id}/answers wl("how many answers has jon given on all stack exchange?"
sofu.Users.ById(242897).Answers.ToList();
// /users/{id}/badges skeet.Associated.Users.ForEach(u =>
Console.WriteLine("{0} : {1}", u.Site
sofu.Name, uUsers.AnswerCountById(242897).Badges.ToList();
// /users/{id}/comments wl("lets find out something about the people that asked the
sofu.Users.ById(242897).Comments.ToList();
// questions/users/{id}/comments/{toid} for jon's top rated answeres"
sofu.Users.ById(242897).Comments.To(160173).ToList();
// /users/{id}/favorites skeet.Associated
sofu.Users.WhereById(u242897).Favorites.ToList();
// =>/users/{id}/mentioned u.AnswerCount > 0)
sofu.ToListUsers.ById(242897).ForEachMentioned.ToList(u =>);
// /users/{id}/questions {
sofu.Users.ById(242897).Questions.ToList();
// /users/{id}/reputation var topA = u
sofu.Answers(sort: PostSortUsers.Votes, pagesize: 1ById(242897).FirstOrDefaultReputation.ToList();
// /users/{id}/tags var topAQ = topA
sofu.Question;Users.ById(242897).Tags.ToList();
// /users/{id}/timeline Console
sofu.WriteLineUsers.ById("{0} {1} asked '{2}'", topAQ242897).SiteTimeline.Name,ToList();
// /users/moderators topAQ
sofu.OwnerUsers.DisplayName, topAQModerators.TitleToList();
// from the perspective of a }user
sofu.User(242897).Answers.ToList();
sofu.User(242897).Badges.ToList();
}sofu.User(242897).Comments.ToList();
sofu.User(242897).CommentsTo(160173).ToList();
sofu.User(242897).Favorites.ToList();
sofu.User(242897).Mentioned.ToList();
sofu.User(242897).Questions.ToList();
sofu.User(242897).RepChanges.ToList();
sofu.User(242897).Tags.ToList();
sofu.User(242897).Timeline.ToList();
OUTPUT:
setup ApiContext one time
Once initialized, the static ApiContext can be used to create context instances that can be used to access the API
'Official' sites have statically typed accessors.
Stack Overflow
Area 51 sites in incubation can be accessed usingthe api endpoint.
Web Apps
you may discover available sites on the context .Sites collection
Stack Overflow http://api.stackoverflow.com/
Server Fault http://api.serverfault.com/
Super User http://api.superuser.com/
Meta Stack Overflow http://api.meta.stackoverflow.com/
Web Apps http://api.webapps.stackexchange.com/
Web Apps Meta http://api.meta.webapps.stackexchange.com/
Gaming http://api.gaming.stackexchange.com/
Gaming Meta http://api.meta.gaming.stackexchange.com/
Webmasters http://api.webmasters.stackexchange.com/
Webmasters Meta http://api.meta.webmasters.stackexchange.com/
Cooking http://api.cooking.stackexchange.com/
Cooking Meta http://api.meta.cooking.stackexchange.com/
Game Developers http://api.gamedev.stackexchange.com/
Game Developers Meta http://api.meta.gamedev.stackexchange.com/
Electronic Gadgets http://api.gadgets.stackexchange.com/
Electronic Gadgets Meta http://api.meta.gadgets.stackexchange.com/
Photography http://api.photo.stackexchange.com/
Photography Meta http://api.meta.photo.stackexchange.com/
Statistical Analysis http://api.stats.stackexchange.com/
Statistical Analysis Meta http://api.meta.stats.stackexchange.com/
Mathematics http://api.math.stackexchange.com/
Mathematics Meta http://api.meta.math.stackexchange.com/
Home Improvement http://api.diy.stackexchange.com/
Home Improvement Meta http://api.meta.diy.stackexchange.com/
Meta Super User http://api.meta.superuser.com/
Meta Server Fault http://api.meta.serverfault.com/
GIS http://api.gis.stackexchange.com/
GIS Meta http://api.meta.gis.stackexchange.com/
TeX - LaTeX http://api.tex.stackexchange.com/
TeX - LaTeX Meta http://api.meta.tex.stackexchange.com/
Ubuntu http://api.ubuntu.stackexchange.com/
Ubuntu Meta http://api.meta.ubuntu.stackexchange.com/
Stack Apps http://api.stackapps.com/
Each site exposes it's own properties, as listed on /sites
sofu link color is #0077CC
as well as lazy loaded statistics.
sofu answers per minute: 1.85
as well as collections that correspond to API paths
/users - the poets
code poet
Integer Poet
poeticGeek
VogonPoet
CodePoet
guitarpoet
JPoetker
VogonPoet
absurdpoet
codepoet
deadpoet
wpoet
madpoet
kornypoet
poetofzwan
imaginethepoet
/users/{id} - the gurus
cletus - 119868
Jon Skeet - 200899
Marc Gravell - 157483
Alex Martelli - 124229
and then there is me. ;-\
code poet - 10617
Various objects, such as User, expose lazy loaded properties and eager loading collections that correspond to API paths.
My least popular (0) answer was to What causes Cassini to load when I run a unit test
an example of lazy loading would be the question that this answer belongs to..
the q was related to tdd cassini
I wonder what questions where asked by the author of this question?
RegistryKey ValueCount/SubKeyCount wrong
SMO ManagedComputer.ServiceInstances is empty
How do I query delegation properties of an active directory user account?
What causes Cassini to load when I run a unit test
WCF Service Operation - GET Fails with 404
Newbie: Build error running Struts2 on JBoss from Eclipse
Silverlight Xaml: Referencing Code-behind class
Decoupling Silverlight client from service reference generated class
Silverlight: Problem customizing the DatePicker template
Xaml: Bind to a single child in a collection
Creating mock data for unit testing
ParameterMismatch exception when using Moq Callback method
Ok, talking about me is making me feel silly
lets fall back on skeet's sofu user account for the rest of this walk-through
lets get jon's globally aggregated reputation
Skeet's Global Rep: 239766
how many answers has jon given on all stack exchange?
Meta Stack Overflow : 510
Server Fault : 15
Stack Apps : 0
Stack Overflow : 9173
Super User : 40
Web Apps : 2
Web Apps Meta : 0
lets find out something about the people that asked the questions for jon's top rated answeres
Meta Stack Overflow Bill the Lizard asked 'Jon Skeet Facts?'
Server Fault Sebastian Hoitz asked 'Shell command to monitor changes in a file - What's it called again?'
Stack Overflow xelurg asked '"Hello World" in less than 20 bytes'
Super User Bruce McLeod asked 'What is your default web browser and why?'
Web Apps Jeffrey asked 'What keyboard shortcuts in Gmail are helpful?'
Request Log:
http://stackauth.com/1.0/sites?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/stats?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users?filter=poet&key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/23354;95810;18393;22656?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/242897?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/242897/answers?order=Asc&pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/questions/533412?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/64690?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/64690/questions?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/22656?key=xxxxxxxxxxx
http://stackauth.com/1.0/users/a1c71168-ffb9-42a5-8d71-ce38ad8f2c79/associated?key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/users/22656?key=xxxxxxxxxxx
http://api.serverfault.com/1.0/users/173?key=xxxxxxxxxxx
http://api.stackapps.com/1.0/users/69?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/22656?key=xxxxxxxxxxx
http://api.superuser.com/1.0/users/410?key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/users/44?key=xxxxxxxxxxx
http://api.meta.webapps.stackexchange.com/1.0/users/44?key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/users/22656/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/questions/9134?key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/users/1288?key=xxxxxxxxxxx
http://api.serverfault.com/1.0/users/173/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.serverfault.com/1.0/questions/1669?key=xxxxxxxxxxx
http://api.serverfault.com/1.0/users/1127?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/22656/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/questions/284797?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/35520?key=xxxxxxxxxxx
http://api.superuser.com/1.0/users/410/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.superuser.com/1.0/questions/658?key=xxxxxxxxxxx
http://api.superuser.com/1.0/users/372?key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/users/44/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/questions/741?key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/users/69?key=xxxxxxxxxxx
##Soapi.CS Basic Usage
static Various()
{
wl("setup ApiContext one time");
ApiContext.Initialize(ApiKey)
.AsyncWaitHandle.WaitOne();
}
public static void ContextUsage()
{
wl("Once initialized, the static ApiContext can be used to create context instances that can be used to access the API");
var ctx = ApiContext.Create();
wl("'Official' sites have statically typed accessors.");
Site sof = ctx.StackOverflow;
Console.WriteLine(sof.Name);
wl("Area 51 sites in incubation can be accessed usingthe api endpoint.");
Site web = ctx.FindSite("http://api.webapps.stackexchange.com");
Console.WriteLine(web.Name);
wl("you may discover available sites on the context .Sites collection");
ctx.Sites.ForEach(s => Console.WriteLine(s.Name + " " + s.ApiEndpoint));
wl("Each site exposes it's own properties, as listed on /sites");
Console.WriteLine("sofu link color is {0}", sof.Styling.LinkColor);
wl("as well as lazy loaded statistics.");
Console.WriteLine("sofu answers per minute: {0}", sof.Statistics.AnswersPerMinute);
wl("as well as collections that correspond to API paths");
wl("/users - the poets");
sof.Users(filter: "poet").ForEach(u => Console.WriteLine(u.DisplayName));
wl("/users/{id} - the gurus");
sof.Users(22656, 23354, 95810, 18393)
.ForEach(u => Console.WriteLine("{0} - {1}", u.DisplayName, u.Reputation));
wl("and then there is me. ;-\\");
User codePoet = sof.User(242897);
Console.WriteLine("{0} - {1}", codePoet.DisplayName, codePoet.Reputation);
wl("Various objects, such as User, expose lazy loaded properties and eager loading collections that correspond to API paths.");
Answer myLeastPopularAnswer = codePoet.Answers(sort: PostSort.Votes, order: SortOrder.Asc, pagesize: 1).First();
Console.WriteLine("My least popular ({0}) answer was to {1}", myLeastPopularAnswer.Score, myLeastPopularAnswer.Title);
wl("an example of lazy loading would be the question that this answer belongs to..");
Question theQuestion = myLeastPopularAnswer.Question;
Console.WriteLine("the q was related to {0}", string.Join(" ", theQuestion.Tags));
wl("I wonder what questions where asked by the author of this question?");
theQuestion.Owner.Questions().ForEach(q => Console.WriteLine(q.Title));
wl("Ok, talking about me is making me feel silly");
wl("lets fall back on skeet's sofu user account for the rest of this walk-through");
User skeet = ctx.StackOverflow.User(22656);
wl("lets get jon's globally aggregated reputation");
Console.WriteLine("Skeet's Global Rep: {0}",
skeet.Associated.Users.Sum(u => u.Reputation));
wl("how many answers has jon given on all stack exchange?");
skeet.Associated.Users.ForEach(u =>
Console.WriteLine("{0} : {1}", u.Site.Name, u.AnswerCount));
wl("lets find out something about the people that asked the questions for jon's top rated answeres");
skeet.Associated.Users.Where(u => u.AnswerCount > 0)
.ToList().ForEach(u =>
{
var topA = u.Answers(sort: PostSort.Votes, pagesize: 1).FirstOrDefault();
var topAQ = topA.Question;
Console.WriteLine("{0} {1} asked '{2}'", topAQ.Site.Name,
topAQ.Owner.DisplayName, topAQ.Title);
});
}
OUTPUT:
setup ApiContext one time
Once initialized, the static ApiContext can be used to create context instances that can be used to access the API
'Official' sites have statically typed accessors.
Stack Overflow
Area 51 sites in incubation can be accessed usingthe api endpoint.
Web Apps
you may discover available sites on the context .Sites collection
Stack Overflow http://api.stackoverflow.com/
Server Fault http://api.serverfault.com/
Super User http://api.superuser.com/
Meta Stack Overflow http://api.meta.stackoverflow.com/
Web Apps http://api.webapps.stackexchange.com/
Web Apps Meta http://api.meta.webapps.stackexchange.com/
Gaming http://api.gaming.stackexchange.com/
Gaming Meta http://api.meta.gaming.stackexchange.com/
Webmasters http://api.webmasters.stackexchange.com/
Webmasters Meta http://api.meta.webmasters.stackexchange.com/
Cooking http://api.cooking.stackexchange.com/
Cooking Meta http://api.meta.cooking.stackexchange.com/
Game Developers http://api.gamedev.stackexchange.com/
Game Developers Meta http://api.meta.gamedev.stackexchange.com/
Electronic Gadgets http://api.gadgets.stackexchange.com/
Electronic Gadgets Meta http://api.meta.gadgets.stackexchange.com/
Photography http://api.photo.stackexchange.com/
Photography Meta http://api.meta.photo.stackexchange.com/
Statistical Analysis http://api.stats.stackexchange.com/
Statistical Analysis Meta http://api.meta.stats.stackexchange.com/
Mathematics http://api.math.stackexchange.com/
Mathematics Meta http://api.meta.math.stackexchange.com/
Home Improvement http://api.diy.stackexchange.com/
Home Improvement Meta http://api.meta.diy.stackexchange.com/
Meta Super User http://api.meta.superuser.com/
Meta Server Fault http://api.meta.serverfault.com/
GIS http://api.gis.stackexchange.com/
GIS Meta http://api.meta.gis.stackexchange.com/
TeX - LaTeX http://api.tex.stackexchange.com/
TeX - LaTeX Meta http://api.meta.tex.stackexchange.com/
Ubuntu http://api.ubuntu.stackexchange.com/
Ubuntu Meta http://api.meta.ubuntu.stackexchange.com/
Stack Apps http://api.stackapps.com/
Each site exposes it's own properties, as listed on /sites
sofu link color is #0077CC
as well as lazy loaded statistics.
sofu answers per minute: 1.85
as well as collections that correspond to API paths
/users - the poets
code poet
Integer Poet
poeticGeek
VogonPoet
CodePoet
guitarpoet
JPoetker
VogonPoet
absurdpoet
codepoet
deadpoet
wpoet
madpoet
kornypoet
poetofzwan
imaginethepoet
/users/{id} - the gurus
cletus - 119868
Jon Skeet - 200899
Marc Gravell - 157483
Alex Martelli - 124229
and then there is me. ;-\
code poet - 10617
Various objects, such as User, expose lazy loaded properties and eager loading collections that correspond to API paths.
My least popular (0) answer was to What causes Cassini to load when I run a unit test
an example of lazy loading would be the question that this answer belongs to..
the q was related to tdd cassini
I wonder what questions where asked by the author of this question?
RegistryKey ValueCount/SubKeyCount wrong
SMO ManagedComputer.ServiceInstances is empty
How do I query delegation properties of an active directory user account?
What causes Cassini to load when I run a unit test
WCF Service Operation - GET Fails with 404
Newbie: Build error running Struts2 on JBoss from Eclipse
Silverlight Xaml: Referencing Code-behind class
Decoupling Silverlight client from service reference generated class
Silverlight: Problem customizing the DatePicker template
Xaml: Bind to a single child in a collection
Creating mock data for unit testing
ParameterMismatch exception when using Moq Callback method
Ok, talking about me is making me feel silly
lets fall back on skeet's sofu user account for the rest of this walk-through
lets get jon's globally aggregated reputation
Skeet's Global Rep: 239766
how many answers has jon given on all stack exchange?
Meta Stack Overflow : 510
Server Fault : 15
Stack Apps : 0
Stack Overflow : 9173
Super User : 40
Web Apps : 2
Web Apps Meta : 0
lets find out something about the people that asked the questions for jon's top rated answeres
Meta Stack Overflow Bill the Lizard asked 'Jon Skeet Facts?'
Server Fault Sebastian Hoitz asked 'Shell command to monitor changes in a file - What's it called again?'
Stack Overflow xelurg asked '"Hello World" in less than 20 bytes'
Super User Bruce McLeod asked 'What is your default web browser and why?'
Web Apps Jeffrey asked 'What keyboard shortcuts in Gmail are helpful?'
Request Log:
http://stackauth.com/1.0/sites?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/stats?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users?filter=poet&key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/23354;95810;18393;22656?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/242897?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/242897/answers?order=Asc&pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/questions/533412?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/64690?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/64690/questions?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/22656?key=xxxxxxxxxxx
http://stackauth.com/1.0/users/a1c71168-ffb9-42a5-8d71-ce38ad8f2c79/associated?key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/users/22656?key=xxxxxxxxxxx
http://api.serverfault.com/1.0/users/173?key=xxxxxxxxxxx
http://api.stackapps.com/1.0/users/69?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/22656?key=xxxxxxxxxxx
http://api.superuser.com/1.0/users/410?key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/users/44?key=xxxxxxxxxxx
http://api.meta.webapps.stackexchange.com/1.0/users/44?key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/users/22656/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/questions/9134?key=xxxxxxxxxxx
http://api.meta.stackoverflow.com/1.0/users/1288?key=xxxxxxxxxxx
http://api.serverfault.com/1.0/users/173/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.serverfault.com/1.0/questions/1669?key=xxxxxxxxxxx
http://api.serverfault.com/1.0/users/1127?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/22656/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/questions/284797?key=xxxxxxxxxxx
http://api.stackoverflow.com/1.0/users/35520?key=xxxxxxxxxxx
http://api.superuser.com/1.0/users/410/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.superuser.com/1.0/questions/658?key=xxxxxxxxxxx
http://api.superuser.com/1.0/users/372?key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/users/44/answers?pagesize=1&sort=Votes&key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/questions/741?key=xxxxxxxxxxx
http://api.webapps.stackexchange.com/1.0/users/69?key=xxxxxxxxxxx
##Soapi.CS Full API Coverage
// instantiate a context
ApiContext ctx = new ApiContext("qgAq_KfDu0KYzlNG-qaTuw");
ctx.Initialize().AsyncWaitHandle.WaitOne();
// get a site
Site sofu = ctx.Official.StackOverflow;
// or
Site stackapps = ctx.Sites.First(s=>s.ApiEndpoint == "http://api.stackapps.com");
---
// StackAuth Routes
// /sites
ctx.Sites.ToList();
// /users/{id}/associated
sofu.Users.ById(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).Associated.ToList();
// /answers/{id}
sofu.Answers(2917525).ToList();
// /answers/{id}/comments
sofu.Answers(2907216).Comments.ToList();
// /badges
sofu.Badges.ToList();
// /badges/{id}
sofu.Badges.ById(9).ToList();
// /badges/name
// /badges/tags
sofu.Badges.Tags.ToList();
// /comments/{id}
sofu.Comments(2917319).ToList();
// /posts/{id}/comments
sofu.PostComments(2912300).ToList();
// /questions
sofu.Questions.ToList();
// /questions/{id}
sofu.Questions.ById(2912300).ToList();
// /questions/{id}/answers
sofu.Questions.ById(2912300).Answers.ToList();
// /questions/{id}/comments
sofu.Questions.ById(2912300).Comments.ToList();
// /questions/{id}/timeline
sofu.Questions.ById(2912300).Timeline.ToList();
// /questions/unanswered
sofu.Questions.Unanswered.ToList();
// /revisions/{id}
sofu.Revisions(2350874).ToList();
// /revisions/{id}/{revisionguid}
sofu.Revisions(2350874).RevisionId(new Guid("d6b99e8e-0f6c-4f68-92d0-6a050feea1fc")).ToList();
// /search
sofu.Search.InTitle("sqlite").ToList();
// /stats
sofu.Statistics;
// /tags
sofu.Tags.ToList();
// /users
sofu.Users.ToList();
// /users/{id}
sofu.Users.ById(242897).ToList();
// /users/{id}/answers
sofu.Users.ById(242897).Answers.ToList();
// /users/{id}/badges
sofu.Users.ById(242897).Badges.ToList();
// /users/{id}/comments
sofu.Users.ById(242897).Comments.ToList();
// /users/{id}/comments/{toid}
sofu.Users.ById(242897).Comments.To(160173).ToList();
// /users/{id}/favorites
sofu.Users.ById(242897).Favorites.ToList();
// /users/{id}/mentioned
sofu.Users.ById(242897).Mentioned.ToList();
// /users/{id}/questions
sofu.Users.ById(242897).Questions.ToList();
// /users/{id}/reputation
sofu.Users.ById(242897).Reputation.ToList();
// /users/{id}/tags
sofu.Users.ById(242897).Tags.ToList();
// /users/{id}/timeline
sofu.Users.ById(242897).Timeline.ToList();
// /users/moderators
sofu.Users.Moderators.ToList();
// from the perspective of a user
sofu.User(242897).Answers.ToList();
sofu.User(242897).Badges.ToList();
sofu.User(242897).Comments.ToList();
sofu.User(242897).CommentsTo(160173).ToList();
sofu.User(242897).Favorites.ToList();
sofu.User(242897).Mentioned.ToList();
sofu.User(242897).Questions.ToList();
sofu.User(242897).RepChanges.ToList();
sofu.User(242897).Tags.ToList();
sofu.User(242897).Timeline.ToList();
Loading
Loading
Loading
default