DEV Community

Sahil Bondre
Sahil Bondre

Posted on • Edited on

This Post has 100 Positive Reactions

The script mentioned in the following blog post has been turned off now. So the script doesn't know when someone gave a positive reaction. But, I do and it delights me when I get a positive reaction 😄

Recently Tom Scott posted a video on Youtube whose title has the number of views of the video.

Alt Text

Here is what's happening behind the scenes. There's a script running which continuously updates the title of the video to match the view count. In the video, he talks about the rise (and kind of fall) of APIs provided by platforms. He talks about creative applications of accessing APIs and making bots.

I was quite amused by the video. Luckily Dev.to has its API in beta stage. Lightbulb! So I wrote a small Typescript Bot that continually updates the total positive reactions to this post in the title. If everything is working alright, the sum of the positive responses to the post should match with the title. If it is not, then I either shut down the script, or it crashed.

Alt Text

The fun part is that you can try the code yourself and publish your post like this one! Find the code in this repo

🚀 Find me on Instagram | Github | Twitter | Website
😄 Have a wonderful day!

Top comments (12)

Collapse
 
itsjzt profile image
Saurabh Sharma

Well done 👍

Collapse
 
itsjzt profile image
Saurabh Sharma • Edited

Is the like reaction also automated?

Collapse
 
godcrampy profile image
Sahil Bondre

Nah It's was me 😅

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Does not real time update on mobile app.

Collapse
 
godcrampy profile image
Sahil Bondre

Try reloading after you react to the post.

Collapse
 
mohammedasker profile image
Mohammed Asker

Hey, this is so cool! Before it was 29 and after I liked the posts, it updated itself.

Collapse
 
terkwood profile image
Felix Terkhorn

Pretty quick to update!

Collapse
 
terkwood profile image
Felix Terkhorn

And I like how concise your code is. Thanks!

Collapse
 
robole profile image
Rob OLeary

Nice job! Are you running it as a cron job on your local machine?

Collapse
 
godcrampy profile image
Sahil Bondre

yup it's a cron job running on my local machine. Here's the code. I've stopped it now so it won't update anymore.

Collapse
 
harryammon profile image
Harry Ammon

Very cool, didn't know dev.to had an API. My favourite part of Toms' Video is the end line, "the code was never the important part"

Collapse
 
godcrampy profile image
Sahil Bondre

I stumbled upon the dev.to beta API the other day. Luckily I ended up watching the Tom's video later on. Tom's videos are always great to watch!
What's your favorite programming language? 😄