#hacker-news #type #api #items #parse

hackernews-types

Rust types representing items returned from the Hacker News API

3 releases

0.1.2 May 15, 2021
0.1.1 May 15, 2021
0.1.0 May 15, 2021

#8 in #hacker-news

23 downloads per month
Used in hncat

MIT license

5KB
88 lines

hackernews-types

This package contains simple types for interacting with the Hacker News API. The API documentation is not great and there are some differences. The types contained within this crate can parse every item returned from the hacker news API.

Example:

use anyhow::Result;
use reqwest;
use hackernews_types::Item;

#[tokio::main]
async fn main() -> Result<()>{
    let client = reqwest::Client::new();
    let resp = client.get("https://hacker-news.firebaseio.com/v0/item/8863.json").send().await?;
    let item: Item = resp.json().await?;
    
    println!("Item: {:?}", item);
    
    Ok(())
}

Dependencies

~1.3–2.1MB
~39K SLoC