npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stack-exchange

v0.0.3

Published

This is a simple npm module that utilizes request and the StackOverflow API.

Downloads

29

Readme

stack-exchange

NPM

The stack-exchange is a simple npm module that provides a wrapper to access StackOverflow API endpoint.

Build Status npm version Node.js Version Known Vulnerabilities

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

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  = require("stack-exchange")({ version : "2.2" });

const stack_users = stackexchange.users;//for users sections endpoints
const stack_me = stackexchange.me;//for me sections endpoints
const stack_questions = stackexchange.questions; //for questions sections endpoints
const stack_answers = stackexchange.answers; //for answers sections endpoints
const stack_badges = stackexchange.badges; //for badges sections endpoints
const stack_tags = stackexchange.tags; //for tags sections endpoints
const stack_comments = stackexchange.comments;//for comments sections endpoints
const stack_posts = stackexchange.posts;//for posts sections endpoints
const stack_search = stackexchange.search;//for search sections endpoints
const stack_suggested_edits = stackexchange.suggested_edits;//for suggested_edits sections endpoints
const stack_network = stackexchange.network;//for network sections endpoints
const stack_info = stackexchange.info; //for info sections endpoints
const stack_privilages = stackexchange.privilages; //for privilages sections endpoints
const stack_revisions = stackexchange.revisions; //for revisions sections endpoints
const stack_events = stackexchange.events; //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 object
const stack_users = stackexchange.users;

users

Get all users on the site.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using users endpoint 
stack_users.users(users_options, (response) => {
   console.log(response);
});

users_by_ids

Get the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using users_by_ids endpoint 
stack_users.users_by_ids(user_ids, users_options, (response) => {
   console.log(response);
});

answers_on_users

Get the answers posted by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using answers_on_users endpoint 
stack_users.answers_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

badges_on_users

Get the badges earned by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using badges_on_users endpoint 
stack_users.badges_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

comments_on_users

Get the comments posted by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using comments_on_users endpoint 
stack_users.comments_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

comments_by_users_to_user

Get the comments posted by a set of users in reply to another user.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// id of another user
let toid = 1427878;

// using comments_by_users_to_user endpoint 
stack_users.comments_by_users_to_user(user_ids, toid , users_options, (response) => {
   console.log(response);
});

favorites_on_users

Get the questions favorited by users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using favorites_on_users endpoint 
stack_users.favorites_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

mentions_on_users

Get the comments that mention one of the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using mentions_on_users endpoint 
stack_users.mentions_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

users_network_activity

Gets a user's activity across the Stack Exchange network.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using users_network_activity endpoint 
stack_users.users_network_activity(user_ids, users_options, (response) => {
   console.log(response);
});

user_notifications

Get a user's notifications.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using user_notifications endpoint 
stack_users.user_notifications(user_ids, users_options, (response) => {
   console.log(response);
});

user_unread_notifications

Get a user's unread notifications.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using user_unread_notifications endpoint 
stack_users.user_unread_notifications(user_ids, users_options, (response) => {
   console.log(response);
});

posts_on_users

Get all posts (questions and answers) owned by a set of users.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using posts_on_users endpoint 
stack_users.posts_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

privileges_on_users

Get the privileges the given user has on the site.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using privileges_on_users endpoint 
stack_users.privileges_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

questions_on_users

Get the questions asked by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using questions_on_users endpoint 
stack_users.questions_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

featured_questions_on_users

Get the questions on which a set of users, have active bounties.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using featured_questions_on_users endpoint 
stack_users.featured_questions_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

no_answer_questions_on_users

Get the questions asked by a set of users, which have no answers.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using no_answer_questions_on_users endpoint 
stack_users.no_answer_questions_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

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 users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using unaccepted_questions_on_users endpoint 
stack_users.unaccepted_questions_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

unanswered_questions_on_users

Get the questions asked by a set of users, which are not considered to be adequately answered.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using unanswered_questions_on_users endpoint 
stack_users.unanswered_questions_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

reputation_on_users

Get a subset of the reputation changes experienced by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using reputation_on_users endpoint 
stack_users.reputation_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

reputation_history

Get a history of a user's reputation, excluding private events.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using reputation_history endpoint 
stack_users.reputation_history(user_ids, users_options, (response) => {
   console.log(response);
});

full_reputation_history

Get a full history of a user's reputation. auth required

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using full_reputation_history endpoint 
stack_users.full_reputation_history(user_ids, users_options, (response) => {
   console.log(response);
});

tags_on_users

Get the tags that the users (identified by a set of ids) have been active in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using tags_on_users endpoint 
stack_users.tags_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

suggested_edits_on_users

Get the suggested edits provided by users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using suggested_edits_on_users endpoint 
stack_users.suggested_edits_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

top_user_answers_in_tags

Get the top answers a user has posted on questions with a set of tags.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

//user tags
let tags = "nodejs";

// using top_user_answers_in_tags endpoint 
stack_users.top_user_answers_in_tags(user_ids, tags,  users_options, (response) => {
   console.log(response);
});

top_user_questions_in_tags

Get the top questions a user has posted with a set of tags.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

//user tags
let tags = "nodejs";

// using top_user_questions_in_tags endpoint 
stack_users.top_user_questions_in_tags(user_ids, tags,  users_options, (response) => {
   console.log(response);
});

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 users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using timeline_on_users endpoint 
stack_users.timeline_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

top_answer_tags_on_users

Get the top tags (by score) a single user has posted answers in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using top_answer_tags_on_users endpoint 
stack_users.top_answer_tags_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

top_tags_on_users

Get the top tags (by score) a single user has posted in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using top_tags_on_users endpoint 
stack_users.top_tags_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

top_question_tags_on_users

Get the top tags (by score) a single user has asked questions in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using top_question_tags_on_users endpoint 
stack_users.top_question_tags_on_users(user_ids, users_options, (response) => {
   console.log(response);
});

moderators

Get the users who have moderation powers on the site.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using moderators endpoint 
stack_users.moderators(users_options, (response) => {
   console.log(response);
});

elected_moderators

Get the users who are active moderators who have also won a moderator election.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using elected_moderators endpoint 
stack_users.elected_moderators(users_options, (response) => {
   console.log(response);
});

user_inbox

Get a user's inbox. auth required

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using user_inbox endpoint 
stack_users.user_inbox(user_ids, users_options, (response) => {
   console.log(response);
});

user_unread_inbox

Get the unread items in a user's inbox. auth required

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using user_unread_inbox endpoint 
stack_users.user_unread_inbox(user_ids, users_options, (response) => {
   console.log(response);
});

associated_users

Get a user's associated accounts.

//options for users
let users_options = {
    "key": "your_key",
    "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using associated_users endpoint 
stack_users.associated_users(user_ids, users_options, (response) => {
    console.log(response);
});

merge_history

Get the merges a user's accounts has undergone.

//options for users
let users_options = {
    "key": "your_key",
    "access_token": "your_token"
}

// id of the user
let user_ids = "6414102";

// using merge_history endpoint 
stack_users.merge_history(user_ids, users_options, (response) => {
    console.log(response);
});

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 object
const stack_me = stackexchange.me;

me

Get the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using users endpoint 
stack_me.me( users_options, (response) => {
   console.log(response);
});

me_answers

Get the answers posted by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_answers endpoint 
stack_me.me_answers( users_options, (response) => {
   console.log(response);
});

me_badges

Get the badges earned by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_badges endpoint 
stack_me.me_badges( users_options, (response) => {
   console.log(response);
});

me_comments

Get the comments posted by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_comments endpoint 
stack_me.me_comments( users_options, (response) => {
   console.log(response);
});

me_comments_to

Get the comments posted by a set of users in reply to another user.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//another user_id
let toid = 1427878;


// using me_comments_to endpoint 
stack_me.me_comments_to(toid, users_options, (response) => {
   console.log(response);
});

me_favorites

Get the questions favorited by users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_favorites endpoint 
stack_me.me_favorites(users_options, (response) => {
   console.log(response);
});

me_mentioned

Get the comments that mention one of the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_mentioned endpoint 
stack_me.me_mentioned(users_options, (response) => {
   console.log(response);
});

me_network_activity

Gets a user's activity across the Stack Exchange network.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_network_activity endpoint 
stack_me.me_network_activity(users_options, (response) => {
   console.log(response);
});

me_notifications

Get a user's notifications.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_notifications endpoint 
stack_me.me_notifications(users_options, (response) => {
   console.log(response);
});    

me_unread_notifications

Get a user's unread notifications.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_unread_notifications endpoint 
stack_me.me_unread_notifications(users_options, (response) => {
   console.log(response);
});    

me_posts

Get all posts (questions and answers) owned by a set of users.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_posts endpoint 
stack_me.me_posts(users_options, (response) => {
   console.log(response);
});
  

me_privileges

Get the privileges the given user has on the site.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_privileges endpoint 
stack_me.me_privileges(users_options, (response) => {
   console.log(response);
});
  

me_questions

Get the questions asked by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_questions endpoint 
stack_me.me_questions(users_options, (response) => {
   console.log(response);
});
  

me_featured_questions

Get the questions on which a set of users, have active bounties.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_featured_questions endpoint 
stack_me.me_featured_questions(users_options, (response) => {
   console.log(response);
});
  

me_no_answer_questions

Get the questions asked by a set of users, which have no answers.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_no_answer_questions endpoint 
stack_me.me_no_answer_questions(users_options, (response) => {
   console.log(response);
});

  

me_unaccepted_questions

Get the questions asked by a set of users, which have at least one answer but no accepted answer.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_unaccepted_questions endpoint 
stack_me.me_unaccepted_questions(users_options, (response) => {
   console.log(response);
});
  

me_unanswered_questions

Get the questions asked by a set of users, which are not considered to be adequately answered.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_unanswered_questions endpoint 
stack_me.me_unanswered_questions(users_options, (response) => {
   console.log(response);
});
  

me_reputation

Get a subset of the reputation changes experienced by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_reputation endpoint 
stack_me.me_reputation(users_options, (response) => {
   console.log(response);
});
  

me_reputation_history

Get a history of a user's reputation, excluding private events.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_reputation_history endpoint 
stack_me.me_reputation_history(users_options, (response) => {
   console.log(response);
});
  

me_full_reputation_history

Get a full history of a user's reputation. auth required

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_full_reputation_history endpoint 
stack_me.me_full_reputation_history(users_options, (response) => {
   console.log(response);
});
  

me_suggested_edits

Get the suggested edits provided by users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_suggested_edits endpoint 
stack_me.me_suggested_edits(users_options, (response) => {
   console.log(response);
});
  

me_tags

Get the tags that the users (identified by a set of ids) have been active in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_tags endpoint 
stack_me.me_tags(users_options, (response) => {
   console.log(response);
});   

me_tags_top_questions

Get the top questions a user has posted with a set of tags.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//user tags
let tags = "nodejs";

// using me_tags_top_questions endpoint 
stack_me.me_tags_top_questions(tags, users_options, (response) => {
   console.log(response);
}); 

me_tags_top_answers

Get the top answers a user has posted on questions with a set of tags.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}
//user tags
let tags = "nodejs";

// using me_tags_top_answers endpoint 
stack_me.me_tags_top_answers(tags, users_options, (response) => {
   console.log(response);
});  

me_top_answer_tags

Get the top tags (by score) a single user has posted answers in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_top_answer_tags endpoint 
stack_me.me_top_answer_tags( users_options, (response) => {
   console.log(response);
});

me_top_question_tags

Get the top tags (by score) a single user has asked questions in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_top_question_tags endpoint 
stack_me.me_top_question_tags( users_options, (response) => {
   console.log(response);
});

me_timeline

Get a subset of the actions of that have been taken by the users identified by a set of ids.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_timeline endpoint 
stack_me.me_timeline(users_options, (response) => {
   console.log(response);
});

me_top_tags

Get the top tags (by score) a single user has posted in.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_top_tags endpoint 
stack_me.me_top_tags( users_options, (response) => {
   console.log(response);
});

me_inbox

Get a user's inbox. auth required

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_inbox endpoint 
stack_me.me_inbox( users_options, (response) => {
   console.log(response);
});

me_unread_inbox

Get the unread items in a user's inbox. auth required

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_unread_inbox endpoint 
stack_me.me_unread_inbox( users_options, (response) => {
   console.log(response);
});

me_associated_users

Get a user's associated accounts.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_associated_users endpoint 
stack_me.me_associated_users(users_options, (response) => {
   console.log(response);
});

me_merge_history

Get the merges a user's accounts has undergone.

//options for users
let users_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using me_merge_history endpoint 
stack_me.me_merge_history(inbox_options, (response) => {
   console.log(response);
});

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 object
const stack_questions = stackexchange.questions;

questions

Get all questions on the site.

// using questions endpoint 
stack_questions.questions(options , (response) => {
   // response will be json 
   console.log(response);
});

questions by ids

Get the questions identified by a set of ids.

ids = "47559184"
// using questions_by_ids endpoint 
stack_questions.questions_by_ids(ids , options , (response) => {
   // response will be json 
   console.log(response);
});

answers on questions

Get the answers to the questions identified by a set of ids.

id = "47596027"
// using answers_on_questions endpoint 
stack_questions.answers_on_questions(id, options , (response) => {
   // response will be json 
   console.log(response);
});

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 question
let id = "47596027"

// using render_answer endpoint 
stack_questions.render_answer(id, options , (response) => {
  // response returns hypothetical solution
   console.log(response);
});

linked questions

Get the questions that link to the questions identified by a set of ids.

// id of the question
let id = "1884724";

// using answers_on_questions endpoint 
stack_questions.linked_questions(id, options , (response) => {
   console.log(response);
});

related questions

Get the questions that are related to the questions identified by a set of ids.

// id of the question
let id = "37878662";

// using related_questions endpoint 
stack_questions.related_questions(id, options , (response) => {
       console.log(response);
});

questions timeline

Get the timelines of the questions identified by a set of ids.

// id of the question
let id = "37878662";

// using questions_timeline endpoint 
stack_questions.questions_timeline(id, options, (response) => {
   console.log(response);
});

featured questions

Get all questions on the site with active bounties.


// using featured_questions endpoint 
stack_questions.featured_questions(options, (response) => {
     //will return featured questions
   console.log(response);
});

no answer questions

Get all questions on the site with no answers.


// using no_answer_questions endpoint 
stack_questions.no_answer_questions( options , (response) => {
  // will return no-answer questions
   console.log(response);
});

unanswered questions

Get all questions the site considers unanswered.


// using unanswered_questions endpoint 
stack_questions.unanswered_questions( options , (response) => {
   //returns unanswered questions details
   console.log(response);
});

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.unanswered_questions_my_tags( options , (response) => {
   console.log(response);
});

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_flag_options(question_id, options, (response) => {
   console.log(response);
});

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.question_close_options(question_id, options, (response) => {
   console.log(response);
});

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.comments_on_questions(question_id, options, (response) => {
   console.log(response);
});

answers section

The options object is optional, can be an empty object also. update all your query fields in it.


//  answers object
const stack_answers = stackexchange.answers;

answers

Get all answers on the site.

// answer query options
let options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using answers endpoint 
stack_answers.answers(answers_options, (response) => {
   console.log(response);
});

answers_by_ids

Get answers identified by a set of ids.

// query options
let options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the answer
let answer_id = "6414102";

// using answers_by_ids endpoint 
stack_answers.answers_by_ids(answer_id, answers_options, (response) => {
   console.log(response);
});

accept_answer

Casts an accept vote on the given answer. auth required

// query options
let options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the answer
let answer_id = "6414102";

// using accept_answer endpoint 
stack_answers.accept_answer(answer_id, answers_options, (response) => {
   console.log(response);
});

undo_accept_answer

Undoes an accept vote on the given answer. auth required

// query options
let options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the answer
let answer_id = "47451356";

// using undo_accept_answer endpoint 
stack_answers.undo_accept_answer(answer_id, answers_options, (response) => {
   console.log(response);
});

comments_on_answers

Get comments on the answers identified by a set of ids.

// query options
let options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the answer
let answer_id = "37886434";

// using comments_on_answers endpoint 
stack_answers.comments_on_answers(answer_id, answers_options, (response) => {
   console.log(response);
});

badges section

let badges_options = {
    "site": "stackoverflow",
    "key": "U4DMV*8nvpm3EOpvf69Rxw(("
}

//  badges object
const stack_badges = stackexchange.badges;

badges

Get all badges on the site, in alphabetical order.

// using badges endpoint 
stack_badges.badges(badges_options, (response) => {
   // response will be json     
   console.log(response);
});

badges_by_id

Get the badges identified by ids.

// id of the badge
let id = "222"
// using badges_by_id endpoint 
stack_badges.badges_by_id(id, badges_options, (response) => {
   // response will be json    
   console.log(response);
});

badges_by_name

Get all non-tagged-based badges in alphabetical order.


// name of the badge
let name = "fanatic"

// using badges_by_name endpoint 
stack_badges.badges_by_name(name, badges_options, (response) => {
   // response will be json    
   console.log(response);
});

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( options, (response) => {
   // response will be json        
   console.log(response);
});

badge_recipients_by_id

Get the recent recipients of the given badges.

//  options fields are as follows 
let options = {
       "site": "stackoverflow"
   }

// id of the badge
let id = "222"
// using badge_recipients_by_id endpoint 
stack_badges.badge_recipients_by_id(id,  badges_options, (response) => {
   // response will be json        
   console.log(response);
});

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.badge_by_tags(options, (response) => {
   // response will be json        
   console.log(response);
});

tags section

let tags_options = {
    "site": "stackoverflow",
    "key": "your_key"
}


//  tags object
const stack_tags = stackexchange.tags;

tags

Get the tags on the site.

// using tags endpoint 
stack_tags.tags(tags_options, (response) => {
   console.log(response);
});

tags by name

Get tags on the site by their names.

//tag name for search
let tag_name = "nodejs"
// using tags_by_name endpoint 
stack_tags.tags_by_name(tag_name, tags_options, (response) => {
   console.log(response);
});

moderator only tags

Get the tags on the site that only moderators can use.

// using moderator_only_tags endpoint 
stack_tags.moderator_only_tags(tags_options, (response) => {
   console.log(response);
});

require tags

Get the tags on the site that fulfill required tag constraints.

// using require_tags endpoint 
stack_tags.require_tags(tags_options, (response) => {
   console.log(response);
});

tag synonyms

Get all the tag synonyms on the site.

// using tag_synonyms endpoint 
stack_tags.tag_synonyms(tags_options, (response) => {
   console.log(response);
});

faqs by tags

Get frequently asked questions in a set of tags.

//tag name for search
let tag_name = "nodejs"
// using faqs_by_tags endpoint 
stack_tags.faqs_by_tags(tag_name, tags_options, (response) => {
   console.log(response);
});

related tags

Get related tags, based on common tag pairings.

//tag name for search
let tag_name = "nodejs"
// using related_tags endpoint 
stack_tags.related_tags(tag_name, tags_options, (response) => {
   console.log(response);
});

synonyms by tags

Get the synonyms for a specific set of tags.

//tag name for search
let tag_name = "nodejs"
// using synonyms_by_tags endpoint 
stack_tags.synonyms_by_tags(tag_name, tags_options, (response) => {
   console.log(response);
});

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 search
let tag_name = "java"
// using top_answerers_on_tags endpoint 
stack_tags.top_answerers_on_tags(tag_name, tags_options, (response) => {
   console.log(response);
});

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 search
let tag_name = "java"
// using top_askers_on_tags endpoint 
stack_tags.top_askers_on_tags(tag_name, tags_options, (response) => {
   console.log(response);
});

wikis by tags

Get the wiki entries for a set of tags.

//tag name for search
let tag_name = "java"
// using wikis_by_tags endpoint 
stack_tags.wikis_by_tags(tag_name, tags_options, (response) => {
   console.log(response);
});

comments section


//  comments object
const stack_comments = stackexchange.comments;

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(comments_options, (response) => {
   console.log(response);
});

comments_by_ids

Get comments identified by a set of ids.

//options for comments
let comments_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the comment
let comment_id = "131321";

// using comments_by_ids endpoint 
stack_comments.comments_by_ids(comment_id, comments_options, (response) => {
   console.log(response);
});

delete_comment

Delete a comment identified by its id. auth required

//options for comments
let comments_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the comment
let comment_id = "12135";

// using delete_comment endpoint 
stack_comments.delete_comment(comment_id, comments_options, (response) => {
   console.log(response);
});

edit_comment

Edit a comment identified by its id. auth required. body is required in options

//options for comments
let comments_options = {
   "body": "edited comment"
   "key": "your_key",
   "access_token": "your_token"
}

//id of the comment
let comment_id = "12135";

// using edit_comment endpoint 
stack_comments.edit_comment(comment_id, comments_options, (response) => {
   console.log(response);
});

create_comment_flag

Casts a flag on the given comment. auth required. option_id is required in options

//options for comments
let comments_options = {
   "option_id": "1323"
   "key": "your_key",
   "access_token": "your_token"
}

//id of the comment
let comment_id = "12135";

// using create_comment_flag endpoint 
stack_comments.create_comment_flag(comment_id, comments_options, (response) => {
   console.log(response);
});

comment_flag_options

Returns valid flag options for the given comment. auth required

//options for comments
let comments_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the comment
let comment_id = "12135";

// using comment_flag_options endpoint 
stack_comments.comment_flag_options(comment_id, comments_options, (response) => {
   console.log(response);
});

upvote_comment

Casts an upvote on the given comment. auth required

//options for comments
let comments_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the comment
let comment_id = "12135";

// using upvote_comment endpoint 
stack_comments.upvote_comment(comment_id, comments_options, (response) => {
   console.log(response);
});

undo_upvote_comment

Undoes an upvote on the given comment. auth required

//options for comments
let comments_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the comment
let comment_id = "12135";

// using undo_upvote_comment endpoint 
stack_comments.undo_upvote_comment(comment_id, comments_options, (response) => {
   console.log(response);
});

posts section


//  posts object
const stack_posts = stackexchange.posts;

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(posts_options, (response) => {
   console.log(response);
});

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 post
let post_id = "45934757";

// using posts_by_ids endpoint 
stack_posts.posts_by_ids(post_id, posts_options, (response) => {
   console.log(response);
});

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 post
let post_id = "45934757";

// using comments_on_posts endpoint 
stack_posts.comments_on_posts(post_id, posts_options, (response) => {
   console.log(response);
});

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 post
let post_id = "45934757";

// using create_comment endpoint 
stack_posts.create_comment(post_id, posts_options, (response) => {
   console.log(response);
});

render_comment

Renders a hypothetical comment on the given post.


let posts_options = {
   "key": "your_key",
   "access_token": "your_token"
}

//id of the post
let post_id = "45934757";

// using render_comment endpoint 
stack_posts.render_comment(post_id, {}, (response) => {
   console.log(response);
});

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 post
let post_id= 39892422;

// using revisions_by_ids endpoint 
stack_posts.revisions_by_ids(post_id, posts_options, (response) => {
   console.log(response);
});

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 post
let post_id= 39892422;

// using posts_on_suggested_edits endpoint 
stack_posts.posts_on_suggested_edits(post_id, posts_options, (response) => {
   console.log(response);
});

search section


//  search object
const stack_search = stackexchange.search;

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.search(search_options, (response) => {
   console.log(response);
});

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.advanced_search(search_options, (response) => {
   console.log(response);
});

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.similar(search_options, (response) => {
   console.log(response);
});

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.excerpt_search(search_options, (response) => {
   console.log(response);
});

suggested_edits section

let suggested_edits_options = {
    "key": "your_key",
    "access_token": "your_token"
}

//  suggested_edits object
const stack_suggested_edits = stackexchange.suggested_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(suggested_edits_options, (response) => {
       console.log(response);
});

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_edit
let suggested_edit_id = "3445738"

// using suggested_edits_by_ids endpoint 
stack_suggested_edits.suggested_edits_by_ids(suggested_edit_id, suggested_edits_options, (response) => {
   console.log(response);
});

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 object
const stack_network = stackexchange.network;

Access Tokens

invalidate_access_tokens

Allows an application to dispose of access_tokens when it is done with them.

//options for users
let invalidate_options = {
   "key": "your_key",
   "access_token": "your_token"
}


// using invalidate_access_tokens endpoint 
stack_network.invalidate_access_tokens(invalidate_options, (response) => {
   console.log(response);
});

read_access_tokens

Allows an application to inspect access_tokens it has, useful for debugging.

//options for users
let read_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using read_access_tokens endpoint 
stack_network.read_access_tokens( read_options, (response) => {
   console.log(response);
});

Applications

application_de_authenticate

Allows an application to de-authorize itself for a set of users.

//options for users
let read_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using application_de_authenticate endpoint 
stack_network.application_de_authenticate( read_options, (response) => {
   console.log(response);
});

Errors

errors

Get descriptions of all the errors that the API could return.

//options for users
let read_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using errors endpoint 
stack_network.errors( read_options, (response) => {
   console.log(response);
});

simulate_errors

Simulate an API error for testing purposes.

//options for users
let read_options = {
   "key": "your_key",
   "access_token": "your_token"
}

let error_id = "401"; 

// using simulate_errors endpoint 
stack_network.simulate_errors(error_id, read_options, (response) => {
   console.log(response);
});

Filters

create_filter

Create a new filter.

//options for users
let read_options = {
   "include": ".quota_max",
   "exclude": ".quota_remaining",
   "unsafe": false
   "key": "your_key",
   "access_token": "your_token"
}

// using create_filter endpoint 
stack_network.create_filter(create_filter_options, (response) => {
   console.log(response);
});

read_filter

Decode a set of filters, useful for debugging purposes.

//options for users
let read_options = {
    "key": "your_key",
   "access_token": "your_token"
}

let filter = ".quota_max"

// using read_filter endpoint 
stack_network.read_filter(filter, read_options, (response) => {
   console.log(response);
});

Inbox

Inbox

Get a user's inbox, outside of the context of a site. auth required

//options for users
let inbox_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using inbox endpoint 
stack_network.inbox(inbox_options, (response) => {
   console.log(response);
});

inbox_unread

Get the unread items in a user's inbox, outside of the context of a site. auth required

//options for users
let inbox_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using inbox_unread endpoint 
stack_network.inbox_unread(inbox_options, (response) => {
   console.log(response);
});

Notifications

notifications

Get a user's notifications, outside of the context of a site. auth required

//options for users
let inbox_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using notifications endpoint 
stack_network.notifications(inbox_options, (response) => {
   console.log(response);
});

unread_notifications

Get a user's notifications, outside of the context of a site. auth required

//options for users
let inbox_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using unread_notifications endpoint 
stack_network.unread_notifications(inbox_options, (response) => {
   console.log(response);
});

Sites

sites

Get all the sites in the Stack Exchange network.

//options for users
let inbox_options = {
   "key": "your_key",
   "access_token": "your_token"
}

// using sites endpoint 
stack_network.sites(inbox_options, (response) => {
   console.log(response);
});

info section

let info_options = {
    "site": "stackoverflow"
}

//  info object
const stack_info = stackexchange.info;

info

Get information about the entire site.

// using info endpoint 
stack_info.info(info_options, (response) => {
   // response will be json 
   console.log(response);
});

privilages section

let privilages_options = {
    "site": "stackoverflow",
    "key" : "your_key"
}

//  privilages object
const stack_privilages = stackexchange.privilages;

privilages

Get all the privileges available on the site.

// using info endpoint 
stack_privilages.privilages(privilages_options, (response) => {
   // response will be json 
   console.log(response);
});

revisions section

let revisions_options = {
    "site": "stackoverflow",
    "key" : "your_key"
}

// privilages object
const stack_revisions = stackexchange.revisions;

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.revisions( ids , revisions_options, (response) => {
   // response will be json 
   console.log(response);
});

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 object
const stack_events = stackexchange.events;

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.events(event_options, (response) => {
   // response will be json 
   console.log(response);
});

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