Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.45 KB

File metadata and controls

47 lines (35 loc) · 1.45 KB

HackerNews Stream

Polls the HackerNews Firebase API for new stories. No authentication required.

Quick start

from streams.hackernews import HackerNewsStream

stream = HackerNewsStream(limit=25)
await stream.start()
async for event in stream:
    story = event.payload
    print(f"{story.title} (+{story.score}) by {story.author}")
    print(f"  {story.url or story.permalink}")

API

Base URL: https://hacker-news.firebaseio.com/v0

  • GET /newstories.json — list of up to 500 newest story IDs
  • GET /item/{id}.json — individual item details

HNStory fields

Field Type Description
id str Story ID
title str Story title
author str Username of submitter
url str | None Link URL; None for Ask HN / Show HN text posts
text str | None HTML body for text posts; None for link posts
score int Current points
comments int Number of comments (descendants)
created_at datetime Submission time (UTC)
permalink str https://news.ycombinator.com/item?id={id}

Configuration

No environment variables required. The stream polls every 30 seconds and fetches up to limit new stories per cycle.

# Optional: override config
from streams.config import HackerNewsConfig
stream = HackerNewsStream(limit=10, config=HackerNewsConfig(base_url="..."))