Skip to content

Questions Section

kgangadhar edited this page May 25, 2019 · 1 revision

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);
});