dev.to karma rank

daviducolo profile image Davide Santangelo ・1 min read


just for fun I implemented a very simple algorithm that allow to calculate "Karma" rank of dev.to website, based on actual dev.to v0 API.

This is a simple ruby code ( you must install rest-client gem )

class DevToKarma 
  API_URL = 'https://dev.to/api'

  def initialize(username)
    @username = username

  attr_reader :username

  def posts
    page = 1
    result = []

    loop do
      response = RestClient.get "#{API_URL}/articles?username=#{username}&page=#{page}"
      posts = JSON.parse(response.body)
      result << posts

      page = page + 1
      break if posts.size == 0 


  def user
    response = RestClient.get "#{API_URL}/users/by_username?url=#{username}"

  def karma
    joined_at_timestamp = Time.parse(user.dig('joined_at')).to_i 

    posts_count = posts.size
    total_comments_count = posts.map { |r| r['comments_count'] }.sum
    total_positive_reactions_count = posts.map { |r| r['positive_reactions_count'] }.sum

    karma = ( posts_count + total_comments_count + total_positive_reactions_count ).to_f / ( joined_at_timestamp / 1000 / 1000 ) * 100



  DevToKarma.new('daviduco').karma # My own karma
  => 23 
  DevToKarma.new('ben').karma # Ben Halper karma
  => 3529 

obviously it is a "stupid" and little mathematical solution. Many other considerations and variables to use are missing. But it's a start!

Posted on by:

daviducolo profile

Davide Santangelo


developer - dad. APIs specialist, In love with #ruby, #rails and #python - developer at @getchorally


markdown guide

Nice Davide.

Is there a way to quickly check?


no at the moment but your karma is :)

=> 4


Thanks. Is that good? 🤣

Personally, I am not a fan of karma or point scoring on forums as the whole thing devolves into a competition for Karma not skills (I like your skills, I don't care about your karma). Your algo on serps/posts may be interesting but it's not my site so it's not up to me.

I try to maintain the lowest karma around. 😳

your opinion is reasonable, but competition serves to improve more and more :).

Agreed. But the 'karma club' starts to come into play (brigading/upvotings/sockpuppets/'leaders'). It speeds things up & shortens product lifecycle.

This is why followers are hidden rn. Same principles. Though the problem with hiding it is someone with 40yrs experience vs someone with 3 weeks is less clear & the equal platform aspect substantially degrades the quality of the info provided but real experts & inflates nonsense/weak knowledge.

Using your algo on search would surface better code (people) which makes everything better.


maybe @ben can add karma rank on dev.to officially :).


Karma opacity is a feature not a bug imo.


Why divide by join-time? Doesn't this just mean anyone who joined early will gain a lot more karma per activity than those that join late?

And I'm pretty sure the lack of "karma" on this site is intentional :-P