What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

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?

share|improve this question

4 Answers 4

up vote 18 down vote accepted

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.

share|improve this answer
    
How to use these queries? –  sll Dec 1 '11 at 19:41

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

and for comparison:

share|improve this answer
    
Substitute (adapted by ACuriousMind @ Physics.SE) for the second link, which is no longer functional: data.stackexchange.com/physics/query/238582/comments-and-votes –  Danu Oct 25 at 16:31

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.

share|improve this answer
    
For my user number, it is giving a blank value in score in last row. What does that mean? –  Ravindra Gullapalli Mar 4 '13 at 18:13
    
@RavindraGullapalli the last row shows comments that have no score. –  Dyppl Mar 5 '13 at 22:57
    
Then it should show that counter in zero score. Not as blank. –  Ravindra Gullapalli Mar 6 '13 at 6:26

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()
share|improve this answer

You must log in to answer this question.

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