| Crates.io | fastcomments-sdk |
| lib.rs | fastcomments-sdk |
| version | 1.3.0 |
| created_at | 2025-11-04 17:30:15.954277+00 |
| updated_at | 2026-01-14 05:11:21.52345+00 |
| description | Official FastComments Rust SDK (Typed API Client & Utilities) |
| homepage | https://fastcomments.com |
| repository | https://github.com/fastcomments/fastcomments-rust |
| max_upload_size | |
| id | 1916654 |
| size | 1,178,328 |
The official Rust SDK for FastComments, a fast and developer-friendly commenting platform. This SDK provides typed API clients and utilities for integrating FastComments into your Rust applications.
cargo add fastcomments-sdk
The SDK requires Rust 2021 edition or later.
The FastComments Rust SDK consists of several modules:
Client Module - Auto-generated API client for FastComments REST APIs
DefaultApi) and public (PublicApi) endpointsSSO Module - Server-side Single Sign-On utilities
Core Types - Shared type definitions and utilities
use fastcomments_sdk::client::apis::configuration::Configuration;
use fastcomments_sdk::client::apis::public_api;
#[tokio::main]
async fn main() {
// Create API configuration
let config = Configuration::new();
// Fetch comments for a page
let result = public_api::get_comments_public(
&config,
public_api::GetCommentsPublicParams {
tenant_id: "your-tenant-id".to_string(),
urlid: Some("page-url-id".to_string()),
url: None,
count_only: None,
skip: None,
limit: None,
sort_dir: None,
page: None,
sso_hash: None,
simple_sso_hash: None,
has_no_comment: None,
has_comment: None,
comment_id_filter: None,
child_ids: None,
start_date_time: None,
starts_with: None,
},
)
.await;
match result {
Ok(response) => {
println!("Found {} comments", response.comments.len());
for comment in response.comments {
println!("Comment: {:?}", comment);
}
}
Err(e) => eprintln!("Error fetching comments: {:?}", e),
}
}
use fastcomments_sdk::client::apis::configuration::{ApiKey, Configuration};
use fastcomments_sdk::client::apis::default_api;
#[tokio::main]
async fn main() {
// Create configuration with API key
let mut config = Configuration::new();
config.api_key = Some(ApiKey {
prefix: None,
key: "your-api-key".to_string(),
});
// Fetch comments using authenticated API
let result = default_api::get_comments(
&config,
default_api::GetCommentsParams {
tenant_id: "your-tenant-id".to_string(),
skip: None,
limit: None,
sort_dir: None,
urlid: Some("page-url-id".to_string()),
url: None,
is_spam: None,
user_id: None,
all_comments: None,
for_moderation: None,
parent_id: None,
is_flagged: None,
is_flagged_tag: None,
is_by_verified: None,
is_pinned: None,
asc: None,
include_imported: None,
origin: None,
tags: None,
},
)
.await;
match result {
Ok(response) => {
println!("Total comments: {}", response.count);
for comment in response.comments {
println!("Comment ID: {}, Text: {}", comment.id, comment.comment);
}
}
Err(e) => eprintln!("Error: {:?}", e),
}
}
use fastcomments_sdk::sso::{
fastcomments_sso::FastCommentsSSO,
secure_sso_user_data::SecureSSOUserData,
};
fn main() {
let api_key = "your-api-key".to_string();
// Create secure SSO user data (server-side only!)
let user_data = SecureSSOUserData::new(
"user-123".to_string(), // User ID
"user@example.com".to_string(), // Email
"John Doe".to_string(), // Username
"https://example.com/avatar.jpg".to_string(), // Avatar URL
);
// Generate SSO token
let sso = FastCommentsSSO::new_secure(api_key, &user_data).unwrap();
let token = sso.create_token().unwrap();
println!("SSO Token: {}", token);
// Pass this token to your frontend for authentication
}
If you're getting 401 errors when using the authenticated API:
let mut config = Configuration::new();
config.api_key = Some(ApiKey {
prefix: None,
key: "YOUR_API_KEY".to_string(),
});
If SSO tokens aren't working:
FastCommentsSSO::new_secure() with your API key for productionThe SDK uses tokio for async operations. Make sure to:
[dependencies]
tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() {
// Your async code here
}
You'll see you're supposed to pass a broadcastId in some API calls. When you receive events, you'll get this ID back, so you know to ignore the event if you plan to optimistically apply changes on the client
(which you'll probably want to do since it offers the best experience). Pass a UUID here. The ID should be unique enough to not occur twice in a browser session.
For issues, questions, or feature requests:
MIT - See LICENSE file for details.