Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hn-ts

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hn-ts

TypeScript client for the Hacker News API

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

hn-ts

Build status Coverage jsDocs.io Language npm bundle size npm License

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();

  // Output: a number like `27107832`
  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,
  });

  // Output: `27107832`
  console.log(item.id);

  // Output: `story`
  console.log(item.type);

  // Output: `velut`
  console.log(item.author);
})();

Get the user with the given name:

import { getUserById } from 'hn-ts';

(async () => {
  const user = await getUserById({
    id: "velut",
  });

  // Output: `velut`
  console.log(user.id);
})();

License

MIT License

Copyright (c) 2021 Edoardo Scibona

See LICENSE file.

Keywords

FAQs

Package last updated on 27 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc