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.
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.
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)
Well done 👍
Is the like reaction also automated?
Nah It's was me 😅
Does not real time update on mobile app.
Try reloading after you react to the post.
Hey, this is so cool! Before it was 29 and after I liked the posts, it updated itself.
Pretty quick to update!
And I like how concise your code is. Thanks!
Nice job! Are you running it as a cron job on your local machine?
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.
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"
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? 😄