reddit-insights

Crates.ioreddit-insights
lib.rsreddit-insights
version1.0.0
created_at2025-12-24 07:01:56.645529+00
updated_at2025-12-24 07:01:56.645529+00
descriptionOfficial Rust SDK for the Reddit Insights API
homepagehttps://reddit-insights.com/developers
repositoryhttps://github.com/lignertys/reddit-insights-rust
max_upload_size
id2002815
size55,207
(lignertys)

documentation

https://docs.rs/reddit-insights

README

Reddit Insights Rust SDK

Official Rust SDK for the Reddit Insights API. Analyze Reddit conversations with AI-powered semantic search.

Installation

Add this to your Cargo.toml:

[dependencies]
reddit-insights = "1.0"
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }

Quick Start

use reddit_insights::RedditInsightsClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize the client
    let client = RedditInsightsClient::new("YOUR_API_KEY")?;

    // Semantic search
    let results = client.semantic_search(
        "What do young people complain about banking apps?",
        Some(20),
    ).await?;
    
    if let Some(data) = results.data {
        println!("Found {} results", data.total);
        for result in data.results {
            println!("- {}", result.title);
        }
    }

    // Vector search with date filters
    let vector_results = client.vector_search(
        "electric vehicle charging",
        Some(30),
        Some("2025-01-01"),
        Some("2025-01-31"),
    ).await?;

    // Get trending topics
    let trends = client.get_trends(
        Some("2025-01-01"),
        Some("2025-01-31"),
        Some(20),
    ).await?;

    Ok(())
}

Sonar Management (FREE Endpoints)

Sonars allow you to monitor Reddit conversations and receive alerts.

use reddit_insights::{RedditInsightsClient, CreateSonarOptions};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = RedditInsightsClient::new("YOUR_API_KEY")?;

    // List all sonars
    let sonars = client.list_sonars().await?;

    // Create a new sonar
    let options = CreateSonarOptions {
        name: "Product Feedback Monitor".to_string(),
        query: "What do users think about our product?".to_string(),
        description: Some("Track product feedback".to_string()),
        schedule: Some("daily".to_string()),
        triggers: Some(serde_json::json!({
            "keywords": ["bug", "issue", "problem"],
            "sentiment": "negative",
            "minNewPosts": 5
        })),
        notify_email: Some(true),
        notify_slack: None,
        slack_webhook: None,
    };
    
    let sonar = client.create_sonar(&options).await?;

    Ok(())
}

Custom Base URL

let client = RedditInsightsClient::with_base_url(
    "YOUR_API_KEY",
    "https://custom-api.example.com",
)?;

Error Handling

use reddit_insights::{RedditInsightsClient, Error};

#[tokio::main]
async fn main() {
    let client = RedditInsightsClient::new("YOUR_API_KEY").unwrap();

    match client.semantic_search("test query", Some(20)).await {
        Ok(results) => println!("Success!"),
        Err(Error::Authentication(msg)) => println!("Invalid API key: {}", msg),
        Err(Error::RateLimit(msg)) => println!("Rate limit exceeded: {}", msg),
        Err(Error::Validation(msg)) => println!("Invalid request: {}", msg),
        Err(Error::Api { status_code, message }) => {
            println!("API error (status {}): {}", status_code, message)
        }
        Err(e) => println!("Error: {}", e),
    }
}

Rate Limits

Tier Limit
Free 100 requests/hour
Pro 10,000 requests/month
Enterprise Unlimited

License

MIT License

Support

For support, please visit https://reddit-insights.com or contact support@reddit-insights.com.

Commit count: 0

cargo fmt