Coinstats Tool¶
Overview¶
The Coinstats Tool enables Nevron agents to access cryptocurrency market data, news, and portfolio information through the Coinstats API. This integration allows agents to track market trends, monitor specific cryptocurrencies, and gather the latest news in the crypto space.
Features¶
- Market Data: Access real-time and historical price data for cryptocurrencies
- News Aggregation: Retrieve the latest news from various crypto news sources
- Portfolio Tracking: Monitor cryptocurrency portfolios and performance
- Market Trends: Analyze market trends and sentiment
- Coin Information: Get detailed information about specific cryptocurrencies
Configuration¶
To use the Coinstats Tool, you need to configure the following environment variable in your .env
file:
How to Obtain Coinstats API Credentials¶
- Register at Coinstats
- Go to the developer section
- Create a new API key
Methods¶
get_news
¶
Retrieves the latest cryptocurrency news articles.
Arguments:
- limit
(Optional[int]): Maximum number of news articles to retrieve (default: 10)
- skip
(Optional[int]): Number of articles to skip (for pagination) (default: 0)
- categories
(Optional[List[str]]): Specific news categories to filter by
Returns:
- List[Dict[str, Any]]
: List of news articles with title, source, url, and content
Example:
get_coin_data
¶
Retrieves detailed information about a specific cryptocurrency.
Arguments:
- coin_id
(str): The ID of the cryptocurrency (e.g., "bitcoin", "ethereum")
- currency
(Optional[str]): The currency for price data (default: "USD")
Returns:
- Dict[str, Any]
: Detailed information about the cryptocurrency including price, market cap, and volume
Example:
get_market_data
¶
Retrieves market data for multiple cryptocurrencies.
Arguments:
- limit
(Optional[int]): Maximum number of coins to retrieve (default: 20)
- skip
(Optional[int]): Number of coins to skip (for pagination) (default: 0)
- currency
(Optional[str]): The currency for price data (default: "USD")
- sort
(Optional[str]): Sorting criteria (e.g., "market_cap", "volume", "price") (default: "market_cap")
Returns:
- List[Dict[str, Any]]
: List of cryptocurrencies with market data
Example:
get_trending_coins
¶
Retrieves currently trending cryptocurrencies.
Arguments:
- limit
(Optional[int]): Maximum number of trending coins to retrieve (default: 5)
- currency
(Optional[str]): The currency for price data (default: "USD")
Returns:
- List[Dict[str, Any]]
: List of trending cryptocurrencies with market data
Example:
Implementation Details¶
The Coinstats Tool is implemented in src/tools/coinstats_tool.py
and uses the Coinstats API to retrieve cryptocurrency data and news. The tool handles authentication, request formatting, and response parsing to provide clean, usable results.
API Interaction¶
- The tool authenticates with the Coinstats API using the provided API key
- Requests are sent to the appropriate endpoints based on the method called
- Responses are parsed and formatted for easy consumption
- Error handling is implemented for API issues
Best Practices¶
- Rate Limiting: Be mindful of API rate limits in high-frequency applications
- Data Freshness: Consider the timestamp of market data for time-sensitive analyses
- News Filtering: Use categories to filter news for more relevant results
- Error Handling: Implement proper error handling for API connectivity issues
- Data Validation: Validate important data points before making decisions based on them
Example Agent Workflow¶
Here's an example of how an agent might use the Coinstats Tool in a market analysis workflow:
async def crypto_market_analysis_workflow(agent):
# Get trending coins
trending_coins = await agent.tools.coinstats.get_trending_coins(limit=5)
# Get latest news
latest_news = await agent.tools.coinstats.get_news(
limit=10,
categories=["market", "bitcoin", "ethereum"]
)
# Analyze market sentiment based on news
news_texts = [article["content"] for article in latest_news]
sentiment_analysis = await agent.llm.analyze_sentiment(news_texts)
# Get detailed data for top trending coins
detailed_data = []
for coin in trending_coins:
coin_data = await agent.tools.coinstats.get_coin_data(
coin_id=coin["id"],
currency="USD"
)
detailed_data.append(coin_data)
# Generate market report
market_report = await agent.llm.generate_market_report(
trending_coins=trending_coins,
detailed_data=detailed_data,
news=latest_news,
sentiment=sentiment_analysis
)
# Share report via Twitter and Telegram
await agent.tools.twitter.post_tweet(text=f"📊 Daily Crypto Market Report 📊\n\nCheck out our latest analysis!")
await agent.tools.telegram.send_message(text=market_report)
return "Crypto market analysis completed and reports shared"
Limitations¶
- Subject to Coinstats API rate limits
- Data may have slight delays compared to real-time market movements
- Limited historical data availability depending on API tier
- News sources are limited to those aggregated by Coinstats
Troubleshooting¶
Common issues and their solutions:
- Authentication Failed: Verify your API key in the
.env
file - Rate Limit Exceeded: Implement rate limiting in your application
- Coin Not Found: Check that you're using the correct coin ID
- API Timeout: Implement retry logic for temporary API issues
For more help, visit our GitHub Discussions.