stack-exchange
The stack-exchange is a simple npm module that provides a wrapper to access StackOverflow API endpoint.
Installation
Installation is done using the npm install command:
$ npm install stack-exchange
Quick Start
You can make 300 requests without a key per day, with a key you can make 10,000 requests. To generate key visit here.The sections are as follows
- Users section
- Me section
- Questions section
- Answers section
- Badges section
- Tags section
- Comments section
- Posts section
- Search section
- Suggested Edits section
- Network section
- Info section
- Privilages section
- Revisions section
- Events section
For more details about the endpoints on each section visit table-of-content. To use above mentioned sections endpoints, you need to create their respective sections objects as follows:
// You can specify the version of api you want to use by passing object with version field.// if version is not provided, by default api response with version 2.2 will be provided const stackexchange = version : "2.2" ; const stack_users = stackexchangeusers;//for users sections endpointsconst stack_me = stackexchangeme;//for me sections endpointsconst stack_questions = stackexchangequestions; //for questions sections endpointsconst stack_answers = stackexchangeanswers; //for answers sections endpointsconst stack_badges = stackexchangebadges; //for badges sections endpointsconst stack_tags = stackexchangetags; //for tags sections endpointsconst stack_comments = stackexchangecomments;//for comments sections endpointsconst stack_posts = stackexchangeposts;//for posts sections endpointsconst stack_search = stackexchangesearch;//for search sections endpointsconst stack_suggested_edits = stackexchangesuggested_edits;//for suggested_edits sections endpointsconst stack_network = stackexchangenetwork;//for network sections endpointsconst stack_info = stackexchangeinfo; //for info sections endpointsconst stack_privilages = stackexchangeprivilages; //for privilages sections endpointsconst stack_revisions = stackexchangerevisions; //for revisions sections endpointsconst stack_events = stackexchangeevents; //for events sections endpoints
users section
All user methods that take an {ids} parameter have a /me equivalent method that takes an access_token instead.
// users objectconst stack_users = stackexchangeusers;
users
Get all users on the site.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using users endpoint stack_users;
users_by_ids
Get the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using users_by_ids endpoint stack_users;
answers_on_users
Get the answers posted by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using answers_on_users endpoint stack_users;
badges_on_users
Get the badges earned by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using badges_on_users endpoint stack_users;
comments_on_users
Get the comments posted by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using comments_on_users endpoint stack_users;
comments_by_users_to_user
Get the comments posted by a set of users in reply to another user.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // id of another userlet toid = 1427878; // using comments_by_users_to_user endpoint stack_users;
favorites_on_users
Get the questions favorited by users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using favorites_on_users endpoint stack_users;
mentions_on_users
Get the comments that mention one of the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using mentions_on_users endpoint stack_users;
users_network_activity
Gets a user's activity across the Stack Exchange network.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using users_network_activity endpoint stack_users;
user_notifications
Get a user's notifications.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using user_notifications endpoint stack_users;
user_unread_notifications
Get a user's unread notifications.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using user_unread_notifications endpoint stack_users;
posts_on_users
Get all posts (questions and answers) owned by a set of users.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using posts_on_users endpoint stack_users;
privileges_on_users
Get the privileges the given user has on the site.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using privileges_on_users endpoint stack_users;
questions_on_users
Get the questions asked by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using questions_on_users endpoint stack_users;
featured_questions_on_users
Get the questions on which a set of users, have active bounties.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using featured_questions_on_users endpoint stack_users;
no_answer_questions_on_users
Get the questions asked by a set of users, which have no answers.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using no_answer_questions_on_users endpoint stack_users;
unaccepted_questions_on_users
Get the questions asked by a set of users, which have at least one answer but no accepted answer.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using unaccepted_questions_on_users endpoint stack_users;
unanswered_questions_on_users
Get the questions asked by a set of users, which are not considered to be adequately answered.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using unanswered_questions_on_users endpoint stack_users;
reputation_on_users
Get a subset of the reputation changes experienced by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using reputation_on_users endpoint stack_users;
reputation_history
Get a history of a user's reputation, excluding private events.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using reputation_history endpoint stack_users;
full_reputation_history
Get a full history of a user's reputation. auth required
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using full_reputation_history endpoint stack_users;
tags_on_users
Get the tags that the users (identified by a set of ids) have been active in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using tags_on_users endpoint stack_users;
suggested_edits_on_users
Get the suggested edits provided by users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using suggested_edits_on_users endpoint stack_users;
top_user_answers_in_tags
Get the top answers a user has posted on questions with a set of tags.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; //user tagslet tags = "nodejs"; // using top_user_answers_in_tags endpoint stack_users;
top_user_questions_in_tags
Get the top questions a user has posted with a set of tags.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; //user tagslet tags = "nodejs"; // using top_user_questions_in_tags endpoint stack_users;
timeline_on_users
Get a subset of the actions of that have been taken by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using timeline_on_users endpoint stack_users;
top_answer_tags_on_users
Get the top tags (by score) a single user has posted answers in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using top_answer_tags_on_users endpoint stack_users;
top_tags_on_users
Get the top tags (by score) a single user has posted in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using top_tags_on_users endpoint stack_users;
top_question_tags_on_users
Get the top tags (by score) a single user has asked questions in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using top_question_tags_on_users endpoint stack_users;
moderators
Get the users who have moderation powers on the site.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using moderators endpoint stack_users;
elected_moderators
Get the users who are active moderators who have also won a moderator election.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using elected_moderators endpoint stack_users;
user_inbox
Get a user's inbox. auth required
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using user_inbox endpoint stack_users;
user_unread_inbox
Get the unread items in a user's inbox. auth required
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using user_unread_inbox endpoint stack_users;
associated_users
Get a user's associated accounts.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using associated_users endpoint stack_users;
merge_history
Get the merges a user's accounts has undergone.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // id of the userlet user_ids = "6414102"; // using merge_history endpoint stack_users;
me section
/me are users equivalent methods that takes an access_token instead. These methods are provided for developer convenience, with the exception of plain /me, which is actually necessary for discovering which user authenticated to an application.
// me objectconst stack_me = stackexchangeme;
me
Get the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using users endpoint stack_me;
me_answers
Get the answers posted by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_answers endpoint stack_me;
me_badges
Get the badges earned by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_badges endpoint stack_me;
me_comments
Get the comments posted by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_comments endpoint stack_me;
me_comments_to
Get the comments posted by a set of users in reply to another user.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" //another user_idlet toid = 1427878; // using me_comments_to endpoint stack_me;
me_favorites
Get the questions favorited by users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_favorites endpoint stack_me;
me_mentioned
Get the comments that mention one of the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_mentioned endpoint stack_me;
me_network_activity
Gets a user's activity across the Stack Exchange network.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_network_activity endpoint stack_me;
me_notifications
Get a user's notifications.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_notifications endpoint stack_me;
me_unread_notifications
Get a user's unread notifications.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_unread_notifications endpoint stack_me;
me_posts
Get all posts (questions and answers) owned by a set of users.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_posts endpoint stack_me;
me_privileges
Get the privileges the given user has on the site.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_privileges endpoint stack_me;
me_questions
Get the questions asked by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_questions endpoint stack_me;
me_featured_questions
Get the questions on which a set of users, have active bounties.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_featured_questions endpoint stack_me;
me_no_answer_questions
Get the questions asked by a set of users, which have no answers.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_no_answer_questions endpoint stack_me;
me_unaccepted_questions
Get the questions asked by a set of users, which have at least one answer but no accepted answer.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_unaccepted_questions endpoint stack_me;
me_unanswered_questions
Get the questions asked by a set of users, which are not considered to be adequately answered.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_unanswered_questions endpoint stack_me;
me_reputation
Get a subset of the reputation changes experienced by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_reputation endpoint stack_me;
me_reputation_history
Get a history of a user's reputation, excluding private events.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_reputation_history endpoint stack_me;
me_full_reputation_history
Get a full history of a user's reputation. auth required
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_full_reputation_history endpoint stack_me;
me_suggested_edits
Get the suggested edits provided by users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_suggested_edits endpoint stack_me;
me_tags
Get the tags that the users (identified by a set of ids) have been active in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_tags endpoint stack_me;
me_tags_top_questions
Get the top questions a user has posted with a set of tags.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" //user tagslet tags = "nodejs"; // using me_tags_top_questions endpoint stack_me;
me_tags_top_answers
Get the top answers a user has posted on questions with a set of tags.
//options for userslet users_options = "key": "your_key" "access_token": "your_token"//user tagslet tags = "nodejs"; // using me_tags_top_answers endpoint stack_me;
me_top_answer_tags
Get the top tags (by score) a single user has posted answers in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_top_answer_tags endpoint stack_me;
me_top_question_tags
Get the top tags (by score) a single user has asked questions in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_top_question_tags endpoint stack_me;
me_timeline
Get a subset of the actions of that have been taken by the users identified by a set of ids.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_timeline endpoint stack_me;
me_top_tags
Get the top tags (by score) a single user has posted in.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_top_tags endpoint stack_me;
me_inbox
Get a user's inbox. auth required
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_inbox endpoint stack_me;
me_unread_inbox
Get the unread items in a user's inbox. auth required
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_unread_inbox endpoint stack_me;
me_associated_users
Get a user's associated accounts.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_associated_users endpoint stack_me;
me_merge_history
Get the merges a user's accounts has undergone.
//options for userslet users_options = "key": "your_key" "access_token": "your_token" // using me_merge_history endpoint stack_me;
questions section
The options object is optional, can be an empty object also. update all your query fields in it. supported query fields are as follows:
let options = "order": "desc" "sort": "activity" "site": "stackoverflow" "key" : "your_key" // questions objectconst stack_questions = stackexchangequestions;
questions
Get all questions on the site.
// using questions endpoint stack_questions;
questions by ids
Get the questions identified by a set of ids.
ids = "47559184"// using questions_by_ids endpoint stack_questions;
answers on questions
Get the answers to the questions identified by a set of ids.
id = "47596027"// using answers_on_questions endpoint stack_questions;
render answers
Renders a hypothetical answer to a question. This is a post endpoints, the options section looks like this, both fields are required.
let options = "body": "hello" "site": "stackoverflow" // id of the questionlet id = "47596027" // using render_answer endpoint stack_questions;
linked questions
Get the questions that link to the questions identified by a set of ids.
// id of the questionlet id = "1884724"; // using answers_on_questions endpoint stack_questions;
related questions
Get the questions that are related to the questions identified by a set of ids.
// id of the questionlet id = "37878662"; // using related_questions endpoint stack_questions;
questions timeline
Get the timelines of the questions identified by a set of ids.
// id of the questionlet id = "37878662"; // using questions_timeline endpoint stack_questions;
featured questions
Get all questions on the site with active bounties.
// using featured_questions endpoint stack_questions;
no answer questions
Get all questions on the site with no answers.
// using no_answer_questions endpoint stack_questions;
unanswered questions
Get all questions the site considers unanswered.
// using unanswered_questions endpoint stack_questions;
unanswered questions my tags
Get questions the site considers unanswered within a user's favorite or interesting tags. auth required This endpoint required access_token and key in options.
// using unanswered_questions_my_tags endpoint stack_questions;
question flag options
Returns valid flag options for the given question. auth required. This endpoint required access_token and key in options.
let options = "key": "your_key" "access_token": "your_token" "site": "stackoverflow" let question_id = "37878662"; // using question_flag_options endpoint stack_questions;
question close options
Returns valid flag options which are also close reasons for the given question. auth required. This endpoint required access_token and key in options.
let options = "key": "your_key" "access_token": "your_token" "site": "stackoverflow" let question_id = "37878662"; // using question_close_options endpoint stack_questions;
comments on questions
Get the comments on the questions identified by a set of ids. This endpoint required access_token and key in options.
let options = "key": "your_key" "access_token": "your_token" "site": "stackoverflow" let question_id = "45934757"; // using comments_on_questions endpoint stack_questions;
answers section
The options object is optional, can be an empty object also. update all your query fields in it.
// answers objectconst stack_answers = stackexchangeanswers;
answers
Get all answers on the site.
// answer query optionslet options = "key": "your_key" "access_token": "your_token" // using answers endpoint stack_answers;
answers_by_ids
Get answers identified by a set of ids.
// query optionslet options = "key": "your_key" "access_token": "your_token" //id of the answerlet answer_id = "6414102"; // using answers_by_ids endpoint stack_answers;
accept_answer
Casts an accept vote on the given answer. auth required
// query optionslet options = "key": "your_key" "access_token": "your_token" //id of the answerlet answer_id = "6414102"; // using accept_answer endpoint stack_answers;
undo_accept_answer
Undoes an accept vote on the given answer. auth required
// query optionslet options = "key": "your_key" "access_token": "your_token" //id of the answerlet answer_id = "47451356"; // using undo_accept_answer endpoint stack_answers;
comments_on_answers
Get comments on the answers identified by a set of ids.
// query optionslet options = "key": "your_key" "access_token": "your_token" //id of the answerlet answer_id = "37886434"; // using comments_on_answers endpoint stack_answers;
badges section
let badges_options = "site": "stackoverflow" "key": "U4DMV*8nvpm3EOpvf69Rxw((" // badges objectconst stack_badges = stackexchangebadges;
badges
Get all badges on the site, in alphabetical order.
// using badges endpoint stack_badges;
badges_by_id
Get the badges identified by ids.
// id of the badgelet id = "222"// using badges_by_id endpoint stack_badges;
badges_by_name
Get all non-tagged-based badges in alphabetical order.
// name of the badgelet name = "fanatic" // using badges_by_name endpoint stack_badges;
badge_recipients
Get badges recently awarded on the site.
// options fields are as follows let options = "site": "stackoverflow" // using badge_recipients endpoint stack_badges;
badge_recipients_by_id
Get the recent recipients of the given badges.
// options fields are as follows let options = "site": "stackoverflow" // id of the badgelet id = "222"// using badge_recipients_by_id endpoint stack_badges;
badge_by_tags
Get all tagged-based badges in alphabetical order.
// options fields are as follows let options = "order": "desc" "sort": "popular" "site": "stackoverflow" // using badge_by_tags endpoint stack_badges;
tags section
let tags_options = "site": "stackoverflow" "key": "your_key" // tags objectconst stack_tags = stackexchangetags;
tags
Get the tags on the site.
// using tags endpoint stack_tagstagstags_options { console;};
tags by name
Get tags on the site by their names.
//tag name for searchlet tag_name = "nodejs"// using tags_by_name endpoint stack_tags;
moderator only tags
Get the tags on the site that only moderators can use.
// using moderator_only_tags endpoint stack_tags;
require tags
Get the tags on the site that fulfill required tag constraints.
// using require_tags endpoint stack_tags;
tag synonyms
Get all the tag synonyms on the site.
// using tag_synonyms endpoint stack_tags;
faqs by tags
Get frequently asked questions in a set of tags.
//tag name for searchlet tag_name = "nodejs"// using faqs_by_tags endpoint stack_tags;
related tags
Get related tags, based on common tag pairings.
//tag name for searchlet tag_name = "nodejs"// using related_tags endpoint stack_tags;
synonyms by tags
Get the synonyms for a specific set of tags.
//tag name for searchlet tag_name = "nodejs"// using synonyms_by_tags endpoint stack_tags;
top answerers on tags
Get the top answer posters in a specific tag, either in the last month or for all time.
//tag name for searchlet tag_name = "java"// using top_answerers_on_tags endpoint stack_tags;
top askers on tags
Get the top question askers in a specific tag, either in the last month or for all time.
//tag name for searchlet tag_name = "java"// using top_askers_on_tags endpoint stack_tags;
wikis by tags
Get the wiki entries for a set of tags.
//tag name for searchlet tag_name = "java"// using wikis_by_tags endpoint stack_tags;
comments section
// comments objectconst stack_comments = stackexchangecomments;
comments
Get all comments on the site. comments_options can be empty object.
let comments_options = "key": "your_key" "access_token": "your_token" // using comments endpoint stack_comments;
comments_by_ids
Get comments identified by a set of ids.
//options for commentslet comments_options = "key": "your_key" "access_token": "your_token" //id of the commentlet comment_id = "131321"; // using comments_by_ids endpoint stack_comments;
delete_comment
Delete a comment identified by its id. auth required
//options for commentslet comments_options = "key": "your_key" "access_token": "your_token" //id of the commentlet comment_id = "12135"; // using delete_comment endpoint stack_comments;
edit_comment
Edit a comment identified by its id. auth required. body is required in options
//options for commentslet comments_options = "body": "edited comment" "key": "your_key" "access_token": "your_token" //id of the commentlet comment_id = "12135"; // using edit_comment endpoint stack_comments;
create_comment_flag
Casts a flag on the given comment. auth required. option_id is required in options
//options for commentslet comments_options = "option_id": "1323" "key": "your_key" "access_token": "your_token" //id of the commentlet comment_id = "12135"; // using create_comment_flag endpoint stack_comments;
comment_flag_options
Returns valid flag options for the given comment. auth required
//options for commentslet comments_options = "key": "your_key" "access_token": "your_token" //id of the commentlet comment_id = "12135"; // using comment_flag_options endpoint stack_comments;
upvote_comment
Casts an upvote on the given comment. auth required
//options for commentslet comments_options = "key": "your_key" "access_token": "your_token" //id of the commentlet comment_id = "12135"; // using upvote_comment endpoint stack_comments;
undo_upvote_comment
Undoes an upvote on the given comment. auth required
//options for commentslet comments_options = "key": "your_key" "access_token": "your_token" //id of the commentlet comment_id = "12135"; // using undo_upvote_comment endpoint stack_comments;
posts section
// posts objectconst stack_posts = stackexchangeposts;
posts
Get all posts (questions and answers) in the system. posts_options can be empty object.
let posts_options = "key": "your_key" "access_token": "your_token" // using posts endpoint stack_posts;
posts_by_ids
Get all posts identified by a set of ids. Useful for when the type of post (question or answer) is not known.
let posts_options = "key": "your_key" "access_token": "your_token" //id of the postlet post_id = "45934757"; // using posts_by_ids endpoint stack_posts;
comments_on_posts
Get comments on the posts (question or answer) identified by a set of ids.
let posts_options = "key": "your_key" "access_token": "your_token" //id of the postlet post_id = "45934757"; // using comments_on_posts endpoint stack_posts;
create_comment
Create a new comment on the post identified by id. auth required. the comment should be included in options as body.
// body is required field.let posts_options = "body": "Adding test comment" "key": "your_key" "access_token": "your_token" //id of the postlet post_id = "45934757"; // using create_comment endpoint stack_posts;
render_comment
Renders a hypothetical comment on the given post.
let posts_options = "key": "your_key" "access_token": "your_token" //id of the postlet post_id = "45934757"; // using render_comment endpoint stack_posts;
revisions_by_ids
Get revisions on the set of posts in ids.
let posts_options = "key": "your_key" "access_token": "your_token" //id of the postlet post_id= 39892422; // using revisions_by_ids endpoint stack_posts;
posts_on_suggested_edits
Get suggested edits on the set of posts in ids. `
let posts_options = "key": "your_key" "access_token": "your_token" //id of the postlet post_id= 39892422; // using posts_on_suggested_edits endpoint stack_posts;
search section
// search objectconst stack_search = stackexchangesearch;
search
Search the site for questions meeting certain criteria. search_options must contain one of tagged or intitle field.
let search_options = "tagged": "nodejs" "key": "your_key" "access_token": "your_token" // using search endpoint stack_search;
advanced_search
Search the site for questions using most of the on-site search options. for more search_options please visit advanced_search endpoint of stackexchange.
let search_options = "key": "your_key" "access_token": "your_token" // using advanced_search endpoint stack_search;
similar
Search the site based on similarity to a title. title must be set in search_options.
let search_options = "title": "npm install error" "key": "your_key" "access_token": "your_token" // using similar endpoint stack_search;
excerpt_search
Searches a site. For more search_options see excerpt_search endpoint of stackexchange.
let search_options = "key": "your_key" "access_token": "your_token" // using excerpt_search endpoint stack_search;
suggested_edits section
let suggested_edits_options = "key": "your_key" "access_token": "your_token" // suggested_edits objectconst stack_suggested_edits = stackexchangesuggested_edits;
suggested_edits
Get all the suggested edits on the site. options is optional, can be an empty object
// using suggested_edits endpoint stack_suggested_edits;
suggested_edits_by_ids
Get the suggested edits identified by a set of ids. options is optional, can be an empty object
// id of the suggested_editlet suggested_edit_id = "3445738" // using suggested_edits_by_ids endpoint stack_suggested_edits;
network section
These methods return data across the entire Stack Exchange network of sites. Accordingly, you do not pass a site parameter to them.
// network objectconst stack_network = stackexchangenetwork;
Access Tokens
invalidate_access_tokens
Allows an application to dispose of access_tokens when it is done with them.
//options for userslet invalidate_options = "key": "your_key" "access_token": "your_token" // using invalidate_access_tokens endpoint stack_network;
read_access_tokens
Allows an application to inspect access_tokens it has, useful for debugging.
//options for userslet read_options = "key": "your_key" "access_token": "your_token" // using read_access_tokens endpoint stack_network;
Applications
application_de_authenticate
Allows an application to de-authorize itself for a set of users.
//options for userslet read_options = "key": "your_key" "access_token": "your_token" // using application_de_authenticate endpoint stack_network;
Errors
errors
Get descriptions of all the errors that the API could return.
//options for userslet read_options = "key": "your_key" "access_token": "your_token" // using errors endpoint stack_network;
simulate_errors
Simulate an API error for testing purposes.
//options for userslet read_options = "key": "your_key" "access_token": "your_token" let error_id = "401"; // using simulate_errors endpoint stack_network;
Filters
create_filter
Create a new filter.
//options for userslet read_options = "include": ".quota_max" "exclude": ".quota_remaining" "unsafe": false "key": "your_key" "access_token": "your_token" // using create_filter endpoint stack_network;
read_filter
Decode a set of filters, useful for debugging purposes.
//options for userslet read_options = "key": "your_key" "access_token": "your_token" let filter = ".quota_max" // using read_filter endpoint stack_network;
Inbox
Inbox
Get a user's inbox, outside of the context of a site. auth required
//options for userslet inbox_options = "key": "your_key" "access_token": "your_token" // using inbox endpoint stack_network;
inbox_unread
Get the unread items in a user's inbox, outside of the context of a site. auth required
//options for userslet inbox_options = "key": "your_key" "access_token": "your_token" // using inbox_unread endpoint stack_network;
Notifications
notifications
Get a user's notifications, outside of the context of a site. auth required
//options for userslet inbox_options = "key": "your_key" "access_token": "your_token" // using notifications endpoint stack_network;
unread_notifications
Get a user's notifications, outside of the context of a site. auth required
//options for userslet inbox_options = "key": "your_key" "access_token": "your_token" // using unread_notifications endpoint stack_network;
Sites
sites
Get all the sites in the Stack Exchange network.
//options for userslet inbox_options = "key": "your_key" "access_token": "your_token" // using sites endpoint stack_network;
info section
let info_options = "site": "stackoverflow" // info objectconst stack_info = stackexchangeinfo;
info
Get information about the entire site.
// using info endpoint stack_info;
privilages section
let privilages_options = "site": "stackoverflow" "key" : "your_key" // privilages objectconst stack_privilages = stackexchangeprivilages;
privilages
Get all the privileges available on the site.
// using info endpoint stack_privilages;
revisions section
let revisions_options = "site": "stackoverflow" "key" : "your_key" // privilages objectconst stack_revisions = stackexchangerevisions;
revisions
Get all revisions identified by a set of ids.
// ids will be available from posts_id endpoint, can be single or multiple seperated by comma. let ids = "BCF73AEC-7F9D-4623-8C38-66E481B52513"// using info endpoint stack_revisions;
events section
To use events endpoint you need to have access_token and key, you can generate your access_token and key here.
let event_options = "site": "stackoverflow" "key": "your_key" "access_token": "your_token" // ; events objectconst stack_events = stackexchangeevents;
events
Get recent events that have occurred on the site. Effectively a stream of new users and content. auth required
// using info endpoint stack_events;
Table of Content
The module exposes following endpoints of stackexchange api:
Endpoints | Description | See in StackExchange |
---|---|---|
users | Get all users on the site. | users |
users_by_ids | Get the users identified by a set of ids. | users/{ids} |
answers_on_users | Get the answers posted by the users identified by a set of ids. | users/{ids}/answers |
badges_on_users | Get the badges earned by the users identified by a set of ids. | users/{ids}/badges |
comments_on_users | Get the comments posted by the users identified by a set of ids. | users/{ids}/comments |
comments_by_users_to_user | Get the comments posted by a set of users in reply to another user. | /users/{ids}/comments/{toid} |
favorites_on_users | Get the questions favorited by users identified by a set of ids. | users/{ids}/favorites |
mentions_on_users | Get the comments that mention one of the users identified by a set of ids. | users/{ids}/mentioned |
users_network_activity | Gets a user's activity across the Stack Exchange network. | users/{id}/network-activity |
user_notifications | Get a user's notifications. | users/{id}/notifications |
user_unread_notifications | Get a user's unread notifications. | users/{id}/notifications/unread |
posts_on_users | Get all posts (questions and answers) owned by a set of users. | users/{ids}/posts |
privileges_on_users | Get the privileges the given user has on the site. | users/{id}/privileges |
questions_on_users | Get the questions asked by the users identified by a set of ids. | users/{ids}/questions |
featured_questions_on_users | Get the questions on which a set of users, have active bounties. | users/{ids}/questions/featured |
no_answer_questions_on_users | Get the questions asked by a set of users, which have no answers. | users/{ids}/questions/no-answers |
unaccepted_questions_on_users | Get the questions asked by a set of users, which have at least one answer but no accepted answer. | users/{ids}/questions/unaccepted |
unanswered_questions_on_users | Get the questions asked by a set of users, which are not considered to be adequately answered. | users/{ids}/questions/unanswered |
reputation_on_users | Get a subset of the reputation changes experienced by the users identified by a set of ids. | users/{ids}/reputation |
reputation_history | Get a history of a user's reputation, excluding private events. | users/{ids}/reputation-history |
full_reputation_history | Get a full history of a user's reputation. auth required | users/{id}/reputation-history/full |
tags_on_users | Get the tags that the users (identified by a set of ids) have been active in. | users/{ids}/tags |
suggested_edits_on_users | Get the suggested edits provided by users identified by a set of ids. | users/{ids}/suggested-edits |
top_user_answers_in_tags | Get the top answers a user has posted on questions with a set of tags. | users/{id}/tags/{tags}/top-answers |
top_user_questions_in_tags | Get the top questions a user has posted with a set of tags. | users/{id}/tags/{tags}/top-questions |
timeline_on_users | Get a subset of the actions of that have been taken by the users identified by a set of ids. | users/{ids}/timeline |
top_answer_tags_on_users | Get the top tags (by score) a single user has posted answers in. | users/{id}/top-answer-tags |
top_tags_on_users | Get the top tags (by score) a single user has posted in. | users/{id}/top-tags |
top_question_tags_on_users | Get the top tags (by score) a single user has asked questions in. | users/{id}/top-question-tags |
moderators | Get the users who have moderation powers on the site. | users/moderators |
elected_moderators | Get the users who are active moderators who have also won a moderator election. | users/moderators/elected |
user_inbox | Get a user's inbox. auth required | users/{id}/inbox |
user_unread_inbox | Get the unread items in a user's inbox. auth required | users/{id}/inbox/unread |
associated_users | Get a user's associated accounts. | users/{ids}/associated |
merge_history | Get the merges a user's accounts has undergone. | users/{ids}/merges |
Endpoints | Description | See in StackExchange |
---|---|---|
me | Get the users identified by a set of ids. | me |
me_answers | Get the answers posted by the users identified by a set of ids. | me/answers |
me_badges | Get the badges earned by the users identified by a set of ids. | me/badges |
me_comments | Get the comments posted by the users identified by a set of ids. | me/comments |
me_comments_to | Get the comments posted by a set of users in reply to another user. | me/comments/{toId} |
me_favorites | Get the questions favorited by users identified by a set of ids. | me/favorites |
me_mentioned | Get the comments that mention one of the users identified by a set of ids. | me/mentioned |
me_network_activity | Gets a user's activity across the Stack Exchange network. | me/network-activity |
me_notifications | Get a user's notifications. | me/notifications |
me_unread_notifications | Get a user's unread notifications. | me/notifications/unread |
me_posts | Get all posts (questions and answers) owned by a set of users. | me/posts |
me_privileges | Get the privileges the given user has on the site. | me/privileges |
me_questions | Get the questions asked by the users identified by a set of ids. | me/questions |
me_featured_questions | Get the questions on which a set of users, have active bounties. | me/questions/featured |
me_no_answer_questions | Get the questions asked by a set of users, which have no answers. | me/questions/no-answers |
me_unaccepted_questions | Get the questions asked by a set of users, which have at least one answer but no accepted answer. | me/questions/unaccepted |
me_unanswered_questions | Get the questions asked by a set of users, which are not considered to be adequately answered. | me/questions/unanswered |
me_reputation | Get a subset of the reputation changes experienced by the users identified by a set of ids. | me/reputation |
me_reputation_history | Get a history of a user's reputation, excluding private events. | me/reputation-history |
me_full_reputation_history | Get a full history of a user's reputation. auth required | me/reputation-history/full |
me_suggested_edits | Get the suggested edits provided by users identified by a set of ids. | me/suggested-edits |
me_tags | Get the tags that the users (identified by a set of ids) have been active in. | me/tags |
me_tags_top_questions | Get the top answers a user has posted on questions with a set of tags. | me/tags/{tags}/top-answers |
me_tags_top_answers | Get the top questions a user has posted with a set of tags. | me/tags/{tags}/top-questions |
me_timeline | Get a subset of the actions of that have been taken by the users identified by a set of ids. | me/timeline |
me_top_answer_tags | Get the top tags (by score) a single user has posted answers in. | me/top-answer-tags |
me_top_question_tags | Get the top tags (by score) a single user has asked questions in. | me/top-question-tags |
me_top_tags | Get the top tags (by score) a single user has posted in. | me/top-tags |
me_inbox | Get a user's inbox. auth required | me/inbox |
me_unread_inbox | Get the unread items in a user's inbox. auth required | me/inbox/unread |
me_associated_users | Get a user's associated accounts. | me/associated |
me_merge_history | Get the merges a user's accounts has undergone. | me/merges |
Endpoints | Description | See in StackExchange |
---|---|---|
questions | Get all questions on the site. | questions |
quetions_by_id | Get the questions identified by a set of ids. | questions/{ids} |
answers_on_questions | Get the answers to the questions identified by a set of ids. | questions/{ids}/answers |
render_answers | Renders a hypothetical answer to a question. This is a post endpoints, the options section looks like this, both fields are required. | questions/{id}/answers/render |
linked_questions | Get the questions that link to the questions identified by a set of ids. | questions/{ids}/linked |
related_questions | Get the questions that are related to the questions identified by a set of ids. | questions/{ids}/related |
questions_timeline | Get the timelines of the questions identified by a set of ids. | questions/{ids}/timeline |
featured_questions | Get all questions on the site with active bounties. | questions/featured |
no-answer-questions | Get all questions on the site with no answers. | questions/no-answers |
unanswered_questions | Get all questions the site considers unanswered. | questions/unanswered |
unanswered_questions_my_tags | Get questions the site considers unanswered within a user's favorite or interesting tags. auth required. | questions/unanswered/my-tags |
question_flag_options | Returns valid flag options for the given question. auth required. | questions/{id}/flags/options |
question_close_options | Returns valid flag options which are also close reasons for the given question. auth required. | questions/{id}/close/options |
comments_on_questions | Get the comments on the questions identified by a set of ids. This endpoint required access_token and key in options. | questions/{ids}/comments |
Endpoints | Description | See in StackExchange |
---|---|---|
answers | Get all answers on the site. | answers |
answers_by_ids | Get answers identified by a set of ids. | answers/{ids} |
accept_answer | Casts an accept vote on the given answer. auth required | answers/{id}/accept |
comments_on_answers | Undoes an accept vote on the given answer. auth required | answers/{id}/accept/undo |
undo_accept_answer | Get comments on the answers identified by a set of ids. | answers/{ids}/comments |
Endpoints | Description | See in StackExchange |
---|---|---|
badges | Get all badges on the site, in alphabetical order. | badges |
badges_by_id | Get the badges identified by ids. | badges/{ids} |
badges_by_name | Get all non-tagged-based badges in alphabetical order. | badges/name |
badge_recipients | Get badges recently awarded on the site. | badges/recipients |
badge_recipients_by_id | Get the recent recipients of the given badges. | badges/{ids}/recipients |
badge_by_tags | Get all tagged-based badges in alphabetical order. | badges/tags |
Endpoints | Description | See in StackExchange |
---|---|---|
tags | Get the tags on the site. | tags |
tags_by_name | Get tags on the site by their names. | tags/{tags}/info |
moderator_only_tags | Get the tags on the site that only moderators can use. | tags/moderator-only |
require_tags | Get the tags on the site that fulfill required tag constraints. | tags/required |
tag_synonyms | Get all the tag synonyms on the site. | tags/synonyms |
faqs_by_tags | Get frequently asked questions in a set of tags. | tags/{tags}/faq |
related_tags | Get related tags, based on common tag pairings. | tags/{tags}/related |
synonyms_by_tags | Get the synonyms for a specific set of tags. | tags/{tags}/synonyms |
top_answerers_on_tags | Get the top answer posters in a specific tag, either in the last month or for all time. | tags/{tag}/top-answerers/{period} |
top_askers_on_tags | Get the top question askers in a specific tag, either in the last month or for all time. | tags/{tag}/top-askers/{period} |
wikis_by_tags | Get the wiki entries for a set of tags. | tags/{tags}/wikis |
Endpoints | Description | See in StackExchange |
---|---|---|
comments | Get all comments on the site. | comments |
comments_by_ids | Get comments identified by a set of ids. | comments/{ids} |
delete_comment | Delete a comment identified by its id. auth required | comments/{id}/delete |
edit_comment | Edit a comment identified by its id. auth required | comments/{id}/edit |
create_comment_flag | Casts a flag on the given comment. auth required | comments/{id}/flags/add |
comment_flag_options | Returns valid flag options for the given comment. auth required | comments/{id}/flags/options |
upvote_comment | Casts an upvote on the given comment. auth required | comments/{id}/upvote |
undo_upvote_comment | Undoes an upvote on the given comment. auth required | comments/{id}/upvote/undo |
Endpoints | Description | See in StackExchange |
---|---|---|
posts | Get all posts (questions and answers) in the system. | posts |
posts_by_ids | Get all posts identified by a set of ids. Useful for when the type of post (question or answer) is not known. | posts/{ids} |
comments_on_posts | Get comments on the posts (question or answer) identified by a set of ids. | posts/{ids}/comments |
create_comment | Create a new comment on the post identified by id. auth required | posts/{id}/comments/add |
render_comment | Renders a hypothetical comment on the given post. | posts/{id}/comments/render |
revisions_by_ids | Get revisions on the set of posts in ids. | posts/{ids}/revisions |
posts_on_suggested_edits | Get suggested edits on the set of posts in ids. | posts/{ids}/suggested-edits |
Endpoints | Description | See in StackExchange |
---|---|---|
search | Search the site for questions meeting certain criteria. | search |
advanced_search | Search the site for questions using most of the on-site search options. | search/advanced |
similar | Search the site based on similarity to a title. | similar |
excerpt_search | Searches a site. | search/excerpts |
Endpoints | Description | See in StackExchange |
---|---|---|
suggested_edits | Get all the suggested edits on the site. | suggested-edits |
suggested_edits_by_ids | Get the suggested edits identified by a set of ids. | suggested-edits/{ids} |
Endpoints | Description | See in StackExchange |
---|---|---|
invalidate_access_tokens | Allows an application to dispose of access_tokens when it is done with them. | access-tokens/{accessTokens}/invalidate |
read_access_tokens | Allows an application to inspect access_tokens it has, useful for debugging. | access-tokens/{accessTokens} |
application_de_authenticate | Allows an application to de-authorize itself for a set of users. | apps/{accessTokens}/de-authenticate |
errors | Get descriptions of all the errors that the API could return. | errors |
simulate_errors | Simulate an API error for testing purposes. | errors/{id} |
create_filter | Create a new filter. | filters/create |
read_filter | Decode a set of filters, useful for debugging purposes. | filters/{filters} |
Inbox | Get a user's inbox, outside of the context of a site. auth required | inbox |
inbox_unread | Get the unread items in a user's inbox, outside of the context of a site. auth required | inbox/unread |
notifications | Get a user's notifications, outside of the context of a site. auth required | notifications |
unread_notifications | Get a user's unread notifications, outside of the context of a site. auth required | notifications/unread |
sites | Get all the sites in the Stack Exchange network. | sites |
Endpoints | Description | See in StackExchange |
---|---|---|
info | Get information about the entire site. | info |
Endpoints | Description | See in StackExchange |
---|---|---|
privilages | Get all the privileges available on the site. | privileges |
Endpoints | Description | See in StackExchange |
---|---|---|
revisions | Get all revisions identified by a set of ids. | revisions/{ids} |
Endpoints | Description | See in StackExchange |
---|---|---|
events | Get recent events that have occurred on the site. Effectively a stream of new users and content. auth required | events |