<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Scaplejett</title>
    <description>The latest articles on DEV Community by Scaplejett (@scaplejett_651bc524e85d7a).</description>
    <link>https://dev.to/scaplejett_651bc524e85d7a</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4263101%2F87f3c0f4-44dd-472b-9c9d-d32fe8de6117.png</url>
      <title>DEV Community: Scaplejett</title>
      <link>https://dev.to/scaplejett_651bc524e85d7a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/scaplejett_651bc524e85d7a"/>
    <language>en</language>
    <item>
      <title>I wanted to back up my Instagram posts, stories, and highlights — here's what I learned comparing instagrapi and hosted APIs</title>
      <dc:creator>Scaplejett</dc:creator>
      <pubDate>Tue, 24 Nov 2026 17:32:03 +0000</pubDate>
      <link>https://dev.to/scaplejett_651bc524e85d7a/i-wanted-to-back-up-my-instagram-posts-stories-and-highlights-heres-what-i-learned-comparing-2de4</link>
      <guid>https://dev.to/scaplejett_651bc524e85d7a/i-wanted-to-back-up-my-instagram-posts-stories-and-highlights-heres-what-i-learned-comparing-2de4</guid>
      <description>&lt;p&gt;The end result was a backup workflow that didn't require me to constantly troubleshoot Instagram session issues or maintain the scraping layer myself. I could focus on collecting the content I actually wanted to preserve: my posts, stories, and highlights.&lt;/p&gt;

&lt;p&gt;Getting there meant comparing two approaches: instagrapi and a hosted REST API.&lt;/p&gt;

&lt;p&gt;They solve a similar problem, but the maintenance responsibilities are quite different.&lt;/p&gt;

&lt;p&gt;What I was trying to build&lt;/p&gt;

&lt;p&gt;I wanted a straightforward way to back up my own Instagram content. Not a complicated analytics system — just a way to retrieve media and metadata and keep a local copy.&lt;/p&gt;

&lt;p&gt;The things I cared about were:&lt;/p&gt;

&lt;p&gt;Posts and their associated media&lt;/p&gt;

&lt;p&gt;Stories while they were available&lt;/p&gt;

&lt;p&gt;Highlights and their contents&lt;/p&gt;

&lt;p&gt;Metadata needed to organize the downloaded files&lt;/p&gt;

&lt;p&gt;The first approach I considered was running everything locally with instagrapi.&lt;/p&gt;

&lt;p&gt;Option 1: instagrapi — self-hosted control&lt;/p&gt;

&lt;p&gt;instagrapi is a Python library that lets you interact with Instagram through your own code and infrastructure.&lt;/p&gt;

&lt;p&gt;The main advantage is control. I can decide how the application works, where data is stored, how requests are handled, and how the rest of the backup pipeline is structured.&lt;/p&gt;

&lt;p&gt;What I liked&lt;/p&gt;

&lt;p&gt;No API provider billing per request&lt;/p&gt;

&lt;p&gt;Direct integration with Python&lt;/p&gt;

&lt;p&gt;Full control over the workflow and storage&lt;/p&gt;

&lt;p&gt;Easy to customize for a specific backup system&lt;/p&gt;

&lt;p&gt;No external API service sitting between my application and the data retrieval layer&lt;/p&gt;

&lt;p&gt;What I didn't like as much&lt;/p&gt;

&lt;p&gt;Self-hosted doesn't mean maintenance-free.&lt;/p&gt;

&lt;p&gt;Session management, authentication problems, compatibility changes, request failures, and debugging become my responsibility. If something stops working, I'm the one investigating it.&lt;/p&gt;

&lt;p&gt;For a project where I enjoy maintaining the underlying integration, this is reasonable. For a backup job that I just want to run reliably, it becomes another thing to maintain.&lt;/p&gt;

</description>
      <category>api</category>
      <category>automation</category>
      <category>python</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>Building a Telegram Bot That Monitors Instagram Posts with Concurrent Python Requests</title>
      <dc:creator>Scaplejett</dc:creator>
      <pubDate>Tue, 24 Nov 2026 16:42:33 +0000</pubDate>
      <link>https://dev.to/scaplejett_651bc524e85d7a/building-a-telegram-bot-that-monitors-instagram-posts-with-concurrent-python-requests-42pb</link>
      <guid>https://dev.to/scaplejett_651bc524e85d7a/building-a-telegram-bot-that-monitors-instagram-posts-with-concurrent-python-requests-42pb</guid>
      <description>&lt;p&gt;What if I could monitor multiple Instagram accounts without waiting for each request to finish one by one?&lt;/p&gt;

&lt;p&gt;That was the problem I was trying to solve. I wanted a Telegram bot that checks selected Instagram accounts and sends me a notification whenever something new is posted.&lt;/p&gt;

&lt;p&gt;The straightforward approach works, but when you're checking multiple accounts, making every request sequentially starts wasting time waiting for network responses. Since this is mostly an I/O-bound task, concurrency makes more sense.&lt;/p&gt;

&lt;p&gt;Starting with a basic API request&lt;/p&gt;

&lt;p&gt;I started with a simple request using Python's requests library:&lt;/p&gt;

&lt;p&gt;import requests&lt;/p&gt;

&lt;p&gt;headers = {"x-access-key": "YOUR_KEY"}&lt;/p&gt;

&lt;p&gt;resp = requests.get(&lt;br&gt;
    "&lt;a href="https://api.hikerapi.com/v2/hashtag/medias/top?name=travel" rel="noopener noreferrer"&gt;https://api.hikerapi.com/v2/hashtag/medias/top?name=travel&lt;/a&gt;",&lt;br&gt;
    headers=headers&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;print(resp.json())&lt;/p&gt;

&lt;p&gt;This is fine for a single request. The problem is that if I repeat this for multiple accounts, each request waits for the previous one to finish.&lt;/p&gt;

&lt;p&gt;Why concurrency helps&lt;/p&gt;

&lt;p&gt;Network requests spend much of their time waiting for a response. Rather than waiting for each request sequentially, I can run multiple requests concurrently.&lt;/p&gt;

&lt;p&gt;For this workflow, I used HikerAPI, a REST Instagram API. It offers pricing starting at $0.001/request and 100 free requests to get started.&lt;/p&gt;

&lt;p&gt;The goal isn't to fire unlimited requests. It's to reduce unnecessary waiting while keeping requests controlled.&lt;/p&gt;

&lt;p&gt;Using asyncio with aiohttp&lt;/p&gt;

&lt;p&gt;For a larger monitoring list, async requests are a useful approach. aiohttp allows multiple HTTP requests to be in progress without blocking the entire program.&lt;/p&gt;

&lt;p&gt;import asyncio&lt;br&gt;
import aiohttp&lt;/p&gt;

&lt;p&gt;API_URL = "&lt;a href="https://api.hikerapi.com/v2/hashtag/medias/top" rel="noopener noreferrer"&gt;https://api.hikerapi.com/v2/hashtag/medias/top&lt;/a&gt;"&lt;br&gt;
HEADERS = {"x-access-key": "YOUR_KEY"}&lt;/p&gt;

&lt;p&gt;async def fetch(session, hashtag):&lt;br&gt;
    params = {"name": hashtag}&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async with session.get(API_URL, params=params, headers=HEADERS) as response:
    response.raise_for_status()
    return await response.json()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;async def main():&lt;br&gt;
    hashtags = ["travel", "technology", "photography"]&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async with aiohttp.ClientSession() as session:
    results = await asyncio.gather(
        *(fetch(session, tag) for tag in hashtags),
        return_exceptions=True
    )

for tag, result in zip(hashtags, results):
    if isinstance(result, Exception):
        print(f"{tag}: request failed - {result}")
    else:
        print(f"{tag}: fetched successfully")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;asyncio.run(main())&lt;/p&gt;

&lt;p&gt;This demonstrates the concurrency pattern: multiple requests are started together, and the program collects their results as they finish.&lt;/p&gt;

&lt;p&gt;For an account-monitoring bot, the same pattern can be applied to the relevant account-data endpoints instead of hashtag endpoints.&lt;/p&gt;

&lt;p&gt;Keeping concurrency under control&lt;/p&gt;

&lt;p&gt;Running concurrent requests doesn't mean running unlimited requests. I would use a semaphore to control the number of simultaneous connections:&lt;/p&gt;

&lt;p&gt;semaphore = asyncio.Semaphore(5)&lt;/p&gt;

&lt;p&gt;async def controlled_fetch(session, hashtag):&lt;br&gt;
    async with semaphore:&lt;br&gt;
        return await fetch(session, hashtag)&lt;/p&gt;

&lt;p&gt;This gives the application a limit on simultaneous requests. It's useful for avoiding unnecessary bursts and making request behavior more predictable.&lt;/p&gt;

&lt;p&gt;Handling rate limits and failures&lt;/p&gt;

&lt;p&gt;A monitoring bot needs to handle API failures properly. A request shouldn't crash the entire monitoring cycle just because one endpoint temporarily fails.&lt;/p&gt;

&lt;p&gt;Things I would account for:&lt;/p&gt;

&lt;p&gt;429 Too Many Requests: Respect rate limits and any Retry-After header provided.&lt;/p&gt;

&lt;p&gt;5xx errors: Retry temporary server failures with exponential backoff.&lt;/p&gt;

&lt;p&gt;Timeouts: Set a reasonable request timeout rather than allowing requests to hang indefinitely.&lt;/p&gt;

&lt;p&gt;Partial failures: Let other accounts finish checking if one request fails.&lt;/p&gt;

&lt;p&gt;Duplicate notifications: Track the last processed post ID so the bot doesn't notify me about the same post repeatedly.&lt;/p&gt;

&lt;p&gt;Retries should be limited. Repeatedly retrying a rate-limited request just creates more traffic and usually makes the problem worse.&lt;/p&gt;

&lt;p&gt;Connecting it to Telegram&lt;/p&gt;

&lt;p&gt;Once the API returns the data, the remaining part is relatively simple:&lt;/p&gt;

&lt;p&gt;Compare the latest post against the last post stored for that account.&lt;/p&gt;

&lt;p&gt;If it's new, save the updated post ID.&lt;/p&gt;

&lt;p&gt;Send a Telegram message with the account and post information.&lt;/p&gt;

&lt;p&gt;Continue the next monitoring cycle.&lt;/p&gt;

&lt;p&gt;The important part is storing the last processed post somewhere persistent. Otherwise, restarting the bot could cause old posts to trigger notifications again.&lt;/p&gt;

&lt;p&gt;Async or threads?&lt;/p&gt;

&lt;p&gt;For this particular workflow, I'd generally start with asyncio because monitoring Instagram is primarily network-bound.&lt;/p&gt;

&lt;p&gt;Threads using ThreadPoolExecutor are also perfectly reasonable if the existing code already uses requests and I don't want to rewrite everything around an async HTTP client.&lt;/p&gt;

&lt;p&gt;The choice depends more on the existing application and how many requests need to be managed than on async being inherently better.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;The useful part of concurrency here isn't making requests as fast as possible. It's being able to monitor multiple accounts without turning the entire process into a long sequence of network waits.&lt;/p&gt;

&lt;p&gt;For a Telegram notification bot, controlled concurrency, persistent post tracking, and sensible rate-limit handling matter more than simply increasing the number of simultaneous requests.&lt;/p&gt;

&lt;p&gt;I'd rather have a monitoring script that runs reliably over time than one that finishes a batch quickly and starts failing on the next cycle.&lt;/p&gt;

</description>
      <category>python</category>
      <category>api</category>
      <category>webscraping</category>
    </item>
  </channel>
</rss>
