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 a CoinMarketCap connection. 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.
ValuesSet priceKeyword to blank.Set priceKeyword to blank.
ValuesSet coinsSearched to 300.Set coinsSearched to 300.
ValuesSet chatId to message.chat_id.Set chatId to message.chat_id.
ValuesSet messageText to blank.Set messageText to blank.
Decisions & LoopsIf a step below fails, save the error as noTextErrorIf a step below fails, save the error as noTextError
Try
TextTrim message.text and save it as messageText.Trim message.text and save it as messageText.
On error
ValuesShow 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..
Decisions & LoopsIf messageText is emptyIf messageText is empty
Yes
Decisions & LoopsFinish 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
TextSplit 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.
Decisions & LoopsIf commandWord is not priceKeyword in lowercaseIf commandWord is not priceKeyword in lowercase
Yes
Decisions & LoopsFinish 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
ValuesSet requestedSymbol to blank.Set requestedSymbol to blank.
Decisions & LoopsIf a step below fails, save the error as symbolErrorIf a step below fails, save the error as symbolError
Try
TextReplace $ 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
ValuesShow in the output: No ticker symbol followed the keyword..Show in the output: No ticker symbol followed the keyword..
Decisions & LoopsIf 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
Decisions & LoopsFinish 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.
ValuesSet rows to listings.listings.data.Set rows to listings.listings.data.
ValuesSet matched to false.Set matched to false.
ValuesSet coinName to nothing.Set coinName to nothing.
ValuesSet coinRank to nothing.Set coinRank to nothing.
ValuesSet usdQuote to nothing.Set usdQuote to nothing.
Decisions & LoopsFor each row in rows:For each row in rows:
Decisions & LoopsIf row.symbol is requestedSymbolIf row.symbol is requestedSymbol
Yes
ValuesChange matched to true.Change matched to true.
ValuesChange coinName to row.name.Change coinName to row.name.
ValuesChange coinRank to row.cmc_rank.Change coinRank to row.cmc_rank.
ValuesChange usdQuote to row.quote.USD.Change usdQuote to row.quote.USD.
Decisions & LoopsStop repeating.Stop repeating.
No
No steps
Decisions & LoopsIf 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.
Decisions & LoopsFinish the run: No coin on CoinMarketCap matched requestedSymbol.Finish the run: No coin on CoinMarketCap matched requestedSymbol.
No
No steps
ValuesSet replyLines to an empty list.Set replyLines to an empty list.
ValuesSet heading to requestedSymbol.Set heading to requestedSymbol.
Decisions & LoopsIf coinName isn't emptyIf coinName isn't empty
Yes
ValuesChange heading to coinName (requestedSymbol).Change heading to coinName (requestedSymbol).
No
No steps
ListsAdd heading to the end of replyLines and save it as replyLines.Add heading to the end of replyLines and save it as replyLines.
ValuesSet priceLine to Price: not reported by CoinMarketCap.Set priceLine to Price: not reported by CoinMarketCap.
ValuesSet priceRaw to usdQuote.price.Set priceRaw to usdQuote.price.
Decisions & LoopsIf priceRaw isn't emptyIf priceRaw isn't empty
Yes
Decisions & LoopsIf a step below fails, save the error as priceErrorIf a step below fails, save the error as priceError
Try
MathSet priceNumber to priceRaw multiplied by 1.Set priceNumber to priceRaw multiplied by 1.
Decisions & LoopsIf priceNumber is less than 1If priceNumber is less than 1
Yes
ValuesChange 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
ValuesChange 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
ValuesShow 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
ListsAdd priceLine to the end of replyLines and save it as replyLines.Add priceLine to the end of replyLines and save it as replyLines.
ValuesSet hourChangeRaw to usdQuote.percent_change_1h.Set hourChangeRaw to usdQuote.percent_change_1h.
Decisions & LoopsIf hourChangeRaw isn't emptyIf hourChangeRaw isn't empty
Yes
Decisions & LoopsIf a step below fails, save the error as hourChangeRawErrorIf a step below fails, save the error as hourChangeRawError
Try
ListsAdd 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
ValuesShow 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
ValuesSet dayChangeRaw to usdQuote.percent_change_24h.Set dayChangeRaw to usdQuote.percent_change_24h.
Decisions & LoopsIf dayChangeRaw isn't emptyIf dayChangeRaw isn't empty
Yes
Decisions & LoopsIf a step below fails, save the error as dayChangeRawErrorIf a step below fails, save the error as dayChangeRawError
Try
ListsAdd 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
ValuesShow 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
ValuesSet marketCapRaw to usdQuote.market_cap.Set marketCapRaw to usdQuote.market_cap.
Decisions & LoopsIf marketCapRaw isn't emptyIf marketCapRaw isn't empty
Yes
Decisions & LoopsIf a step below fails, save the error as marketCapRawErrorIf a step below fails, save the error as marketCapRawError
Try
ListsAdd 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
ValuesShow 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
ValuesSet rankRaw to coinRank.Set rankRaw to coinRank.
Decisions & LoopsIf rankRaw isn't emptyIf rankRaw isn't empty
Yes
Decisions & LoopsIf a step below fails, save the error as rankRawErrorIf a step below fails, save the error as rankRawError
Try
ListsAdd 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
ValuesShow 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
Decisions & LoopsIf 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.
ValuesSet fearGreedData to fearGreed.fear_and_greed.data.Set fearGreedData to fearGreed.fear_and_greed.data.
ValuesSet fearGreedValue to fearGreedData.value.Set fearGreedValue to fearGreedData.value.
ValuesSet fearGreedLabel to fearGreedData.value_classification.Set fearGreedLabel to fearGreedData.value_classification.
Decisions & LoopsIf fearGreedValue isn't emptyIf fearGreedValue isn't empty
Yes
ValuesSet 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.
Decisions & LoopsIf fearGreedLabel isn't emptyIf fearGreedLabel isn't empty
Yes
ValuesChange fearGreedLine to fearGreedLine (fearGreedLabel).Change fearGreedLine to fearGreedLine (fearGreedLabel).
No
No steps
ListsAdd 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
ValuesShow 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..
Decisions & LoopsIf 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.
ValuesSet globalData to globalMetrics.metrics.data.Set globalData to globalMetrics.metrics.data.
ValuesSet dominanceRaw to globalData.btc_dominance.Set dominanceRaw to globalData.btc_dominance.
Decisions & LoopsIf dominanceRaw isn't emptyIf dominanceRaw isn't empty
Yes
Decisions & LoopsIf a step below fails, save the error as dominanceRawErrorIf a step below fails, save the error as dominanceRawError
Try
ListsAdd 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
ValuesShow 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
ValuesSet totalCapRaw to globalData.quote.USD.total_market_cap.Set totalCapRaw to globalData.quote.USD.total_market_cap.
Decisions & LoopsIf totalCapRaw isn't emptyIf totalCapRaw isn't empty
Yes
Decisions & LoopsIf a step below fails, save the error as totalCapRawErrorIf a step below fails, save the error as totalCapRawError
Try
ListsAdd 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
ValuesShow 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
ValuesShow 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..
ListsAdd 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