Class RealtimeTools

java.lang.Object
com.tnsai.tools.realtime.RealtimeTools

public class RealtimeTools extends Object
Function-shape realtime data tools — crypto prices, currency exchange, and weather. Replaces the legacy CryptoPriceTool, CurrencyExchangeTool, and OpenWeatherMapTool (each a single dispatched tool).
MethodBackendAuthIdempotent
cryptoPrice(java.lang.String, java.lang.String)CoinGecko v3 /simple/pricenonetrue
fxRates(java.lang.String)Frankfurter (ECB) /latestnonetrue
fxConvert(double, java.lang.String, java.lang.String)Frankfurter /latestnonetrue
weatherCurrent(java.lang.String, java.lang.String)OpenWeatherMap /data/2.5/weatherOPENWEATHER_API_KEYtrue

Crypto + currency are zero-auth public APIs; weather requires a key (60 calls/min on the free tier — sign up at openweathermap.org/api).

Since:
0.5.7 (Phase 2 batch 18 — built-in tool migration to function shape, see #188)
  • Constructor Details

    • RealtimeTools

      public RealtimeTools()
      Default constructor — picks OPENWEATHER_API_KEY from env.
    • RealtimeTools

      public RealtimeTools(String openWeatherApiKey)
      Explicit-key constructor (only OpenWeatherMap needs a key).
    • RealtimeTools

      public RealtimeTools(String openWeatherApiKey, okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper)
      Full constructor for tests / shared HTTP.
  • Method Details

    • cryptoPrice

      @Tool(name="crypto_price", description="Fetch the current price of a cryptocurrency. {coin} accepts either a CoinGecko id (\"bitcoin\", \"ethereum\") or a common ticker alias (\"btc\", \"eth\"). {vsCurrency} is the fiat / crypto to quote in (default \"usd\"). Returns the raw JSON {{ \"<coin>\": { \"<vsCurrency>\": <price> } }}.", keywords={"crypto","bitcoin","ethereum","price","coin","cryptocurrency"}, idempotent=true) public String cryptoPrice(@ToolParam(description="CoinGecko coin id or common ticker (e.g. \"bitcoin\", \"btc\")") String coin, @ToolParam(description="Quote currency (default \"usd\")",required=false,defaultValue="usd") String vsCurrency) throws IOException
      Throws:
      IOException
    • fxRates

      @Tool(name="fx_rates", description="Fetch current exchange rates from a base currency ({base}, default \"USD\") to all other supported currencies. Source: Frankfurter (European Central Bank rates). Returns the raw JSON.", keywords={"currency","exchange","fx","rates","ecb","frankfurter"}, idempotent=true) public String fxRates(@ToolParam(description="Base currency code (default \"USD\")",required=false,defaultValue="USD") String base) throws IOException
      Throws:
      IOException
    • fxConvert

      @Tool(name="fx_convert", description="Convert {amount} from {from} currency to {to} currency using current Frankfurter (ECB) rates. Returns the raw JSON response with the converted amount under \"rates.{to}\".", keywords={"currency","convert","fx","exchange","money"}, idempotent=true) public String fxConvert(@ToolParam(description="Amount to convert") double amount, @ToolParam(description="Source currency code (e.g. \"USD\")") String from, @ToolParam(description="Target currency code (e.g. \"EUR\")") String to) throws IOException
      Throws:
      IOException
    • weatherCurrent

      @Tool(name="weather_current", description="Fetch current weather for a city. {city} accepts \"London\" or \"Istanbul,TR\" (with optional ISO country code). {units} is one of \"metric\" (default), \"imperial\", or \"standard\" (Kelvin). Returns the raw JSON OpenWeatherMap response. Requires OPENWEATHER_API_KEY.", keywords={"weather","temperature","forecast","city","openweathermap"}, idempotent=true) public String weatherCurrent(@ToolParam(description="City name, optionally with country code (\"Istanbul,TR\")") String city, @ToolParam(description="Units: metric / imperial / standard (default metric)",required=false,defaultValue="metric") String units) throws IOException
      Throws:
      IOException