NPR One

NPR One

News

Personalised news LISTENING experience from NPR. Get listings according to available channels, organisations, recommendations, ratings, history, aggregation and make search queries.

Visit API

📚 Documentation & Examples

Everything you need to integrate with NPR One

🚀 Quick Start Examples

NPR One Javascript Examplejavascript
// NPR One API Example
const response = await fetch('http://dev.npr.org/api/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Exploring the NPR API with JavaScript

If you're looking for a way to access news articles, topics, and programs from National Public Radio (NPR), you're in luck. NPR offers a public API that allows developers to retrieve data from its extensive database of news content.

In this guide, we'll explore how to use the NPR API with JavaScript, and we'll provide some examples of API calls that you can try out for yourself.

Getting Started with the NPR API

To begin using the NPR API, you'll need to sign up for an API key. This key is what you'll use to authenticate your requests and access the API's resources.

Once you have your API key, you can start making API requests using a GET request to a specific endpoint. Endpoints are URLs that correspond to different types of data within the NPR API.

Example API Calls

Here are a few examples of API calls you can make using JavaScript and the NPR API.

Retrieve a List of News Articles

const apiKey = "YOUR_API_KEY_HERE";
const nprEndpoint = "https://api.npr.org/query";

const query = "term=tech";
const apiUrl = `${nprEndpoint}?${query}&apiKey=${apiKey}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.log(error));

This code sends a GET request to the NPR API with a search term of "tech". The API responds with a list of news articles that match the search term.

Retrieve Information on a Specific Topic

const apiKey = "YOUR_API_KEY_HERE";
const nprEndpoint = "https://api.npr.org/query";

const id = "1007";
const query = `id=${id}`;
const apiUrl = `${nprEndpoint}?${query}&apiKey=${apiKey}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.log(error));

This code sends a GET request to the NPR API with a specific topic ID of "1007". The API responds with information on the topic, including its name, description, and related news articles.

Retrieve Information on a Specific Program

const apiKey = "YOUR_API_KEY_HERE";
const nprEndpoint = "https://api.npr.org/query";

const id = "2";
const query = `id=${id}`;
const apiUrl = `${nprEndpoint}?${query}&apiKey=${apiKey}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.log(error));

This code sends a GET request to the NPR API with a specific program ID of "2". The API responds with information on the program, including its name, description, and related news articles.

Conclusion

The NPR API offers a wealth of information for developers looking to access news content from National Public Radio. With the right API key and a little bit of JavaScript knowledge, you can build your own applications that consume data from this robust API endpoint.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jun 4Jun 6Jun 8Jun 10Jun 12Jun 14Jun 16Jun 18Jun 20Jun 22Jun 24Jun 26Jun 28Jun 30Jul 304008001440Minutes
Online
Offline

Related APIs in News