This is my summer internship project/task
https://instastatsapp.streamlit.app/
This project is an Instagram Analytics Dashboard built for the Department of Regional Management of Astana Hub. It allows tracking, analyzing, and visualizing the Instagram performance of 20 regional IT hubs across Kazakhstan (e.g., astana.hub, almaty_hub, terriconvalley).
- Live Data Fetching: Retrieves real-time profile metrics (followers, total posts) and post-level metrics (likes, comments, views) using the instagram-looter2 RapidAPI.
- Interactive Streamlit Dashboard: A user-friendly web interface providing:
- KPI Metrics: Total followers, total posts, and average engagement rate (ER).
- Data View: A tabular view of recent posts with color-coded engagement metrics.
- Interactive Visualizations: Time-series charts for follower growth and ER trends, along with content format breakdowns.
- Content Intelligence: Highlights the top 3 best-performing posts based on total engagement.
- Historical Tracking: Integrates with Google Sheets to store weekly snapshots of account metrics, enabling week-over-week, month-over-month, and year-over-year growth analysis.
- Automated Weekly Sync: Includes a scheduled background job to automatically scrape and sync metrics for all 20 hubs to Google Sheets every Monday morning.
app.py: The main Streamlit application providing the UI, data visualizations, and manual sync controls.scraper.py: Handles the interaction with the RapidAPI endpoint, processing the raw JSON response into structured metrics (calculating engagement rates, classifying content formats).google_sheets_writer.py: Manages the connection to Google Sheets usinggspreadand Google Service Account credentials. It reads historical data for the dashboard and writes new sync payloads.weekly_sync_job.py: A standalone script using theschedulelibrary to automate the data sync for all hubs.
- Python 3.8+
- A RapidAPI account with a subscription to the instagram-looter2 API.
- Google Cloud Service Account credentials with access to Google Sheets.
-
Install the required dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a
.envfile in the root directory and add the following variables:RAPIDAPI_KEY=your_rapidapi_key_here SPREADSHEET_ID=your_google_spreadsheet_id_or_name GOOGLE_CREDENTIALS_JSON='{"type": "service_account", ...}'
Note: Alternatively, you can place a
credentials.jsonfile in the root directory for Google Sheets authentication.
To launch the Streamlit dashboard locally:
streamlit run app.pyTo start the background scheduler that syncs data weekly:
python weekly_sync_job.py- Frontend: Streamlit
- Data Manipulation: Pandas
- Visualizations: Plotly Express
- Data Sourcing: RapidAPI (instagram-looter2)
- Storage: Google Sheets API (gspread)
- Automation: Schedule