Python script to fetch Instagram users info

swiftInsta Avatar



swiftInsta Blog

In today’s digital age, extracting data from social media platforms is becoming increasingly crucial for businesses, researchers, and developers. Instagram, being a popular platform for sharing visual content, contains a wealth of information that can be harnessed for various purposes. In this blog post, we’ll explore how to use a Python script to fetch Instagram user information effortlessly.

Introduction to Instagram User Information Extraction

Python offers a wide range of tools and libraries that make data extraction from APIs a straightforward process. In this example, we’ll focus on fetching user information using the swiftInsta API which is published on RapidAPI.

Fetching User Information Using Python

To get started, you’ll need an API key from swiftInsta, which you can use to access the swiftInsta API. This API provides a convenient way to collect data from Instagram profiles.

import requests url = "" headers = { "X-API-Key": "API_KEY" } response = requests.get(url, headers=headers) if response.status_code == 200: data = response.json() if data['status'] == "ok": userInfo = data['data'] print("Id:", userInfo['id']) print("username:", userInfo['username']) print("full_name:", userInfo['full_name']) print("Followers:", userInfo['edge_followed_by']['count']) print("Followings:", userInfo['edge_follow']['count']) print("Category:", userInfo['business_category_name']) print("Private:", userInfo['is_private']) print("Verified:", userInfo['is_verified']) ''' Output: Id: 8536113897 username: googleindia full_name: Google India Followers: 993798 Followings: 19 Category: Business & Utility Services Private: False Verified: True '''

API will return lots of information related to a user. You can check sample responses in the documentation.