get_social_volume
Track cryptocurrency social media mentions by retrieving total social volume for a specified asset over a customizable period. Analyze the number of mentions in documents like Reddit posts and Telegram messages to gauge sentiment.
Instructions
Retrieve the total social volume (social_volume_total) for a given asset. It calculates the total number of social data text documents that contain the given search term at least once. Examples of documents are telegram messages and reddit posts.
Parameters:
asset (str): The cryptocurrency slug (e.g., "bitcoin", "ethereum"). Required.
days (int): Number of days to sum the social volume, defaults to 7.
Usage:
Call this tool to get the total number of social media mentions for an asset over a period.
Returns:
A string with the total social volume (e.g., "Bitcoin's social volume over the past 7 days is 15,000 mentions").
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asset | Yes | ||
| days | No |
Implementation Reference
- main.py:91-114 (handler)The handler function for the 'get_social_volume' tool. It fetches social volume data from Santiment API using the helper fetch_santiment_data, sums the daily volumes over the specified days, and returns a formatted string with the total mentions. Includes type hints and detailed docstring serving as input/output schema.@mcp.tool() def get_social_volume(asset: str, days: int = 7) -> str: """ Retrieve the total social volume (social_volume_total) for a given asset. It calculates the total number of social data text documents that contain the given search term at least once. Examples of documents are telegram messages and reddit posts. Parameters: - asset (str): The cryptocurrency slug (e.g., "bitcoin", "ethereum"). Required. - days (int): Number of days to sum the social volume, defaults to 7. Usage: - Call this tool to get the total number of social media mentions for an asset over a period. Returns: - A string with the total social volume (e.g., "Bitcoin's social volume over the past 7 days is 15,000 mentions"). """ try: data = fetch_santiment_data("social_volume_total", asset, days) timeseries = data.get("data", {}).get("getMetric", {}).get("timeseriesData", []) if not timeseries: return f"Unable to fetch social volume for {asset}. Check subscription limits or asset availability." total_volume = sum(int(d["value"]) for d in timeseries) return f"{asset.capitalize()}'s social volume over the past {days} days is {total_volume:,} mentions." except Exception as e: return f"Error fetching social volume for {asset}: {str(e)}"
- main.py:16-42 (helper)Supporting helper function used by get_social_volume to query Santiment GraphQL API for timeseries data of the specified metric (social_volume_total) over the given days.def fetch_santiment_data(metric: str, asset: str, days: int) -> dict: now = datetime.now(UTC) to_date = now from_date = to_date - timedelta(days=days) query = f""" {{ getMetric(metric: "{metric}") {{ timeseriesData( slug: "{asset}" from: "{from_date.isoformat()}" to: "{to_date.isoformat()}" interval: "1d" ) {{ datetime value }} }} }} """ response = requests.post(SANTIMENT_API_URL, json={"query": query}, headers=HEADERS) result = response.json() if result.get("errors"): raise Exception(f"API error: {result.get('errors')}") return result
- main.py:91-91 (registration)The @mcp.tool() decorator registers the get_social_volume function as an MCP tool.@mcp.tool()