Using the NPR API
Web managers, this guide walks you through implementing the NPR API. Possible uses for the NPR API:
What is it?
Last year, National Public Radio introduced their API, or Application Programming Interface. NPR describes the API as a way for two computer applications to talk to each other in a common language that they both understand. NPR’s API essentially provides a way for your station’s website to get NPR stories in a predictable, flexible and powerful way. The content that is available includes audio from most NPR programs as well as text, images and other web-only content.
For emergency coverage, the NPR API can provide stations with a way to integrate national and international coverage into your emergency sections of your website.
How do I use it?
NPR has made it very easy to generate API calls and import content into your local station site. Take a look at the page we created here on the SAFERStations.org site. Here’s how we did it.
1. You need to register to gain an API key in order to use the service. Both Member Stations and individuals are invited to use the NPR API. Stations should register at NPRstations.org, and individuals can gain an API key by registering at NPR.org.
2. After you have a key, visit the the NPR API Query Generator. Select the type of coverage that you are interested in.
5. Hit the “Create API Call” button and a lengthy your Query Url will appear in the box. Copy that address.
6. In your HTML editor on your site, you can use the following code to display the API content.
7. The result should display similarly to our NPR API example page.
Alternatively, stations can choose to display just the headlines from a story within a sidebar or on a section of your homepage. In the query generator under Fields, you are able to select the specific story elements to display, along with the number of stories to return. The API provides the flexibility to customize content to fit your station’s page layout.