A simple Express.js API that fetches live CodeChef user data using Puppeteer with Redis caching.
- User Profile Info
- Rating Graph Data
- Recent Accepted Submissions
- Aggregated Whole Profile
- Upcoming Contests
- Redis-based caching
- Swagger API Docs
| Route | What it does |
|---|---|
/health |
Health check |
/api/whole/:handle |
Full profile data |
/api/profile/:handle |
Basic user info |
/api/ratings/:handle |
Ratings history |
/api/recent/:handle |
Recent submissions |
/api/upcoming |
Upcoming contests |
- Express.js server
- Puppeteer (headless scraping)
- Redis (caching)
- Clean REST APIs
- Node.js 18+
- Redis server
- Chrome/Chromium browser
-
Clone the Repository
git clone https://github.com/your-username/codechef-data-scraper.git cd codechef-data-scraper -
Install Dependencies
npm install
-
Configure Environment
cp .env.example .env
Edit
.envwith your settings:PORT=8800 REDIS_HOST=localhost REDIS_PORT=6379 CACHE_TTL=3600
-
Start Redis (if not running)
redis-server
-
Start Development Server
npm run dev
-
Test the API
http://localhost:8800/api/profile/your_codechef_username http://localhost:8800/api/whole/your_codechef_username
PORT- Server port (default: 8800)NODE_ENV- Environment (development/production)REDIS_HOST- Redis host (default: localhost)REDIS_PORT- Redis port (default: 6379)REDIS_PASSWORD- Redis password (optional)CACHE_TTL- Cache TTL in seconds (default: 3600)PUPPETEER_EXECUTABLE_PATH- Chrome path (auto-detected if not set)
The app automatically detects Chrome/Chromium:
- Windows:
C:\Program Files\Google\Chrome\Application\chrome.exe - Linux:
/usr/bin/google-chrome,/usr/bin/chromium - Custom: Set
PUPPETEER_EXECUTABLE_PATHto override
- With Redis: Full caching + distributed rate limiting
- Without Redis: Works fine, uses in-memory rate limiting (single instance only)
400 Bad Request- Invalid input404 Not Found- User not found500 Internal Server Error- Server errors503 Service Unavailable- Connection issues
ISC