DEV Community

Eugenio Camargo
Eugenio Camargo

Posted on

My Instagram mention monitoring kept breaking, so I automated it

I got tired of checking Instagram manually.

This was for a small online store. We wanted to notice when someone tagged the account or mentioned it, mostly so those posts wouldn't just sit there unnoticed.

At first, I thought this would be a pretty simple thing to automate.

It wasn't.

My first setup was a mixture of manual checking and some scraping. It worked for a while, then stopped working reliably. I'd come back to it, fix something, and eventually end up checking Instagram manually again.

So I decided to stop trying to patch that setup and make the workflow much simpler.

The workflow I ended up with is basically:

  1. Check for new Instagram activity.
    1. Get the post/user data through an API.
    2. Compare it against the items I've already processed.
    3. Keep only the new stuff.
    4. Send those items to the next step of the workflow.

I'm using HikerAPI for the Instagram API part. The useful thing for my case was simply having REST endpoints I could call from the automation instead of maintaining the scraping code myself.

A request looks roughly like this:

import requests

headers = {"x-access-key": "YOUR_KEY"}

user = requests.get(
    "https://api.hikerapi.com/v2/user/by/username?username=google",
    headers=headers
).json()

r = requests.get(
    "https://api.hikerapi.com/v2/user/stories",
    params={"user_id": user["pk"]},
    headers=headers
)

print(r.json())
Enter fullscreen mode Exit fullscreen mode

I'm still keeping the workflow pretty boring on purpose.

The old setup had more moving parts than it needed. The new one is basically just fetch → check → filter → process.

That's been much easier to maintain.

I'm interested in what other people here have automated around Instagram monitoring. What small repetitive task would you automate next?

Top comments (0)