1---2name: hacker-news3description: Search and browse Hacker News with API access to stories, comments, users, and hiring threads.4---56## Quick Reference78| Topic | File |9|-------|------|10| API endpoints | `api.md` |11| Search patterns | `search.md` |1213## Core Rules1415### 1. Two APIs Available16| API | Use Case | Base URL |17|-----|----------|----------|18| Official HN API | Single items, real-time | `https://hacker-news.firebaseio.com/v0` |19| Algolia Search | Full-text search, filters | `https://hn.algolia.com/api/v1` |2021### 2. Official API Endpoints22- `/topstories.json` — top 500 story IDs23- `/newstories.json` — newest 500 story IDs 24- `/beststories.json` — best stories25- `/askstories.json` — Ask HN26- `/showstories.json` — Show HN27- `/jobstories.json` — job postings28- `/item/{id}.json` — story/comment details29- `/user/{username}.json` — user profile3031### 3. Algolia Search Syntax32```33/search?query=TERM&tags=TAG&numericFilters=FILTER34```3536**Tags (combinable with AND):**37- `story`, `comment`, `poll`, `job`, `ask_hn`, `show_hn`38- `author_USERNAME` — posts by user39- `story_ID` — comments on story4041**Numeric filters:**42- `created_at_i>TIMESTAMP` — after date43- `points>N` — minimum points44- `num_comments>N` — minimum comments4546### 4. Common Patterns47| Request | Endpoint |48|---------|----------|49| Frontpage | Official `/topstories.json` → fetch first 30 items |50| Search posts | Algolia `/search?query=X&tags=story` |51| User's posts | Algolia `/search?tags=author_USERNAME` |52| Who is hiring? | Algolia `/search?query=who is hiring&tags=story,author_whoishiring` |53| Comments on story | Algolia `/search?tags=comment,story_ID` |54| This week's top | Algolia `/search?tags=story&numericFilters=created_at_i>WEEK_TS` |5556### 5. Response Handling57- Official API returns IDs → batch fetch items (parallelize)58- Algolia returns full objects with `hits[]` array59- Story object: `id`, `title`, `url`, `score`, `by`, `time`, `descendants` (comment count)60- Comment object: `id`, `text`, `by`, `parent`, `time`6162### 6. Rate Limits63- Official API: No auth required, generous limits64- Algolia: 10,000 requests/hour (no key needed)65- Always paginate large results (`page=N`, `hitsPerPage=N`)6667### 7. Gotchas68- `url` is null for Ask HN/Show HN text posts — use `text` field instead69- `deleted` and `dead` items exist — check before displaying70- Timestamps are Unix seconds, not milliseconds71- Algolia `objectID` = HN item `id` (as string)