← Back to Blog
Tutorial

Track Copper Scrap Prices in Python: A Step-by-Step Tutorial

Copper is the most valuable common scrap metal, and its price fluctuates daily based on COMEX futures, global demand, and supply chain dynamics. If you're a scrap dealer, a purchasing manager at a foundry, or a developer building tools for either, tracking copper scrap prices programmatically can save you hours of manual research.

In this tutorial, we'll build a simple Python script that pulls copper scrap prices from the ScrapMetal API, stores them locally, and sends a notification when prices move beyond a threshold you set.

Setting Up the Project

Start by creating a virtual environment and installing the dependencies you need. You only need two packages beyond the standard library: requests for HTTP calls and schedule for running the fetch on a timer.

Fetching Current Copper Prices

The ScrapMetal API endpoint for current prices accepts a metal filter parameter. When you query for copper, you get back all tracked copper grades: Bare Bright (BARLEY), #1 Tubing (CANDY), #2 Copper (BIRCH), and Insulated Wire (DRUID). Each response object includes the grade name, ISRI code, price per pound, source, and a UTC timestamp.

A simple GET request with your API key in the X-API-Key header returns this data as JSON. Parse the response and you have structured pricing data ready for storage or analysis.

Storing Prices in SQLite

SQLite is perfect for local price tracking because it requires zero configuration. Create a table with columns for the date, grade, ISRI code, price, and source. Before inserting a new record, check whether you already have a price for that grade and date to avoid duplicates.

Over time, this local database becomes a valuable historical record. You can query it to calculate moving averages, identify seasonal patterns, or compare your realized prices against market benchmarks.

Setting Price Alerts

The alerting logic is straightforward. After each fetch, compare the new price against your threshold. If Bare Bright copper drops below $3.50 per pound or rises above $4.20, trigger a notification. You can send alerts via email using Python's built-in smtplib, post to a Slack webhook, or simply log to the console.

Running on a Schedule

Use the schedule library to run the fetch function once per day at a time you choose. For scrap metal, prices typically update during business hours Eastern Time. Running your fetch around 2 PM ET captures the day's pricing.

Taking It Further

Once you have daily price collection working, you can extend the script in several directions. Build a simple Flask dashboard to visualize your price history. Add multiple metals to track copper, aluminum, and brass simultaneously. Or integrate the price data into your yard management or ERP system to automate purchase ticket pricing.

The ScrapMetal API's free tier gives you 100 calls per day, which is more than enough for daily price checks across all grades. If you need historical backfill or higher volume, the Basic plan at $29/month covers most use cases.