Services Reference¶
Reference for built-in services.
Built-in Services¶
All services inherit from BaseService (see Core Reference for details).
Hello Service¶
Simple demonstration service that returns a greeting message.
services.hello_service.HelloService
¶
Bases: BaseService
Service that returns a simple hello world message.
This service demonstrates the simplest possible BaseService implementation. It doesn't require external API calls and returns a static response with optional customization via parameters.
The service accepts an optional 'name' parameter in the parameters dictionary. If not provided, defaults to "World".
Examples:
Example usage in endpoint configuration:
Using the service directly:
service = HelloService()
result = await service.call({"name": "Alice"})
print(result["message"]) # "Hello, Alice!"
await service.cleanup()
Source code in core/services/base.py
call
async
¶
Return a hello world message.
Parameters:
-
parameters(dict[str, Any] | None, default:None) –Optional service parameters dictionary containing:
- name (str, optional): Name to greet. Defaults to "World".
Returns:
-
dict[str, Any]–Dictionary containing a greeting message with the following structure:
-
dict[str, Any]–```python
-
dict[str, Any]–{ "message": str, # e.g., "Hello, World!" "name": str, # The name parameter value "service": str # Service identifier
-
dict[str, Any]–}
-
dict[str, Any]–```
Examples:
service = HelloService()
result = await service.call({"name": "Alice"})
print(result["message"]) # "Hello, Alice!"
await service.cleanup()
Source code in services/hello_service.py
Crypto Service¶
Get cryptocurrency price data.
services.crypto_service.CryptoService
¶
Bases: BaseService
Service for cryptocurrency price data using CoinLore API.
This service provides access to real-time cryptocurrency market data through the CoinLore API. It implements the BaseService interface, making it compatible with the dynamic endpoint routing system.
The service accepts an optional 'symbol' parameter in the parameters dictionary. If not provided, defaults to "BTC" (Bitcoin).
Examples:
Example usage in endpoint configuration:
Using the service directly:
service = CryptoService()
result = await service.call({"symbol": "ETH"})
print(result["price_usd"]) # e.g., 2932.25
await service.cleanup()
Source code in core/services/base.py
call
async
¶
Get cryptocurrency price data by symbol.
Retrieves comprehensive market data for the specified cryptocurrency symbol from the CoinLore API.
Parameters:
-
parameters(dict[str, Any] | None, default:None) –Optional service parameters dictionary containing:
- symbol (str, optional): Cryptocurrency symbol to query (e.g., "BTC", "ETH", "SOL", "DOGE"). Case-insensitive. Defaults to "BTC" if not provided.
Returns:
-
dict[str, Any]–Dictionary containing cryptocurrency market data with the following structure:
-
dict[str, Any]–```python
-
dict[str, Any]–{ "symbol": str, # e.g., "BTC" "name": str, # e.g., "Bitcoin" "rank": int, # Market cap rank "price_usd": float, # Price in USD "percent_change_24h": float, # 24h change % "percent_change_1h": float, # 1h change % "percent_change_7d": float, # 7d change % "market_cap_usd": float, # Market cap in USD "volume24": float, # 24h volume "price_btc": float, # Price in BTC "csupply": str, # Circulating supply "tsupply": str, # Total supply "msupply": str # Max supply (may be None)
-
dict[str, Any]–}
-
dict[str, Any]–```
Raises:
-
ValidationError–If the API request fails or the symbol is not found.
Examples:
service = CryptoService()
result = await service.call({"symbol": "ETH"})
print(result["price_usd"]) # e.g., 2932.25
await service.cleanup()
Source code in services/crypto_service.py
Creating Custom Services¶
See the Creating Services Guide for detailed information on creating your own services.
Quick example:
from core.services.base import BaseService
class MyService(BaseService):
"""My custom service."""
async def call(self, parameters: dict | None = None) -> dict:
"""Process the service request.
Args:
parameters: Optional parameters for the service
Returns:
Service response data
"""
return {"result": "data"}