1---
2name: hacker-news
3slug: hacker-news
4version: 1.0.0
5description: Search and browse Hacker News with API access to stories, comments, users, and hiring threads.
6metadata:
7 source: https://skillmd.com/skills/modbender/hacker-news
8 clawdbot:
9 emoji: 🟠
10 requires:
11 bins: []
12 os:
13 - linux
14 - darwin
15 - win32
16---
17
18## Quick Reference
19
20| Topic | File |
21|-------|------|
22| API endpoints | `api.md` |
23| Search patterns | `search.md` |
24
25## Core Rules
26
27### 1. Two APIs Available
28| API | Use Case | Base URL |
29|-----|----------|----------|
30| Official HN API | Single items, real-time | `https://hacker-news.firebaseio.com/v0` |
31| Algolia Search | Full-text search, filters | `https://hn.algolia.com/api/v1` |
32
33### 2. Official API Endpoints
34- `/topstories.json` — top 500 story IDs
35- `/newstories.json` — newest 500 story IDs
36- `/beststories.json` — best stories
37- `/askstories.json` — Ask HN
38- `/showstories.json` — Show HN
39- `/jobstories.json` — job postings
40- `/item/{id}.json` — story/comment details
41- `/user/{username}.json` — user profile
42
43### 3. Algolia Search Syntax
44```
45/search?query=TERM&tags=TAG&numericFilters=FILTER
46```
47
48**Tags (combinable with AND):**
49- `story`, `comment`, `poll`, `job`, `ask_hn`, `show_hn`
50- `author_USERNAME` — posts by user
51- `story_ID` — comments on story
52
53**Numeric filters:**
54- `created_at_i>TIMESTAMP` — after date
55- `points>N` — minimum points
56- `num_comments>N` — minimum comments
57
58### 4. Common Patterns
59| Request | Endpoint |
60|---------|----------|
61| Frontpage | Official `/topstories.json` → fetch first 30 items |
62| Search posts | Algolia `/search?query=X&tags=story` |
63| User's posts | Algolia `/search?tags=author_USERNAME` |
64| Who is hiring? | Algolia `/search?query=who is hiring&tags=story,author_whoishiring` |
65| Comments on story | Algolia `/search?tags=comment,story_ID` |
66| This week's top | Algolia `/search?tags=story&numericFilters=created_at_i>WEEK_TS` |
67
68### 5. Response Handling
69- Official API returns IDs → batch fetch items (parallelize)
70- Algolia returns full objects with `hits[]` array
71- Story object: `id`, `title`, `url`, `score`, `by`, `time`, `descendants` (comment count)
72- Comment object: `id`, `text`, `by`, `parent`, `time`
73
74### 6. Rate Limits
75- Official API: No auth required, generous limits
76- Algolia: 10,000 requests/hour (no key needed)
77- Always paginate large results (`page=N`, `hitsPerPage=N`)
78
79### 7. Gotchas
80- `url` is null for Ask HN/Show HN text posts — use `text` field instead
81- `deleted` and `dead` items exist — check before displaying
82- Timestamps are Unix seconds, not milliseconds
83- Algolia `objectID` = HN item `id` (as string)