The Old Reader

The Old Reader

  • Category: News

TheOldReader API: A Comprehensive Guide with JavaScript Examples

TheOldReader is a popular RSS reader that offers a public API for third-party developers to access its data. This API allows developers to create apps that integrate with the reader and retrieve information such as articles, categories, subscriptions, and more.

In this guide, we will explore TheOldReader API and provide examples of how to use it with JavaScript.

Authentication

To access TheOldReader API, you will need to authenticate your app with OAuth 2.0. To do so, you will need to create an account with TheOldReader and register your app.

Once you've registered your app, you can use the following JavaScript code to authenticate your app and retrieve an access token:

const clientId = 'YOUR_CLIENT_ID';
const clientSecret = 'YOUR_CLIENT_SECRET';
const redirectUri = 'https://example.com/oauth_callback';
const authorizationUrl = `https://theoldreader.com/oauth/authorize?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}`;
const tokenUrl = 'https://theoldreader.com/oauth/token';

// Redirect the user to the authorization URL
window.location = authorizationUrl;

// Once the user has authorized your app, retrieve the authorization code from the URL:
const authorizationCode = new URL(window.location).searchParams.get('code');

// Exchange the authorization code for an access token
const response = await fetch(tokenUrl, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  body: `client_id=${clientId}&client_secret=${clientSecret}&grant_type=authorization_code&code=${authorizationCode}&redirect_uri=${redirectUri}`,
});
const { access_token } = await response.json();

// Use the access token in subsequent API requests

Retrieving the User's Feeds

Once you have authenticated your app, you can retrieve the user's feeds by making a GET request to the /reader/feeds endpoint. The response will include information about the user's feeds, such as the feed ID, title, and URL.

const response = await fetch('https://theoldreader.com/reader/feeds', {
  headers: {
    Authorization: `Bearer ${access_token}`,
  },
});
const { subscriptions } = await response.json();

// Iterate over the user's subscriptions and log the title and URL of each feed
subscriptions.forEach(({ title, url }) => {
  console.log(`${title}: ${url}`);
});

Retrieving Articles from a Feed

To retrieve articles from a specific feed, you can make a GET request to the /reader/atom/feed/{feedId} endpoint, where {feedId} is the ID of the feed you want to retrieve.

const feedId = 'FEED_ID';
const response = await fetch(`https://theoldreader.com/reader/atom/feed/${feedId}`, {
  headers: {
    Authorization: `Bearer ${access_token}`,
  },
});
const text = await response.text();

// Parse the response XML using a library such as xmldom
const parser = new DOMParser();
const doc = parser.parseFromString(text, 'application/xml');
const entries = doc.getElementsByTagName('entry');

// Iterate over the entries and log the title and URL of each article
for (let i = 0; i < entries.length; i++) {
  const link = entries[i].querySelector('link');
  console.log(`${entries[i].querySelector('title').textContent}: ${link.getAttribute('href')}`);
}

Adding a Subscription

To add a new subscription to the user's account, you can make a POST request to the /reader/api/0/subscription/quickadd endpoint.

const url = 'FEED_URL';
const response = await fetch('https://theoldreader.com/reader/api/0/subscription/quickadd', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${access_token}`,
  },
  body: `quickadd=${encodeURIComponent(url)}`,
});

Conclusion

TheOldReader API provides a comprehensive set of endpoints for developers to access RSS reader data. With the examples provided in this guide, you should have a good starting point to begin building your own app and integrating with TheOldReader. Happy coding!

Visit to The Old Reader website

Similar APIs of News

Contify

Contify

News

Enrich your apps with machine-readable and properly structured news feeds with the help of Contify. It tags, duplicates, and aggregates data and delivers through RSS feeds, webhooks, and RESTful APIs. Contify offers wide coverage of clean and company-based intelligence data relevant to specific business or industry, instead of keyword-based feeds. It collects data from 200k+ sources, including company websites, online news, social media, reviews websites, regulatory portals, job boards, niche and premium publications. In addition to that, it allows you to integrate your preferred sources for fetching user-relevant data from anywhere across the globe. Contify also provides multi-language support through SmartTranslate so that you can source intel from publications in 100s of languages. They combine AI and machine-learning technologies with human intelligence to deliver deduplicated and actionable data feed, identify trends, and maintain system integrity. The platform also includes noise-filtering algorithms like NLP, NER, and disambiguation, to ensure a constant flow of quality updates. With API endpoints and customized taxonomy, they structure all the sourced data with their endpoints to align your business goals. Enjoy frictionless collaboration using a fully dedicated account management.

machinereadablestructured

Connexun

Connexun

News

Search news content in real-time by taking advantage of the sophisticated technology of Connexun that crawls and indexes thousands of sources every day. Analysing the published content becomes easy with their live dataset containing cleaned-up news feeds. It allows you to discover trending global news that their unique algorithms evaluate. You can also filter news by selecting the language of your choice and news items. Select two countries of your interest and access all the latest news from them using their InterCountry API. Similarly, you can discover popular news from the media outlets of a selected country or news from a country frequently mentioned by global news sources. There’s one more fascinating feature of Connexun – it lets you access news from a particular place using its longitude and latitude. With its powerful search engine, Connexun API can display the textual news content related to a keyword or topic and is acquired from 1 million pages each month.

newssearchengine

Contextual Web

Contextual Web

News

Search from 100k news sources to find news feeds, posts, articles, and blogs on the topic of your choice using ContextualWeb. By integrating with RapidAPI, you can obtain your API key and make a GET request within seconds. ContexualWeb has one of the most advanced search algorithms on the internet, which helps you find what you are looking for precisely and fast. They respect your privacy by employing the highest privacy protection; hence, your search history or data is never available to someone else.

feedspostsarticles

Spaceflight News

Spaceflight News

News

Get an overview of the latest Spaceflight news, Articles, Reports from various sources! Easily link your users to the right websites

spaceflightnews

News Catcher API

News Catcher API

News

News API to find news articles by any topic country language website or keyword

newscatcherapi

Hubblesite

Hubblesite

News

Space Telescope News Releases

Spacetelescopenews

News API

News API

News

Get breaking news headlines, and search for articles from over 30,000 news sources and blogs with our news API. Freaking fast because everything is asynchronously cached for a super-fast response. Free for development and easy integration.

Fastnewsblogs

Currents

Currents

News

Currents - Capture the world news through simple json news API. Latest news published in various news sources, blogs and forums. 26 Million Entries and Counting, 18 Languages, News API sourced from over 70 countries, Data from Over 17,000 sources, 70,000 articles added daily and access to historical data.

Historyheadlinesdata

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.

audiolistenchannels

Feedbin

Feedbin

News

A nice place to read on the web. Follow your passions with RSS, Twitter, and email newsletters. If you are a user of Feedbin, you can manage your pinned articles, liked content and subscriptions through this api. It also allows you to extract pages, articles and blogs with respect to their title and url.

rssneatlife