Reply in Telegram with the current price and market figures for any ticker symbol someone asks about.

UsesCoinMarketCapTelegram

Look up a crypto price from Telegram

Whenever someone in a Telegram chat your bot is in writes your price keyword followed by a ticker symbol, such as BTC, the bot replies with what CoinMarketCap reports for that coin right now. Any other message is left alone, so it stays quiet in a busy group instead of answering everything.

The reply gives the coin's name, its price in US dollars, the one-hour and 24-hour change, market cap and market cap rank, then two pieces of wider context: the Fear and Greed Index and Bitcoin's share of total market cap. It reports figures and nothing else: no view on what a number means and no suggestion about what to do, and every reply says so. A figure the data does not carry is marked as not reported rather than shown as zero, and a symbol outside the top coins by market cap gets a reply saying it was not found.

You need a Telegram bot in the chat and CoinMarketCap connected. Prices are always in US dollars.

TelegramTelegramWhen a new message is received. Save it as message.When a new message is received. Save it as message.
Set priceKeyword to blank.Set priceKeyword to blank.
Set coinsSearched to 300.Set coinsSearched to 300.
Set chatId to message.chat_id.Set chatId to message.chat_id.
Set messageText to blank.Set messageText to blank.
If a step below fails, save the error as noTextErrorIf a step below fails, save the error as noTextError
Try
Trim message.text and save it as messageText.Trim message.text and save it as messageText.
On error
Show in the output: “This message carried no text, so there was nothing to look up.”.Show in the output: “This message carried no text, so there was nothing to look up.”.
If messageText is emptyIf messageText is empty
Yes
Finish the run: This message carried no text, so no price was looked up.Finish the run: This message carried no text, so no price was looked up.
No
No steps
Split messageText by a space and save it as words.Split messageText by a space and save it as words.
TextMake words[0] lowercase and save it as commandWord.Make words[0] lowercase and save it as commandWord.
If commandWord is not priceKeyword in lowercaseIf commandWord is not priceKeyword in lowercase
Yes
Finish the run: This message was not a price request, so nothing was looked up.Finish the run: This message was not a price request, so nothing was looked up.
No
No steps
Set requestedSymbol to blank.Set requestedSymbol to blank.
If a step below fails, save the error as symbolErrorIf a step below fails, save the error as symbolError
Try
Replace “$” with “” in words[1] in uppercase and save it as requestedSymbol.Replace “$” with “” in words[1] in uppercase and save it as requestedSymbol.
On error
Show in the output: “No ticker symbol followed the keyword.”.Show in the output: “No ticker symbol followed the keyword.”.
If requestedSymbol is empty or the length of requestedSymbol is greater than 12If requestedSymbol is empty or the length of requestedSymbol is greater than 12
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Send a ticker symbol after '@priceKeyword', for example: priceKeyword BTC
Finish the run: No usable ticker symbol was in the message.Finish the run: No usable ticker symbol was in the message.
No
No steps
CoinMarketCapCoinMarketCapGet top CoinMarketCap cryptocurrencies. Save it as listings.Get top CoinMarketCap cryptocurrencies. Save it as listings.
Set rows to listings.listings.data.Set rows to listings.listings.data.
Set matched to false.Set matched to false.
Set coinName to nothing.Set coinName to nothing.
Set coinRank to nothing.Set coinRank to nothing.
Set usdQuote to nothing.Set usdQuote to nothing.
For each row in rows:For each row in rows:
If row.symbol is requestedSymbolIf row.symbol is requestedSymbol
Yes
Change matched to true.Change matched to true.
Change coinName to row.name.Change coinName to row.name.
Change coinRank to row.cmc_rank.Change coinRank to row.cmc_rank.
Change usdQuote to row.quote.USD.Change usdQuote to row.quote.USD.
Stop repeating.Stop repeating.
No
No steps
If matched is noIf matched is no
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not find requestedSymbol in the top coinsSearched as text cryptocurrencies by market cap on CoinMarketCap. Check the ticker symbol and try again.
Finish the run: No coin on CoinMarketCap matched requestedSymbol.Finish the run: No coin on CoinMarketCap matched requestedSymbol.
No
No steps
Set replyLines to an empty list.Set replyLines to an empty list.
Set heading to requestedSymbol.Set heading to requestedSymbol.
If coinName isn't emptyIf coinName isn't empty
Yes
Change heading to “@coinName (requestedSymbol)”.Change heading to “@coinName (requestedSymbol)”.
No
No steps
Add heading to the end of replyLines and save it as replyLines.Add heading to the end of replyLines and save it as replyLines.
Set priceLine to “Price: not reported by CoinMarketCap”.Set priceLine to “Price: not reported by CoinMarketCap”.
Set priceRaw to usdQuote.price.Set priceRaw to usdQuote.price.
If priceRaw isn't emptyIf priceRaw isn't empty
Yes
If a step below fails, save the error as priceErrorIf a step below fails, save the error as priceError
Try
Set priceNumber to priceRaw multiplied by 1.Set priceNumber to priceRaw multiplied by 1.
If priceNumber is less than 1If priceNumber is less than 1
Yes
Change priceLine to “Price: priceNumber formatted as US dollars with 8 decimal places”.Change priceLine to “Price: priceNumber formatted as US dollars with 8 decimal places”.
No
Change priceLine to “Price: priceNumber formatted as US dollars with 2 decimal places”.Change priceLine to “Price: priceNumber formatted as US dollars with 2 decimal places”.
On error
Show in the output: “The price came back in a form that is not a number, so it was left out.”.Show in the output: “The price came back in a form that is not a number, so it was left out.”.
No
No steps
Add priceLine to the end of replyLines and save it as replyLines.Add priceLine to the end of replyLines and save it as replyLines.
Set hourChangeRaw to usdQuote.percent_change_1h.Set hourChangeRaw to usdQuote.percent_change_1h.
If hourChangeRaw isn't emptyIf hourChangeRaw isn't empty
Yes
If a step below fails, save the error as hourChangeRawErrorIf a step below fails, save the error as hourChangeRawError
Try
Add 1h change: hourChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.Add 1h change: hourChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.
On error
Show in the output: “A percentage came back in a form that is not a number, so it was left out.”.Show in the output: “A percentage came back in a form that is not a number, so it was left out.”.
No
No steps
Set dayChangeRaw to usdQuote.percent_change_24h.Set dayChangeRaw to usdQuote.percent_change_24h.
If dayChangeRaw isn't emptyIf dayChangeRaw isn't empty
Yes
If a step below fails, save the error as dayChangeRawErrorIf a step below fails, save the error as dayChangeRawError
Try
Add 24h change: dayChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.Add 24h change: dayChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.
On error
Show in the output: “A percentage came back in a form that is not a number, so it was left out.”.Show in the output: “A percentage came back in a form that is not a number, so it was left out.”.
No
No steps
Set marketCapRaw to usdQuote.market_cap.Set marketCapRaw to usdQuote.market_cap.
If marketCapRaw isn't emptyIf marketCapRaw isn't empty
Yes
If a step below fails, save the error as marketCapRawErrorIf a step below fails, save the error as marketCapRawError
Try
Add Market cap: marketCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.Add Market cap: marketCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.
On error
Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.
No
No steps
Set rankRaw to coinRank.Set rankRaw to coinRank.
If rankRaw isn't emptyIf rankRaw isn't empty
Yes
If a step below fails, save the error as rankRawErrorIf a step below fails, save the error as rankRawError
Try
Add Market cap rank: #rankRaw multiplied by 1 formatted as a plain number with 0 decimal places to the end of replyLines and save it as replyLines.Add Market cap rank: #rankRaw multiplied by 1 formatted as a plain number with 0 decimal places to the end of replyLines and save it as replyLines.
On error
Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.
No
No steps
If a step below fails, save the error as fearGreedErrorIf a step below fails, save the error as fearGreedError
Try
CoinMarketCapCoinMarketCapGet CoinMarketCap Fear and Greed Index. Save it as fearGreed.Get CoinMarketCap Fear and Greed Index. Save it as fearGreed.
Set fearGreedData to fearGreed.fear_and_greed.data.Set fearGreedData to fearGreed.fear_and_greed.data.
Set fearGreedValue to fearGreedData.value.Set fearGreedValue to fearGreedData.value.
Set fearGreedLabel to fearGreedData.value_classification.Set fearGreedLabel to fearGreedData.value_classification.
If fearGreedValue isn't emptyIf fearGreedValue isn't empty
Yes
Set fearGreedLine to “CoinMarketCap Fear and Greed Index: fearGreedValue multiplied by 1 formatted as a plain number with 0 decimal places”.Set fearGreedLine to “CoinMarketCap Fear and Greed Index: fearGreedValue multiplied by 1 formatted as a plain number with 0 decimal places”.
If fearGreedLabel isn't emptyIf fearGreedLabel isn't empty
Yes
Change fearGreedLine to “@fearGreedLine (fearGreedLabel)”.Change fearGreedLine to “@fearGreedLine (fearGreedLabel)”.
No
No steps
Add fearGreedLine to the end of replyLines and save it as replyLines.Add fearGreedLine to the end of replyLines and save it as replyLines.
No
No steps
On error
Show in the output: “The Fear and Greed Index could not be read, so it was left out of the reply.”.Show in the output: “The Fear and Greed Index could not be read, so it was left out of the reply.”.
If a step below fails, save the error as globalErrorIf a step below fails, save the error as globalError
Try
CoinMarketCapCoinMarketCapGet global market data. Save it as globalMetrics.Get global market data. Save it as globalMetrics.
Set globalData to globalMetrics.metrics.data.Set globalData to globalMetrics.metrics.data.
Set dominanceRaw to globalData.btc_dominance.Set dominanceRaw to globalData.btc_dominance.
If dominanceRaw isn't emptyIf dominanceRaw isn't empty
Yes
If a step below fails, save the error as dominanceRawErrorIf a step below fails, save the error as dominanceRawError
Try
Add Bitcoin share of total market cap: dominanceRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.Add Bitcoin share of total market cap: dominanceRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.
On error
Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.
No
No steps
Set totalCapRaw to globalData.quote.USD.total_market_cap.Set totalCapRaw to globalData.quote.USD.total_market_cap.
If totalCapRaw isn't emptyIf totalCapRaw isn't empty
Yes
If a step below fails, save the error as totalCapRawErrorIf a step below fails, save the error as totalCapRawError
Try
Add Total crypto market cap: totalCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.Add Total crypto market cap: totalCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.
On error
Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.Show in the output: “A market figure came back in a form that is not a number, so it was left out.”.
No
No steps
On error
Show in the output: “Global market figures could not be read, so they were left out of the reply.”.Show in the output: “Global market figures could not be read, so they were left out of the reply.”.
Add “Observed market data from CoinMarketCap. Not financial advice.” to the end of replyLines and save it as replyLines.Add “Observed market data from CoinMarketCap. Not financial advice.” to the end of replyLines and save it as replyLines.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.replyLines joined by a new line