hn-ts
A TypeScript client for the Hacker News API.
Features
- Fully typed API and response data
- Well documented and tested
API & Package Info
Install
Using npm
:
npm i hn-ts
Using yarn
:
yarn add hn-ts
Usage Examples
Get the ID of the latest item created on HN:
import { getMaxItemId } from 'hn-ts';
(async () => {
const id = await getMaxItemId();
console.log(id);
})();
Get the item (story, comment, job, poll or poll option) with the given ID:
import { getItemById } from 'hn-ts';
(async () => {
const item = await getItemById({
id: 27107832,
});
console.log(item.id);
console.log(item.type);
console.log(item.author);
})();
Get the user with the given name:
import { getUserById } from 'hn-ts';
(async () => {
const user = await getUserById({
id: "velut",
});
console.log(user.id);
})();
License
MIT License
Copyright (c) 2021 Edoardo Scibona
See LICENSE file.