A NestJS application that uses Telegram bot to notify users about new car listings from Copart.
- Fetches new car listings from Copart API periodically
- Sends notifications to Telegram users about new listings
- Allows users to customize notification schedule using cron expressions
- Stores car listings and user preferences in a database
- Node.js (v18 or later)
- npm or yarn
- Telegram Bot Token (obtained from BotFather)
- Clone the repository:
git clone <repository-url>
cd copart-notifier- Install dependencies:
npm install- Create a
.envfile in the root directory with your Telegram bot token:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
npm run start:devnpm run build
npm run start:prodTo test the Copart API integration without running the full application:
npm run test:copart-apiThis will run a test script that fetches car listings from Copart and displays sample results. The script will show the first few listings with details like lot number, model, year, price, auction date, and image URL.
Example output:
Testing Copart API integration...
Sending request to Copart API...
Successfully fetched 20 car listings
Sample listings:
Listing 1:
- Lot Number: 64388354
- Model: A4 PREMIUM
- Year: 2017
- Price: $2350
- Auction Date: 4/21/2025
- Image URL: https://cs.copart.com/v1/AUTH_svc.pdoc00001/lpp/0724/80505467e3644ca9af56cd6bec9140d2_thb.jpg
/start- Start receiving notifications/help- Show available commands/setschedule [cron]- Set notification schedule using cron expression (e.g.,/setschedule 0 */2 * * *for every 2 hours)/status- Show current notification settings/stop- Stop receiving notifications
- Open Telegram and search for "BotFather"
- Start a chat with BotFather and send the command
/newbot - Follow the instructions to create a new bot
- Once created, BotFather will provide you with a token
- Copy this token to your
.envfile
apps/copart-notifier/src/app/bot- Telegram bot integrationapps/copart-notifier/src/app/copart- Copart API integration and data processinginterfaces- TypeScript interfaces for Copart API request/response
apps/copart-notifier/src/app/database- Database entities and configurationapps/copart-notifier/src/app/scheduler- Scheduled tasks for fetching data
The application uses the Copart API to fetch car listings:
- Endpoint:
https://www.copart.com/public/lots/vehicle-finder-search-results - Method: POST
- Request: JSON payload with filters, sorting, and pagination
- Response: JSON with car listings including details like model, year, price, auction date, etc.
The API integration allows for filtering by make, model, year, drive type, and other parameters, which can be customized in the createFilter method of the CopartService.
MIT