Vyper API Rust SDK

A Rust SDK for interacting with the Vyper API. This library allows developers to integrate Vyper's HTTP and WebSocket API into their Rust applications with ease.
Table of Contents
Installation
To install the Vyper API Rust SDK, add the following to your Cargo.toml:
[dependencies]
vyper-client_rs = "0.1.0" tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Quick Start
Here's a simple example to get you started:
use vyper_client_rs::client::VyperClient;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = VyperClient::new("your_api_key_here");
let chain_ids = client.get_chain_ids().await?;
println!("Supported chain IDs: {:?}", chain_ids);
Ok(())
}
Usage
REST API Example
Retrieve the market data for a specific token:
use vyper_client_rs::client::VyperClient;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = VyperClient::new("your_api_key_here");
let token_ath = client
.get_token_ath(1, "AVs9TA4nWDzfPJE9gGVNJMVhcQy3V9PGazuz33BfG2RA")
.await?;
println!("Market Cap USD: {}", token_ath.market_cap_usd);
println!("Timestamp: {}", token_ath.timestamp);
Ok(())
}
WebSocket API Example
use vyper_client_rs::websocket::{VyperWebsocketClient, FeedType, SubscriptionType, TokenSubscriptionMessage, SubscriptionMessageType};
use serde_json::Value;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let ws_client = VyperWebsocketClient::new("your_api_key_here".to_string());
let handler = move |message: Value| {
println!("Received message: {:?}", message);
};
ws_client.set_message_handler(handler);
ws_client.connect(FeedType::TokenEvents).await?;
ws_client
.subscribe(
FeedType::TokenEvents,
TokenSubscriptionMessage {
action: SubscriptionMessageType::Subscribe,
types: vec![SubscriptionType::PumpfunTokens],
},
)
.await?;
println!("Subscribed to token events");
ws_client.listen().await?;
Ok(())
}
API Documentation
For detailed information on the Vyper API, refer to the official documentation: