Two new GitHub Actions have been created to scrape trending products from Social1.ai API:
- Daily Trending Products Scraper - Runs daily at 9:00 AM UTC
- Monthly Trending Products Scraper - Runs on the 1st of each month at 9:00 AM UTC
Both scrapers use the /api/products/getTopProducts endpoint and store data in Supabase.
github-action-product-daily-scraper.js- Daily product scraper (days=1)github-action-product-monthly-scraper.js- Monthly product scraper (days=30)
scripts/create-daily-trending-products-table.sql- SQL for daily products tablescripts/create-monthly-trending-products-table.sql- SQL for monthly products table
.github/workflows/daily-product-scraper.yml- Daily workflow.github/workflows/monthly-product-scraper.yml- Monthly workflow
- Go to your Supabase dashboard: https://supabase.com/dashboard
- Navigate to SQL Editor
- Run the SQL scripts:
For Daily Products:
-- Copy and paste contents from scripts/create-daily-trending-products-table.sqlFor Monthly Products:
-- Copy and paste contents from scripts/create-monthly-trending-products-table.sql- Stores daily trending products
collection_date: DATE format (YYYY-MM-DD)- Fetches products with
days=1
- Stores monthly trending products
collection_date: VARCHAR(7) format (YYYY-MM)- Fetches products with
days=30
- GitHub repository with Actions enabled
SUPABASE_KEYsecret already configured (same as video scrapers)
Daily Scraper:
- Runs: Every day at 9:00 AM UTC
- Cron:
0 9 * * * - Can be manually triggered via GitHub UI
Monthly Scraper:
- Runs: 1st day of each month at 9:00 AM UTC
- Cron:
0 9 1 * * - Can be manually triggered via GitHub UI
- Go to: https://github.com/salmanrajz/social1/actions
- Click on the workflow you want to test:
- "Daily Trending Products Scraper"
- "Monthly Trending Products Scraper"
- Click "Run workflow" → "Run workflow"
Each product record includes:
-
Basic Info:
product_id: Unique product identifierproduct_name: Product nameprice_value: Numeric priceprice_display: Formatted price stringproduct_img_url: Product image URL
-
Sales Metrics:
units_sold: Number of units soldgmv: Gross Merchandise Valuevideo_count: Number of videos featuring productcreator_count: Number of creators featuring product
-
Shop Info:
shop_name: Shop nameshop_id: Shop identifier
-
Categories:
categories: JSON array of categories
-
Metadata:
ranking: Product ranking (1-240)region: Geographic region (us/uk)collection_date: Date/month of collectionlast_updated: Timestamp
- URL:
https://www.social1.ai/api/products/getTopProducts - Parameters:
limit: 12 (products per page)offset: Pagination offsetdays: 1 (daily) or 30 (monthly)region: 'us' (default)
- Both scrapers target 240 products total
- Fetches in pages of 12 products
- Maximum 50 pages (600 products max, then slices to 240)
After running the scrapers, verify data in Supabase:
-- Check daily products
SELECT COUNT(*), collection_date, SUM(gmv) as total_gmv
FROM daily_trending_products_api
GROUP BY collection_date
ORDER BY collection_date DESC;
-- Check monthly products
SELECT COUNT(*), collection_date, SUM(gmv) as total_gmv
FROM monthly_trending_products_api
GROUP BY collection_date
ORDER BY collection_date DESC;The cookie in both scrapers may need to be updated periodically. To update:
- Get a fresh cookie from your browser (logged into social1.ai)
- Update the
COOKIEconstant in:github-action-product-daily-scraper.jsgithub-action-product-monthly-scraper.js
- Both scrapers use the same cookie and API endpoint
- Daily scraper uses
days=1, monthly usesdays=30 - Data is cleared and re-inserted for each collection date/month
- Retry logic handles network errors automatically
- 30-second timeout per request
- 2-second delay between requests to avoid rate limiting
After successful runs, you should see:
- ✅ 240 products inserted per run
- ✅ Total GMV calculated and logged
- ✅ Total units sold calculated and logged
- ✅ Data stored in respective tables