Hacker News API
hacker-news.firebaseio.com · Media
Official Y Combinator Hacker News API — top stories, new stories, best stories, jobs, Ask HN, Show HN, comments, and user profiles. Real-time via Firebase. No API key required.
Authentication
No authentication requiredFree to use with no key needed.
Sample Requests
GET
Get top story IDs
Get IDs of the current top 500 HN stories.
https://hacker-news.firebaseio.com/v0/topstories.json
Hover any highlighted part to learn what it does
curl -X GET "https://hacker-news.firebaseio.com/v0/topstories.json"
import requests
response = requests.get(
"https://hacker-news.firebaseio.com/v0/topstories.json",
)
print(response.json())const url = 'https://hacker-news.firebaseio.com/v0/topstories.json'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://hacker-news.firebaseio.com/v0/topstories.json"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://hacker-news.firebaseio.com/v0/topstories.json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://hacker-news.firebaseio.com/v0/topstories.json";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Get a story
Get a specific story, comment, or job by ID.
https://hacker-news.firebaseio.com/v0/item/8863.json
Hover any highlighted part to learn what it does
curl -X GET "https://hacker-news.firebaseio.com/v0/item/8863.json"
import requests
response = requests.get(
"https://hacker-news.firebaseio.com/v0/item/8863.json",
)
print(response.json())const url = 'https://hacker-news.firebaseio.com/v0/item/8863.json'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://hacker-news.firebaseio.com/v0/item/8863.json"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://hacker-news.firebaseio.com/v0/item/8863.json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://hacker-news.firebaseio.com/v0/item/8863.json";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- No API key needed
- Step 1: GET /topstories.json to get list of IDs
- Step 2: GET /item/{id}.json for each story
- Also: /newstories.json, /beststories.json, /showstories.json, /jobstories.json