3

I wanted to search for questions on all SE sites that had a bounty. I am not sure if it is possible, and if it is how can I?

I have seen other questions that show how to find questions on each individual site, but how can I find all of them in one search from the homepage stackexchange.com? If this has been asked already, please let me know.

It has been suggested that the question was already asked (click here for the question), but that question only showed how to find those questions on each separate site or some complex way to search. I am hoping to find a way to search for bountied questions easily or for someone to create a way to do this.

13
  • Did you get inspired by this question?
    – rene
    Nov 6, 2015 at 20:34
  • I read that question. I was asking for a simple way to search for all of the questions with a bounty from the main site. The answers in the question you linked to talked about complex ways to search or how to find questions with bounties in each individual SE site. Nov 6, 2015 at 20:37
  • 3
    But would this really help at all? There are so many types of sites in SE, you probably wouldn't find any questions you could answer very easily... :/ Nov 6, 2015 at 20:37
  • I wasn't asking for an easy answer. I was asking for an easy way to search for bountied questions Nov 6, 2015 at 20:39
  • Is it a puzzle, then? :D
    – nicael
    Nov 6, 2015 at 20:40
  • @nicael Yes it is a mystery. Nov 6, 2015 at 20:44
  • Nononono it hasn't been suggested that your question was asked already. Rene just brought another question there because they thought the association with that question made you write this one.
    – nicael
    Nov 6, 2015 at 20:48
  • So clicking a link to a query is complex?
    – rene
    Nov 6, 2015 at 20:49
  • 1
    @rene what do you mean? Nov 6, 2015 at 20:50
  • @rene Your link is broken. Nov 6, 2015 at 20:52
  • You seem to suggest that the answers on the question I linked are too complex for your purpose. Those answers try to teach how to fish but in the end it is a link you can follow that runs a pre-baked sql query. If either I or @nicael create such a query, would that answer your question or isn't that what you're looking for in terms of easy.
    – rene
    Nov 6, 2015 at 20:55
  • @rene I messed up. When I hovered over the link in your first comment, I thought it was another question that I had seen earlier in my search for an answer. I thought that the question you linked to was the question I described, which had more than 2. I am gonna have to ind that again and fix my mistake. Never have seen that question you linked to before just a moment ago. Nov 6, 2015 at 21:01
  • I did some experimenting of my own and found out this works: "This question has an open bounty worth" Nov 6, 2015 at 22:16

2 Answers 2

5

The Stack API has two endpoints that we can use to implement this. First we use /sites to get a list of all sites. After that we call /questions/featured to get the per-site featured (bountied) questions.

The following Stack Snippet demonstrates the use of those two end-points and produces a list of all featured questions across all sites. The script does take the API throttle limits into account. When hit (or when a result-set is paged) a link appears at the end of the list that needs to be clicked to continue loading.

(function () {
  var api = {
    url: 'https://api.stackexchange.com/2.2/',
    endpoint: 'questions/featured',
    params: { 
      site: 'stackoverflow',
      pagesize: 100,
      order: 'desc',
      sort: 'activity',
      Filter: '!iCF4LsDYJt6oT_Y1qKBCOv',
      key: 'JBN9WXWxwrcnAj7WEEytmQ(('
      }
    },
      sites = [],
      siteIndex = -1;
    
    
  function createUrl(ap) {
    var ep = ap.url + ap.endpoint +'?',
     nv = [];
    $.each(ap.params, function (k,v) {
       nv.push(k + '=' + v);
    });
    console.log(ep + nv.join('&'));
    return ep + nv.join('&');
  }
 
  function enableLoad(func) {
    $('#load').show();
    $('#load').one('click', func);
  }
   
  // load a page of featured questions
  function load(page) {
    console.log(sites);
    api.params.page = page;
    api.params.site = sites[siteIndex].sapi;
    $('#load').hide();
    $.get(createUrl(api), function (data) {
      var i, 
          list = $('#fav'),
          next;
      for(i = 0; i < data.items.length; i = i +1) {
          list.append(
            $('<div></div>').append(
              $('<img/>')
                .attr('src',sites[siteIndex].url)
                .attr('title',sites[siteIndex].name),
            $('<a></a>')
              .attr('href', data.items[i].link)
              .attr('title', data.items[i].bounty_amount)
              .html(data.items[i].title)
            ));
      }
      if (data.has_more) {
        next = function () { load(page + 1); };
        if (data.backoff !== undefined) {
          window.setTimeout( function () {
              enableLoad(next);
            }, 
            data.items.backoff * 1000);  
        } else {
            enableLoad(next);
        }
      } else {
        siteIndex = siteIndex + 1;
        if (siteIndex < sites.length) {
          load(1);
        } else {
           $('#load').hide(); 
          }
      }
    });
  }

  // load all sites and setup sites array
  function loadSites() {
   $.get('https://api.stackexchange.com/2.2/sites?pagesize=500&filter=!*l7_tSmzy1mF3bw9odQw*8ur&key=JBN9WXWxwrcnAj7WEEytmQ((', function(data) {
        var i;
         for(i=0; i < data.items.length; i++) {
           if (data.items[i].site_type === 'main_site') {
                sites.push({ "name": data.items[i].name,
                             "sapi": data.items[i].api_site_parameter,
                             "url": data.items[i].icon_url
                            });
             }
           }
        sites.sort(function(a,b) { 
          return a.name < b.name?-1: a.name>b.name?1:0; 
        });
        siteIndex = 0;
        
        if (data.backoff !== undefined) {
          window.setTimeout( function () {
              load(1);
            }, 
            data.items.backoff * 1000);  
        } else {
            load(1);
        }
      });
  }
  
  loadSites();
}());
#onhold div {
  overflow:hidden;
  text-overflow: ellipsis;
  white-space:nowrap;
  }

#load {
  padding: 1em;
  text-align: center; 
  cursor: pointer
  }

img {
  height: 1em;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="error" style="display:none">
</div>
<div id="fav">
  
</div>
<div id="load" style="display:none">
 Click to load more ...
</div>

1
  • 1
    This is perfect.
    – nicael
    Nov 7, 2015 at 9:11
1

With "one search from the homepage stackexchange.com", the most closest alternative I find is to search for "featured questions - " using the network wide search, powered by Google (<-- which means that the SE magical search operators don't work), but this starts to output unwanted results from the pages > 2.

https://stackexchange.com/search?q=%22featured%20questions%20-%20%22

This will show the lists of the featured questions on all the SE sites and you can click on one list.

The other options, like searching for "This question has an open bounty" doesn't work because the google search seems to be cached. The data explorer won't help there because it's updated only every week (though I believe @rene can create one, taking the questions with the bounties set < 8 days ago).

So, I'm not sure there's direct alternative to the per-site featured lists.

4
  • Your search isn't the greatest. I did some experimenting of my own and found out this works: "This question has an open bounty worth" Nov 6, 2015 at 22:14
  • @AChildofGod The other options, like searching for "This question has an open bounty" doesn't work because the google search seems to be cached - look at the results: the 44% of those results would be wrong because of already expired bounties and bounties which were started less than 2 days ago. And also the first is just a meta post about the bounty.
    – nicael
    Nov 6, 2015 at 22:23
  • Remind me what the first is. Nov 6, 2015 at 22:24
  • 1
    Well, the first result of your search. Or have you lost your comment?
    – nicael
    Nov 6, 2015 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .