Rust client for the Discourse API
npm install discourse-api-rsRust client library for the Discourse API.
- Fetch latest topics
- Get categories
- Get topic details with posts
- Get individual posts
- Filter topics by category
- Async/await support with tokio
- Optional authentication with API keys
``toml`
[dependencies]
discourse-api = "0.20251116"
`rust
use discourse_api::DiscourseClient;
#[tokio::main]
async fn main() -> Result<(), Box
let client = DiscourseClient::new("https://meta.discourse.org");
let topics = client.get_latest().await?;
for topic in topics.topics {
println!("{}", topic.title);
}
Ok(())
}
`
`rust
let client = DiscourseClient::with_api_key(
"https://your-forum.com",
"your-api-key",
"your-username"
);
let topics = client.get_latest().await?;
`
Run the example:
`bash`
cargo run --example fetch_latest
- get_latest() - Get latest topicsget_categories()
- - Get all categoriesget_topic(id)
- - Get topic with postsget_post(id)
- - Get individual postget_category_topics(category_id)` - Get topics in category
-
MIT