Price alerts are one of the most requested features by scrap metal dealers and buyers. When copper drops below a target price or HMS 1 steel jumps above a certain level, you want to know immediately rather than discovering it hours later. In this tutorial, we build a simple Node.js service that polls the ScrapMetal API and fires webhooks when prices cross thresholds you define.
How It Works
The service runs on a simple interval timer. Every 30 minutes, it fetches current prices from the ScrapMetal API, compares them against a configuration file of alert rules, and sends webhook POST requests when a rule triggers. The entire service fits in a single file and can run on any Node.js host.
Defining Alert Rules
Store your alert rules in a JSON configuration file. Each rule specifies a metal, grade, a direction (above or below), a threshold price, and a webhook URL. For example, you might want an alert when Bare Bright copper drops below $3.50 per pound, or when Busheling steel rises above $400 per gross ton.
The configuration also supports a cooldown period to prevent repeated alerts. If you set a 24-hour cooldown, the service will only fire one alert per rule per day, even if the price continues to meet the threshold on subsequent checks.
Fetching and Comparing Prices
The price-checking function calls the ScrapMetal API's current prices endpoint and iterates through the response. For each price entry, it checks whether any alert rules match the metal and grade. If a match is found, it compares the current price against the threshold, respecting the direction (above or below) specified in the rule.
Keep track of the last alert time for each rule to enforce the cooldown period. A simple in-memory object works for this, or write it to a JSON file if you want persistence across restarts.
Sending Webhooks
When a rule triggers, send an HTTP POST to the configured webhook URL with a JSON payload containing the metal, grade, current price, threshold, direction, and timestamp. This payload format works directly with Slack incoming webhooks, Discord webhooks, and most automation platforms like Zapier or Make.
For Slack specifically, format the payload as a Slack Block Kit message for a clean, readable notification. Include the grade name, price, and whether it crossed above or below the threshold.
Deployment Options
This service is lightweight enough to run on any platform that supports Node.js. Railway, Render, and Fly.io all offer free or low-cost tiers that can keep a small service running continuously. Alternatively, rewrite the check function as a serverless function on AWS Lambda or Vercel and trigger it with a cron schedule.
The ScrapMetal API free tier supports 100 calls per day. At one check every 30 minutes, you use 48 calls per day, leaving room for additional manual queries or a second monitoring service.