Skip to main content
3 of 6
deleted 106 characters in body
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60

###Complete Route Listing

The RouteFactory's factory methods are consistently and intuitively named by convention to make banging out code without intellisense code completion as painless as possible.

Here is a complete list of the RouteFactory methods and the API equivalent. Starting to see a pattern? ;-)


Api Routes

  • AnswersById = /answers/{id}
  • AnswersByIdComments = /answers/{id}/comments
  • Badges = /badges
  • BadgesById = /badges/{id}
  • BadgesName = /badges/name
  • BadgesTags = /badges/tags
  • CommentsById = /comments/{id}
  • ErrorsById = /errors/{id}
  • PostsByIdComments = /posts/{id}/comments
  • Questions = /questions
  • QuestionsById = /questions/{id}
  • QuestionsByIdAnswers = /questions/{id}/answers
  • QuestionsByIdComments = /questions/{id}/comments
  • QuestionsByIdTimeline = /questions/{id}/timeline
  • QuestionsUnanswered = /questions/unanswered
  • RevisionsById = /revisions/{id}
  • RevisionsByIdByRevisionguid = /revisions/{id}/{revisionguid}
  • Search = /search
  • Stats = /stats
  • Tags = /tags
  • Users = /users
  • UsersById = /users/{id}
  • UsersByIdAnswers = /users/{id}/answers
  • UsersByIdBadges = /users/{id}/badges
  • UsersByIdComments = /users/{id}/comments
  • UsersByIdCommentsByToid = /users/{id}/comments/{toid}
  • UsersByIdFavorites = /users/{id}/favorites
  • UsersByIdMentioned = /users/{id}/mentioned
  • UsersByIdQuestions = /users/{id}/questions
  • UsersByIdReputation = /users/{id}/reputation
  • UsersByIdTags = /users/{id}/tags
  • UsersByIdTimeline = /users/{id}/timeline
  • UsersModerators = /users/moderators

StackAuth Routes

  • Sites = /sites
  • UsersByIdAssociated = /users/{id}/associated

NOTE: the stackauth methods/routes are available on every RouteFactory instance and are not tied to a particular target site. In fact, you may simply instantiate a RouteFactory with an empty string for target. This is useful in that you need to fetch /sites (Sites) in order to get an authoritive list of api_endpoint to use as target.


So, to recap, the basic hello world for Soapi.js looks like this:

var factory = new Soapi.RouteFactory("api.stackapps.com","mykey");

var route = factory.UsersById(14);

route.getResponse(function success(data){
   alert(data.users[0].display_name); //code poet!
}, function failure(error){
   alert(error.message);
});

Remember: the data returned is the JavaScript object returned from the API method call. If you are in doubt as to what is being returned, simply look at the API help page for that route.

With an understanding of this simple code snippet, you can now easily and freely explore the Stack Overflow API with Soapi.js.

Next: Enumerated Constants, or enums, in Soapi.js

Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60