mirror of
https://github.com/navidrome/navidrome.git
synced 2026-02-02 06:24:14 +00:00
- Updated error handling in `nd_host_scheduler.go`, `nd_host_websocket.go`, `nd_host_artwork.go`, `nd_host_cache.go`, and `nd_host_subsonicapi.go` to convert string errors from responses into Go errors. - Removed redundant error checks in test data plugins for cleaner code. - Ensured consistent error handling across all plugins to improve reliability and maintainability.
Crypto Ticker Plugin
This is a WebSocket-based WASM plugin for Navidrome that displays real-time cryptocurrency prices from Coinbase.
Features
- Connects to Coinbase WebSocket API to receive real-time ticker updates
- Configurable to track multiple cryptocurrency pairs
- Implements WebSocket callback handlers for message processing
- Automatically reconnects on connection loss using the scheduler service
- Displays price, best bid, best ask, and 24-hour percentage change
Configuration
In your navidrome.toml file, add:
[PluginConfig.crypto-ticker]
tickers = "BTC,ETH,SOL,MATIC"
tickersis a comma-separated list of cryptocurrency symbols- The plugin will append
-USDto any symbol without a trading pair specified - Default:
BTC,ETHif not configured
How it Works
- On plugin initialization, connects to Coinbase's WebSocket API
- Subscribes to ticker updates for the configured cryptocurrencies
- Incoming ticker data is processed via
nd_websocket_on_text_messagecallback - On connection loss, schedules a reconnection attempt via the scheduler service
- Reconnection is attempted until successful
Building
This plugin was scaffolded using XTP CLI:
xtp plugin init --schema-file ../schemas/websocket_callback.yaml --template go --path ./crypto-ticker --name crypto-ticker
To build the plugin to WASM:
# Using TinyGo (recommended - smaller binary)
tinygo build -o crypto-ticker.wasm -target wasip1 -buildmode=c-shared .
# Or using standard Go
GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o crypto-ticker.wasm .
Installation
Copy the resulting crypto-ticker.wasm to your Navidrome plugins folder.
Example Output
[Crypto] Crypto Ticker Plugin initializing...
[Crypto] Configured tickers: [BTC-USD ETH-USD]
[Crypto] Connected to Coinbase WebSocket API (connection: crypto-ticker-conn)
[Crypto] Subscription message sent to Coinbase WebSocket API
[Crypto] Received subscriptions message
[Crypto] 💰 BTC-USD: $98765.43 (24h: +2.35%) Bid: $98764.00 Ask: $98766.00
[Crypto] 💰 ETH-USD: $3456.78 (24h: -0.54%) Bid: $3455.90 Ask: $3457.80
Permissions Required
- config: Read ticker symbols configuration
- websocket: Connect to
ws-feed.exchange.coinbase.com - scheduler: Schedule reconnection attempts
Files
main.go- Main plugin implementationpdk.gen.go- Generated WebSocket callback types (from XTP)nd_host.go- Host function wrappers for WebSocket and Scheduler services
For more details, see the source code in main.go.