New York Times API
api.nytimes.com · Media
Article search, top stories, most popular, books bestsellers, movie reviews, and more from The New York Times. Free API key required.
Authentication
Sample Requests
Search NYT articles by keyword.
Hover any highlighted part to learn what it does
curl -X GET "https://api.nytimes.com/svc/search/v2/articlesearch.json?q=technology&sort=newest&api-key=YOUR_KEY"
import requests
params = {
"q": "technology",
"sort": "newest",
"api-key": "YOUR_KEY"
}
response = requests.get(
"https://api.nytimes.com/svc/search/v2/articlesearch.json",
params=params,
)
print(response.json())const url = new URL('https://api.nytimes.com/svc/search/v2/articlesearch.json');
url.searchParams.set('q', 'technology');
url.searchParams.set('sort', 'newest');
url.searchParams.set('api-key', 'YOUR_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.nytimes.com/svc/search/v2/articlesearch.json")
q := baseURL.Query()
q.Set("q", "technology")
q.Set("sort", "newest")
q.Set("api-key", "YOUR_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
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://api.nytimes.com/svc/search/v2/articlesearch.json")
uri.query = URI.encode_www_form({
"q" => "technology",
"sort" => "newest",
"api-key" => "YOUR_KEY"
})
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://api.nytimes.com/svc/search/v2/articlesearch.json?" . http_build_query([
"q" => "technology",
"sort" => "newest",
"api-key" => "YOUR_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get top technology stories.
Hover any highlighted part to learn what it does
curl -X GET "https://api.nytimes.com/svc/topstories/v2/technology.json?api-key=YOUR_KEY"
import requests
params = {
"api-key": "YOUR_KEY"
}
response = requests.get(
"https://api.nytimes.com/svc/topstories/v2/technology.json",
params=params,
)
print(response.json())const url = new URL('https://api.nytimes.com/svc/topstories/v2/technology.json');
url.searchParams.set('api-key', 'YOUR_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.nytimes.com/svc/topstories/v2/technology.json")
q := baseURL.Query()
q.Set("api-key", "YOUR_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
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://api.nytimes.com/svc/topstories/v2/technology.json")
uri.query = URI.encode_www_form({
"api-key" => "YOUR_KEY"
})
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://api.nytimes.com/svc/topstories/v2/technology.json?" . http_build_query([
"api-key" => "YOUR_KEY"
]);
$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
- Register at developer.nytimes.com for a free API key
- Pass api-key=YOUR_KEY on every request
- Sections: home, arts, automobiles, books, business, fashion, food, health, insider, magazine, movies, nyregion, obituaries, opinion, politics, realestate, science, sports, sundayreview, technology, theater, t-magazine, travel, upshot, us, world
What can you build with New York Times API?
New York Times API is a Media API. Developers commonly use media APIs for:
- storing and delivering images, video, and audio
- building digital asset management and media libraries
- transcoding and optimising media for the web
- adding video streaming and playback to your app
- automating content tagging and metadata extraction
API Key authentication. You'll receive a key after signing up. Send it with every request — in a header or query parameter. Keep it out of client-side code and never commit it to version control. New York Times API is free to use up to a usage limit, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide