DEV Community

Cover image for How I pull likes, comments, saves and views from TikTok, Instagram, X and YouTube links without APIs key
P33M
P33M

Posted on

How I pull likes, comments, saves and views from TikTok, Instagram, X and YouTube links without APIs key

I'm building something that needs engagement numbers for social media posts, and I got tired of paying for APIs to get them. So I wrote a small tool that takes a link and gives the numbers back, and I put it on GitHub in case it saves someone else the same bill.

It's called social-pulse. You give it a link to a public TikTok, Instagram, Facebook, X or YouTube post and it prints the likes, comments, reposts, shares, saves and views. It's a command line tool, with a small HTTP API mode if you want to call it from something else. No browser is involved and you don't need a developer API key.

social-pulse output for a TikTok link

What each platform gives you

No tool can return a number the platform doesn't publish, so here is what's actually available. A dash in the output means the number wasn't available. It doesn't mean zero.

Platform Likes Comments Reposts Shares Saves Views
TikTok yes yes yes yes yes yes
X yes yes (replies) yes no yes (bookmarks) yes
Instagram yes yes with cookies with cookies no with cookies
Facebook yes (all reactions) yes no yes no videos only
YouTube yes yes no no no yes

Instagram is the awkward one. Reposts, shares and the play count the app shows only come through when you're logged in, so you pass it your own cookies file. Without one you still get likes and comments, plus an older views counter that can sit well below what the app shows. The tool prints a warning when that happens.

Try it

You need Python 3.11 or newer.

git clone https://github.com/p33mTheRealOne/social-pulse.git
cd social-pulse
python -m venv venv
venv\Scripts\activate
pip install -e .
Enter fullscreen mode Exit fullscreen mode

On macOS and Linux, use source venv/bin/activate instead of the activate line.

Then run it on a link, and put the link in double quotes. Links usually contain &, and without quotes your shell cuts the command at the first one. I hit that on my first try with a TikTok link and got "'sender_device' is not recognized as an internal or external command".

social-pulse "https://www.tiktok.com/@noimpurity/video/7687658250057075990"
Enter fullscreen mode Exit fullscreen mode

If you only want some of the numbers, ask for them:

social-pulse "https://www.tiktok.com/@noimpurity/video/7687658250057075990" --fields likes,saves --json
Enter fullscreen mode Exit fullscreen mode

For a list of links, put them in a text file, one per line, and write a CSV:

social-pulse --file links.txt -o report.csv
Enter fullscreen mode Exit fullscreen mode

How it works

Each platform has a list of sources that run in order, and the results are merged field by field. If the first source is missing a number, the next one can fill it in, and the tool stops as soon as it has the fields you asked for.

  • Requests go out through curl_cffi with a Chrome TLS fingerprint, so they look like a normal browser at the connection level.
  • TikTok's numbers come from the JSON embedded in the page.
  • YouTube goes through yt-dlp, then one extra request fetches the exact comment count, because yt-dlp rounds it. On one video I tried it gave 48K where the real number was 48,803.
  • X works without a login, but reposts, bookmarks and views come from api.fxtwitter.com, a third-party service that sees the post's username and ID. --local-only switches that off, and then you only get likes and replies.
  • Instagram reposts, shares and the play count come from Instagram's logged-in JSON endpoint, which is why that one needs your cookies.

Every request and redirect is also checked against a list of the supported domains, so a short link can't send the tool to an arbitrary or internal address. That matters once you run it as an API.

API mode

pip install -e ".[api]"
set PULSE_API_KEYS=my-secret-key
pulse-api
Enter fullscreen mode Exit fullscreen mode

Then call it:

curl -H "X-API-Key: my-secret-key" "http://127.0.0.1:8000/v1/metrics?url=https://www.tiktok.com/@noimpurity/video/7687658250057075990&fields=likes,saves"
Enter fullscreen mode Exit fullscreen mode

It has API keys, a rate limit, a short cache and a batch endpoint for up to 10 links. If you put it on a public server, use HTTPS, and expect TikTok, Instagram and Facebook to block datacenter IP addresses more often than home connections.

What doesn't work

It reads pages the platforms never documented for this, so it breaks when one of them changes something. Some platforms round their numbers (TikTok sent 10,500 for one video, Facebook sent 9.4K for shares) and you get what they send. Saves aren't public on Instagram, Facebook or YouTube. Private and deleted posts fail.

On 2026-11-15 I compared the output with the apps for a TikTok video, an X post, a YouTube video and Short, a Facebook reel and post, and an Instagram reel. Instagram photo posts and Facebook posts without cookies are untested.

Automated access can conflict with a platform's terms of service. I'd stick to public posts and small batches, and read the terms of whichever platform you're pulling from.

How I built it

I built this with an AI coding assistant. I picked the platforms and the approach, ran it against real posts, and kept sending back what was wrong until the numbers matched the apps. I checked the claims in this post against the code and my own test runs.

The code is on GitHub under the MIT license: https://github.com/p33mTheRealOne/social-pulse

If a number looks wrong for you, open an issue with the --debug output. Remove anything personal first, and never paste your cookies.

Top comments (1)

Collapse
 
gautamtalksdev profile image
Gautam K •

Pulling engagement numbers yourself is a good way to learn how fragile those endpoints are. Worth checking each platform's terms before running it at scale, since some allow official API access only. Which platform was hardest to get stable numbers from?