get_bitcoin_price
Retrieve the current Bitcoin price in USD using the CoinGecko API, providing real-time cryptocurrency data for informed decision-making.
Instructions
Gets current Bitcoin price in USD from CoinGecko API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/get_bitcoin_price.py:2-10 (handler)The main handler function that fetches the current Bitcoin price from CoinGecko API and returns it formatted as a string. Handles errors by returning an error message.def get_bitcoin_price(): from urllib import request, error import json try: with request.urlopen('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd') as response: data = json.loads(response.read()) return f"Current Bitcoin price: ${data['bitcoin']['usd']:,.2f}" except: return "Error: Unable to fetch Bitcoin price"