Using the Feedbin API with JavaScript

The Feedbin API provides a way to access and interact with your Feedbin account programmatically. In this tutorial, we will explore the different endpoints of the Feedbin API and learn how to use them with JavaScript.

Authentication

All requests made to the Feedbin API require authentication. You can authenticate by sending your API token in the Authorization header of your requests.

fetch('https://api.feedbin.com/v2/subscriptions.json', {
  headers: {
    'Authorization': 'Token YOUR_API_TOKEN'
  }
}).then(response => {
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
}).then(data => {
  console.log(data);
}).catch(error => {
  console.error('There was a problem fetching data:', error);
});

Replace YOUR_API_TOKEN with your Feedbin API token.

Retrieving Subscriptions

To retrieve all of your subscriptions, send a GET request to the /v2/subscriptions.json endpoint.

fetch('https://api.feedbin.com/v2/subscriptions.json', {
  headers: {
    'Authorization': 'Token YOUR_API_TOKEN'
  }
}).then(response => {
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
}).then(data => {
  console.log(data);
}).catch(error => {
  console.error('There was a problem fetching data:', error);
});

Retrieving Unread Entries

To retrieve all of your unread entries, send a GET request to the /v2/unread_entries.json endpoint.

fetch('https://api.feedbin.com/v2/unread_entries.json', {
  headers: {
    'Authorization': 'Token YOUR_API_TOKEN'
  }
}).then(response => {
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
}).then(data => {
  console.log(data);
}).catch(error => {
  console.error('There was a problem fetching data:', error);
});

Marking Entries as Read

To mark entries as read, send a POST request to the /v2/mark_entries.json endpoint with the entry IDs in the request body.

fetch('https://api.feedbin.com/v2/mark_entries.json', {
  method: 'POST',
  headers: {
    'Authorization': 'Token YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    entry_ids: [123, 456, 789]
  })
}).then(response => {
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  console.log('Entries marked as read.');
}).catch(error => {
  console.error('There was a problem marking entries as read:', error);
});

Replace [123, 456, 789] with the entry IDs you want to mark as read.

Conclusion

The Feedbin API provides a simple and powerful way to access and interact with your Feedbin account. In this tutorial, we learned how to retrieve subscriptions and unread entries, and how to mark entries as read using JavaScript and the Fetch API.

For more information on the available endpoints and parameters, check out the Feedbin API documentation.

Related APIs