get_bitcoin_price
Retrieve current Bitcoin price in USD from the CoinGecko API for real-time cryptocurrency tracking and financial analysis.
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 handler function that executes the tool logic: fetches the current Bitcoin price in USD from CoinGecko API using urllib and json, formats it, and returns the result or an error message if fetch fails.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"