Crate hacker_rs

Source
Expand description

Hacker News API bindings for Rust.

let client = HackerNewsClient::new();

// Call various endpoints with your client instance
let first_item = client.get_item(69).await?;
dbg!(&first_item);

// Determine what the item type is
let item_type = first_item.get_item_type();
dbg!(item_type);

// Check if the item is job
assert!(first_item.is_comment());

// Retrieve user information
let user = client.get_user("joeymckenzie").await?;
dbg!(user);

Modules§

client
Hacker News API client bindings and various methods for interacting.
comments
Stories listed on the Hacker News homepage and all associated data.
errors
Various errors and their conversions for Hacker News API interactions.
items
Item response types associated to various Hacker News posts, comments, users, etc.
stories
Stories listed on the Hacker News homepage and all associated data.
users
User response models and various metadata about accounts and related objects.

Constants§

API_BASE_URL
Current URL of the API.
DEFAULT_TIMEOUT_SECONDS
Default timeout for requests the API.
ITEM_ENDPOINT
Item endpoint for stories, polls, news items, etc.
USERS_ENDPOINT
User endpoint for user data and related items.