28

A question motivated by narcissism:

Is there some way I can find out the total number of upvotes I have received on my comments?

Similarly, can I somehow get a list of all of my comments sorted by their number of votes?

1

4 Answers 4

22

You can also query the live site's API for your results:

For the current Stack Exchange API 2.2:

Those have been valid for the outdated version 1.1 of the API:

Replace the number after "users" with your user id on the appropriate site.

3
  • How to use these queries?
    – sll
    Commented Dec 1, 2011 at 19:41
  • 2
    When I try the 2.2 links, I get a hard-to-read data dump. How can I find this in a user-friendly format?
    – gerrit
    Commented Mar 8, 2016 at 21:03
  • Same question as @gerrit.
    – Wildcard
    Commented Jun 30, 2017 at 1:06
7

You can find out in the data explorer; the data is updated every other month.

and for comparison:

1
5

That's one of the more popular queries on data.stackexchange.com: My Comment score distribution. It is not as real-time as you might like though.

3
  • For my user number, it is giving a blank value in score in last row. What does that mean? Commented Mar 4, 2013 at 18:13
  • @RavindraGullapalli the last row shows comments that have no score.
    – Dyppl
    Commented Mar 5, 2013 at 22:57
  • Then it should show that counter in zero score. Not as blank. Commented Mar 6, 2013 at 6:26
1

Building on Rick Sladkey's answer, I threw a quick Python webserver together so you can see a nice formatted list of a user's top comments.

Note that this is really rough (does zero error checking), but seems to work just fine. Much easier than groking JSON.

Just run it and go to http://localhost:8000/119527

  • Replace 119527 with your user ID (unless you want to see my smart-ass comments)
  • You can specify a port other than 8000 on the command line.
import sys, urllib2, zlib, json
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

MIN = 5

def get_json(url):
    u = urllib2.urlopen(url)
    gzipped = u.read()
    data = zlib.decompress(gzipped, 16+zlib.MAX_WBITS)
    return json.loads(data)

def get_username(uid):
    d = get_json('http://api.stackoverflow.com/1.1/users/{0}'.format(uid))
    return d['users'][0]['display_name']

def do_comments_html(uid, r):
    d = get_json('http://api.stackoverflow.com/1.1/users/{0}/comments?sort=votes&min={1}'.format(uid, MIN))

    r.write('<html>\r\n')
    r.write('<head><title>SO Comments</title></head>\r\n')
    r.write('<body>\r\n')

    name = get_username(uid)
    r.write('<h3>{0} has {1} comments with >= {2} votes. Here are the top {3}</h3>\r\n'.format(
        name, d['total'], MIN, min(MIN,d['pagesize'])) )
    r.write('<ul>\r\n')
    for c in d['comments']:
        url = 'http://stackoverflow.com/posts/comments/{0}'.format(c['comment_id'])
        r.write('<li> <a href="{0}" target="_blank">[{1}]</a>  {2}</li>\r\n'.format(url, c['score'], c['body']))
    r.write('</ul>\r\n')

    r.write('</body>\r\n</html>\r\n')


class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    #Handler for the GET requests
    def do_GET(self):
        parts = self.path.split('/')
        if len(parts) != 2:
            self.send_error(404, 'Bad URL')
            return         
        try:
            uid = int(parts[1])
        except ValueError:
            self.send_error(404, 'Bad user id')
            return

        print 'UID:', uid

        mimetype = 'text/html'
        self.send_response(200)
        self.send_header('Content-type', mimetype)
        self.end_headers()

        do_comments_html(uid, self.wfile)


if sys.argv[1:]:
    port = int(sys.argv[1])
else:
    port = 8000
server_address = ('127.0.0.1', port)

httpd = BaseHTTPServer.HTTPServer(server_address, MyHandler)

sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
try:
    httpd.serve_forever()
except KeyboardInterrupt:
    print 'Closing server.'
    httpd.socket.close()
1
  • I think you need to have at least 25,000 reputation points in order to do that. Commented Mar 9, 2016 at 1:18

You must log in to answer this question.

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