Install
openclaw skills install instagram-collector-adarshCollects Instagram profile metrics for a handle using Apify, returning followers, posts, engagement rate, posting frequency, avg likes/comments, and top hash...
openclaw skills install instagram-collector-adarshCollects Instagram profile data for a given handle using the Apify Instagram Profile Scraper. Extracts follower count, engagement metrics, posting frequency, and top hashtags. This collector feeds into the Marketing Audit Pipeline to populate the Instagram Performance section of the final report.
// Function signature
collectInstagram(handle: string): Promise<InstagramData>
// The handle parameter is the Instagram username without the @ symbol.
// Example: "gymshark" (not "@gymshark")
interface InstagramData {
followers: number;
posts: number;
engagementRate: number; // Calculated: (avgLikes + avgComments) / followers * 100
postingFrequency: string; // e.g. "1.2 posts/day", "3 posts/week", "unknown"
avgLikes: number;
avgComments: number;
topHashtags: string[]; // Up to 10 most-used hashtags from recent posts
error?: string; // Present only when collector fails
}
apify~instagram-profile-scraperhttps://api.apify.com/v2/acts/apify~instagram-profile-scraper/runsAPIFY_API_TOKEN environment variablehandle string from the pipelineapifyService.scrapeInstagramProfile(handle) which starts an Apify actor runInstagramData interfaceengagementRate = ((avgLikes + avgComments) / followers) * 100;
followers is 0, set engagementRate to 0 to avoid division by zero= 1 post/day:
"X.X posts/day"
"X posts/week""X posts/month""unknown"#hashtag tokens using regex: /#(\w+)/gKey fields from Apify's raw output:
followersCount -> followerspostsCount -> postslatestPosts[].likesCount -> used for avgLikeslatestPosts[].commentsCount -> used for avgCommentslatestPosts[].caption -> used for hashtag extractionlatestPosts[].timestamp -> used for posting frequencytry/catchEMPTY_INSTAGRAM_DATA with error field set:return { ...EMPTY_INSTAGRAM_DATA, error: 'Instagram data unavailable: <reason>' };
InstagramData objectlogger.error('Instagram collector failed', { handle, err });
import { collectInstagram } from '../collectors/instagramCollector';
// Successful collection
const data = await collectInstagram('gymshark');
// Returns:
// {
// followers: 6800000,
// posts: 4520,
// engagementRate: 1.85,
// postingFrequency: "1.3 posts/day",
// avgLikes: 120000,
// avgComments: 5800,
// topHashtags: ["gymshark", "fitness", "gym", "workout", "fitnessmotivation", ...],
// }
// Failed collection (graceful degradation)
const failedData = await collectInstagram('nonexistent_handle_12345');
// Returns:
// {
// followers: 0,
// posts: 0,
// engagementRate: 0,
// postingFrequency: "unknown",
// avgLikes: 0,
// avgComments: 0,
// topHashtags: [],
// error: "Instagram data unavailable: Profile not found"
// }
apifyService.ts for the actual API communication. The collector handles only data mapping and calculations.apifyService.scrapeInstagramProfile to return fixture data.EMPTY_INSTAGRAM_DATA constant is defined in src/types/audit.types.ts and should be imported for fallback returns.