Crates.io | price-adapter |
lib.rs | price-adapter |
version | 0.1.8 |
source | src |
created_at | 2023-11-23 10:04:40.095682 |
updated_at | 2024-01-17 17:33:15.592023 |
description | price-adapter |
homepage | |
repository | |
max_upload_size | |
id | 1045952 |
size | 84,060 |
price-adapter
is a Rust library that provides different services for fetching price information for various cryptocurrencies and assets. It includes sources for popular data providers such as CoinGecko and Binance, and offers both HTTP-based and WebSocket-based interfaces for retrieving prices.
price-adapter
supports multiple sources for obtaining cryptocurrency prices, including:
To use price-adapter
, add the following to your Cargo.toml file:
[dependencies]
price-adapter = "0.1.0"
price-adapter
offers two types of services:
IntervalService: This service fetches prices from a specified source at regular intervals and caches them. This is a convenient option if you need to access prices frequently and don't want to make API calls every time.
WebsocketService: This service establishes a WebSocket connection to a source and subscribes to specific symbols. It then streams price updates over the WebSocket connection, allowing you to receive real-time price changes.
Both services implement the Service
trait, which defines the common interface for starting, stopping, and checking the status of the service.
The examples
directory contains several example scripts demonstrating how to use price-adapter
. These examples cover scenarios such as using the HTTP and WebSocket interfaces, creating a custom mapper, and employing the interval and Websocket services.