<?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: Alan Perius</title>
    <description>The latest articles on DEV Community by Alan Perius (@alan_perius_5c3cf96e6b859).</description>
    <link>https://dev.to/alan_perius_5c3cf96e6b859</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%2F2972319%2Fb84067dc-cb7a-4931-8b53-b9c69d074338.jpg</url>
      <title>DEV Community: Alan Perius</title>
      <link>https://dev.to/alan_perius_5c3cf96e6b859</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alan_perius_5c3cf96e6b859"/>
    <language>en</language>
    <item>
      <title>Fetching public Instagram profiles and followers in Python with HikerAPI</title>
      <dc:creator>Alan Perius</dc:creator>
      <pubDate>Mon, 30 Nov 2026 02:05:42 +0000</pubDate>
      <link>https://dev.to/alan_perius_5c3cf96e6b859/fetching-public-instagram-profiles-and-followers-in-python-with-hikerapi-5hjk</link>
      <guid>https://dev.to/alan_perius_5c3cf96e6b859/fetching-public-instagram-profiles-and-followers-in-python-with-hikerapi-5hjk</guid>
      <description>&lt;p&gt;If you need public Instagram data (profiles, posts, followers) from a Python script, you basically have three options: scrape the web app yourself, use an unofficial library like instagrapi with a logged-in account, or pay a hosted API. This post walks through the third option with &lt;a href="https://hikerapi.com" rel="noopener noreferrer"&gt;HikerAPI&lt;/a&gt; and compares the tradeoffs honestly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;HikerAPI is a REST API. You sign up, get an access key, and send it in an &lt;code&gt;x-access-key&lt;/code&gt; header. Pricing is pay-per-request (their site lists prices starting around $0.001 per request, plus 100 free requests to try it).&lt;/p&gt;

&lt;p&gt;The only dependency is &lt;code&gt;requests&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Get a profile by username
&lt;/h2&gt;

&lt;p&gt;Most endpoints take a numeric user id (&lt;code&gt;pk&lt;/code&gt;), so the usual first step is resolving a username:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="no"&gt;API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.hikerapi.com"&lt;/span&gt;
&lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"x-access-key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"YOUR_KEY"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{API}/v2/user/by/username"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"apple"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"pk"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Get followers
&lt;/h2&gt;

&lt;p&gt;With the &lt;code&gt;pk&lt;/code&gt; you can request the follower list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{API}/v2/user/followers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"user_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"pk"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Large accounts return paginated results, so check the response for a cursor/next-page field and loop until it is empty. Every page is a billed request, so for accounts with millions of followers, set a hard limit on how many pages you fetch.&lt;/p&gt;

&lt;h2&gt;
  
  
  API vs. instagrapi vs. scraping
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Scraping the web app yourself&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free in money, expensive in time.&lt;/li&gt;
&lt;li&gt;Instagram changes markup and internal endpoints often, and rate limits / login walls kick in quickly.&lt;/li&gt;
&lt;li&gt;Fine for a one-off, painful to keep running.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;instagrapi (unofficial private API client)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Very capable and free.&lt;/li&gt;
&lt;li&gt;Requires logging in with a real Instagram account, which can get challenged or banned, and you manage sessions, proxies and 2FA yourself.&lt;/li&gt;
&lt;li&gt;Good if you want full control and accept the account risk.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;A hosted API like HikerAPI&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No Instagram account on your side; the provider handles sessions and proxies.&lt;/li&gt;
&lt;li&gt;You pay per request, so cost scales with volume — high-volume jobs (e.g. full follower dumps of big accounts) add up.&lt;/li&gt;
&lt;li&gt;You depend on a third party: if they have downtime or Instagram changes something, you wait for them.&lt;/li&gt;
&lt;li&gt;Only public data. Keep in mind Instagram's terms and privacy laws (GDPR etc.) apply to what you collect and store.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When it makes sense
&lt;/h2&gt;

&lt;p&gt;A paid API is worth it when the data feeds something you actually run (a dashboard, a monitoring job, an app feature) and you don't want to babysit accounts and proxies. For a quick experiment, the free requests are enough to see whether the response format fits your use case.&lt;/p&gt;

&lt;p&gt;What are you using for Instagram data right now, and what has broken on you the most?&lt;/p&gt;

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