CheckPriceMacbook/README.md

53 lines
1.3 KiB
Markdown

# CheckPrice Server
Node.js Express server that checks eBay prices and notifies via Telegram.
## Features
- Runs a scheduled check every minute
- Gets eBay access token automatically using refresh token
- Searches eBay items by keyword
- Notifies Telegram group when items are found below price threshold ($650 USD)
## Setup
1. Install dependencies:
```bash
npm install
```
2. Configure `.env` file:
```
EBAY_CLIENT_ID=your_client_id
EBAY_CLIENT_SECRET=your_client_secret
EBAY_REFRESH_TOKEN=your_refresh_token
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
PORT=3000
```
3. Run the server:
```bash
npm start
```
## Configuration
- **PRICE_THRESHOLD**: Edit in `src/index.js` to change the price threshold (default: $650 USD)
- **Keywords**: Edit the `keywords` array in the cron job section to search for different items
## API Endpoints
- `GET /health` - Health check
- `POST /check` - Manual trigger with keyword
```json
{ "keyword": "your-search-term" }
```
## How It Works
1. Every minute, the server runs `checkAndNotify()` function
2. Calls `getEbayAccessToken()` to get a valid access token
3. Calls `searchEbayItems()` to search eBay for items
4. Filters items with price below $650 USD
5. Sends notification to Telegram if cheap items found