[][src]Crate hn_api

A simple synchronous Hacker News API (v0) client library based on reqwest and serde.

The library currently implements no caching. It simply exposes endpoints as methods.

Furthermore, there is no realtime functionality. If you need that, you should probably use a firebase client crate and subscribe to the live endpoints directly.

API Docs: https://github.com/HackerNews/API

Usage

use hn_api::HnClient;

// Initialize HTTP client
let api = HnClient::init()
    .expect("Could not initialize HN client");

// Fetch latest item
let latest_item_id = api.get_max_item_id()
    .expect("Could not fetch latest item id");
let item = api.get_item(latest_item_id)
    .expect("Could not fetch item");

println!("Latest item: {:?}", item);

For an example, see examples/top.rs.

Modules

types

Item types returned by the API.

Structs

HnClient

The API client.