DEV Community

Jordan Tryon
Jordan Tryon

Posted on

Right Now, Precious Metals are Hot, Lets Create a Bot

So I have always been curious of metal prices and how they fluctuate with the market.

A couple weeks ago I came across a cool API that can provide metal prices called Metals-Api. This service has a free plan for up to 50 calls per month, which was perfect for my personal use case of sending myself the prices every morning (looks like it could be a great tool for a paid platform as well). I also use telegram and recently also discovered they have a bot API That you can setup to send yourself messages in a Channel.

So I put the two together and combined it with a small node.js program and a cron job on a Digital Ocean Droplet that runs every morning. Low and Behold, metal prices daily!

See my github repo for more information!

GitHub logo tryonlinux / telegram-metal-bot

Bot to send metal prices daily to myself

telegram-metal-bot

Extremely Simple Telegram Bot to send metal prices daily to myself using NodeJS and Telegram/Metal-API web services.

Requirements

Getting Started

To run simply clone and download code.

Then run the below line to install required packages.

npm i

Place the keys you get and your channel id in a keys.json file like so:

{
"botID": "bot*Bot API Key Here*"
"chatID": "-100*Channel ID Here*,
"metalAPIKey": "*metal API Key Here*"
}

Usage

node index.js

FAQ

How do I get my channel ID for Telegram?

Check out this answer on stackoverflow

How do I set this up to send me prices automatically every morning?

I personally just use a cron job on my personal digital ocean droplet and schedule it to run everyday at 7am.

0 7 * * * node /path/to/file/index.js

Authors

Top comments (2)

Collapse
 
tomford profile image
tomford51 • Edited

Hello Jordan! My company is just engaged in metal smelting. I think your information will help me, as we are looking for new ways to increase our scale and sales. We produce high-quality metal and alloy, checking it by all means and even spectrometers. Who doesn't know you can watch elvatech.com/applications/pmi/. The device analyzes the quality of the alloy and shows the number of chemical elements in the product.

Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more