JavaSript / Soapi.JS
using Soapi.JS
Soapi.RouteFactory("api.stackapps.com", apiKey) // get all users
.Questions({ pagesize: 100 }).getPagedResponse(function(data) {
var values = {}, keys = [];
// add up the favorite for each user
for (var i = 0; i < data.items.length; i++) {
var q = data.items[i];
var u = q.owner;
if (u) {
if (!values[u.user_id]) {
keys.push(u.user_id);
values[u.user_id] = {
display_name: u.display_name,
favorite_count: 0
};
}
values[u.user_id].favorite_count += q.favorite_count;
}
}
// sort and dump
var output = "";
for (var i = 0; i < keys.sort(function(a, b) {
return values[b].favorite_count - values[a].favorite_count;
}).length; i++) {
output += values[keys[i]].favorite_count + " " + values[keys[i]].display_name + "\r\n";
}
document.getElementById("output").innerHTML = output;
});
Output:
100 Kevin Montrose 88 George Edison 81 code poet 28 Soviut 27 lfoust 22 Adam Wright 22 systempuntoout 21 S.Mark 20 Felix 17 Farseeker 16 Dave DeLong 11 Dave Swersky 10 Bill the Lizard 9 Matt S. 9 Franci Penov 8 Jeff Atwood 8 Edan Maor 7 Jedi Master Spooky 7 codeka 7 carson 7 nabeelmukhtar 7 Shay Erlichmen 7 swanson 6 Steffen Opel 6 Lucas Jones 6 Jason 6 Thomas McDonald 6 Kyle Cronin 6 Joel Potter 5 conmulligan 5 Catchwa 5 Jonathan 5 TheHurt 5 Ricky 5 SztupY 5 ColinD 5 Mark Rushakoff 4 Adam 4 jjnguy 4 chenyuejie 4 Koning Baard 3 Yacoby 3 phsr 3 Nick Presta 3 Igor Zevaka 3 johnwards 3 blork 3 Robert Munteanu 3 Riduidel 3 InfinitiesLoop 3 Martin Plante 2 tonklon 2 Ryan Brunner 2 Dennis Williamson 2 Soldier.moth 2 eWolf 2 Josh Kelley 2 radius 2 James A. Rosen 2 Kevin 2 RichH 2 Nippysaurus 2 Peter Mortensen 2 John Bristowe 2 Mark Hurd 2 adrianbanks 1 Alexandre Rafalovitch 1 balpha 1 Matt Culbreth 1 mlaw 1 Nathan Reed 1 Nicolas Raoul 1 tsudot 1 Ngu Soon Hui 1 Nathan Voxland 1 Joe 1 Michael B. 1 Shane 1 Frank Krueger 1 Robert Cartaino 1 Charles Stewart 1 svick 1 jmoy 1 Fernando 1 Peter Mourfield 1 pufferfish 1 Artefacto 1 Robert Love 1 iconiK 1 voyager 1 coobird 1 Lucas McCoy 1 Chacha102 1 Matthew Pelser
Requests generated
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom 1 200 HTTP api.stackapps.com /1.0/questions?key=foo-bar-fu&pagesize=100&page=1&jsonp=Soapi._internal._callback0 14,525 private application/json; charset=utf-8 iexplore:5676 2 200 HTTP api.stackapps.com /1.0/questions?key=foo-bar-fu&pagesize=100&page=2&jsonp=Soapi._internal._callback1 14,704 private application/json; charset=utf-8 iexplore:5676 3 200 HTTP api.stackapps.com /1.0/questions?key=foo-bar-fu&pagesize=100&page=3&jsonp=Soapi._internal._callback2 15,407 private application/json; charset=utf-8 iexplore:5676 4 200 HTTP api.stackapps.com /1.0/questions?key=foo-bar-fu&pagesize=100&page=4&jsonp=Soapi._internal._callback3 14,012 private application/json; charset=utf-8 iexplore:5676 5 200 HTTP api.stackapps.com /1.0/questions?key=foo-bar-fu&pagesize=100&page=5&jsonp=Soapi._internal._callback4 14,457 private application/json; charset=utf-8 iexplore:5676 6 200 HTTP api.stackapps.com /1.0/questions?key=foo-bar-fu&pagesize=100&page=6&jsonp=Soapi._internal._callback5 4,234 private application/json; charset=utf-8 iexplore:5676 7 200 HTTP api.stackapps.com /1.0/questions?key=foo-bar-fu&pagesize=100&page=7&jsonp=Soapi._internal._callback6 204 private application/json; charset=utf-8 iexplore:5676